我们开发了一个应用程序,可以进行大量的文件下载。当进程正在进行时,错误随机发生。我已经研究了一个类似的问题,比如“超出允许时间的主动断言”,而且非常简单。可能导致此问题的原因是什么?错误报告如下。我们正在使用JGDownloadAcceleration,下载是通过多部分下载进行的。
Incident Identifier: 239DA305-5FDF-4A30-89B3-4446F9AE30D1
CrashReporter Key: e098bda19a9d7115be19b2cd34281cc9cd13aa21
Hardware Model: iPad4,2
Process: Sales Aid [1345]
Path: /private/var/containers/Bundle/Application/176AB0ED-44CD-4454-9096-47DB42663789/Sales Aid.app/Sales Aid
Version: 3.7.47 (3.7.47)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Date/Time: 2017-09-29 10:36:22.4001 +0530
Launch Time: 2017-09-29 08:56:13.0757 +0530
OS Version: iPhone OS 11.0 (15A372)
Baseband Version: 8.01.00
Report Version: 104
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: Namespace SPRINGBOARD, Code 0xbada5e47
Termination Description: SPRINGBOARD, This process has exceeeded the maximum allowable number of active process assertions
Triggered by Thread: 0
Filtered syslog:
None found
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x0000000185b68bc4 0x185b68000 + 3012
1 libsystem_kernel.dylib 0x0000000185b68a3c 0x185b68000 + 2620
2 CoreFoundation 0x0000000186017ce4 0x185f2e000 + 957668
3 CoreFoundation 0x00000001860158b0 0x185f2e000 + 948400
4 CoreFoundation 0x0000000185f362d8 0x185f2e000 + 33496
5 GraphicsServices 0x0000000187dc7f84 0x187dbd000 + 44932
6 UIKit 0x000000018f4e2880 0x18f46f000 + 473216
7 Sales Aid 0x00000001003919b4 0x10038c000 + 22964
8 libdyld.dylib 0x0000000185a5a56c 0x185a59000 + 5484
Thread 1:
0 libsystem_kernel.dylib 0x0000000185b89150 0x185b68000 + 135504
1 libsystem_pthread.dylib 0x0000000185c9ed40 0x185c9a000 + 19776
2 PSPDFKit 0x00000001018dc06c 0x101444000 + 4817004
3 PSPDFKit 0x00000001018da03c 0x101444000 + 4808764
4 PSPDFKit 0x0000000101a97988 0x101444000 + 6633864
5 libsystem_pthread.dylib 0x0000000185c9c32c 0x185c9a000 + 9004
6 libsystem_pthread.dylib 0x0000000185c9c1f8 0x185c9a000 + 8696
7 libsystem_pthread.dylib 0x0000000185c9ac38 0x185c9a000 + 3128
Thread 2 name: com.apple.uikit.eventfetch-thread
Thread 2:
0 libsystem_kernel.dylib 0x0000000185b68bc4 0x185b68000 + 3012
1 libsystem_kernel.dylib 0x0000000185b68a3c 0x185b68000 + 2620
2 CoreFoundation 0x0000000186017ce4 0x185f2e000 + 957668
3 CoreFoundation 0x00000001860158b0 0x185f2e000 + 948400
4 CoreFoundation 0x0000000185f362d8 0x185f2e000 + 33496
5 Foundation 0x000000018695e6e4 0x186952000 + 50916
6 Foundation 0x000000018697dafc 0x186952000 + 178940
7 UIKit 0x000000019002e02c 0x18f46f000 + 12316716
8 Foundation 0x0000000186a5f860 0x186952000 + 1103968
9 libsystem_pthread.dylib 0x0000000185c9c32c 0x185c9a000 + 9004
10 libsystem_pthread.dylib 0x0000000185c9c1f8 0x185c9a000 + 8696
11 libsystem_pthread.dylib 0x0000000185c9ac38 0x185c9a000 + 3128
Thread 3 name: com.twitter.crashlytics.ios.MachExceptionServer
Thread 3:
0 libsystem_kernel.dylib 0x0000000185b68bc4 0x185b68000 + 3012
1 libsystem_kernel.dylib 0x0000000185b68a3c 0x185b68000 + 2620
2 Sales Aid 0x00000001005685cc 0x10038c000 + 1951180
3 libsystem_pthread.dylib 0x0000000185c9c32c 0x185c9a000 + 9004
4 libsystem_pthread.dylib 0x0000000185c9c1f8 0x185c9a000 + 8696
5 libsystem_pthread.dylib 0x0000000185c9ac38 0x185c9a000 + 3128
Thread 4 name: com.apple.NSURLConnectionLoader
Thread 4:
0 libsystem_kernel.dylib 0x0000000185b68bc4 0x185b68000 + 3012
1 libsystem_kernel.dylib 0x0000000185b68a3c 0x185b68000 + 2620
2 CoreFoundation 0x0000000186017ce4 0x185f2e000 + 957668
3 CoreFoundation 0x00000001860158b0 0x185f2e000 + 948400
4 CoreFoundation 0x0000000185f362d8 0x185f2e000 + 33496
5 CFNetwork 0x000000018669fb40 0x1865f1000 + 715584
6 Foundation 0x0000000186a5f860 0x186952000 + 1103968
7 libsystem_pthread.dylib 0x0000000185c9c32c 0x185c9a000 + 9004
8 libsystem_pthread.dylib 0x0000000185c9c1f8 0x185c9a000 + 8696
9 libsystem_pthread.dylib 0x0000000185c9ac38 0x185c9a000 + 3128
Thread 5 name: JGDownloadAcceleration
Thread 5:
0 libsystem_kernel.dylib 0x0000000185b68bc4 0x185b68000 + 3012
1 libsystem_kernel.dylib 0x0000000185b68a3c 0x185b68000 + 2620
2 CoreFoundation 0x0000000186017ce4 0x185f2e000 + 957668
3 CoreFoundation 0x00000001860158b0 0x185f2e000 + 948400
4 CoreFoundation 0x0000000185f362d8 0x185f2e000 + 33496
5 Foundation 0x000000018695e6e4 0x186952000 + 50916
6 Foundation 0x00000001869b062c 0x186952000 + 386604
7 Sales Aid 0x00000001004b3ef0 0x10038c000 + 1212144
8 Foundation 0x0000000186a5f860 0x186952000 + 1103968
9 libsystem_pthread.dylib 0x0000000185c9c32c 0x185c9a000 + 9004
10 libsystem_pthread.dylib 0x0000000185c9c1f8 0x185c9a000 + 8696
11 libsystem_pthread.dylib 0x0000000185c9ac38 0x185c9a000 + 3128
Thread 6:
0 libsystem_pthread.dylib 0x0000000185c9ac2c 0x185c9a000 + 3116
Thread 7 name: Dispatch queue: cocoa.lumberjack
Thread 7:
0 libsystem_kernel.dylib 0x0000000185b68c00 0x185b68000 + 3072
1 libdispatch.dylib 0x00000001859f73d4 0x1859f4000 + 13268
2 libdispatch.dylib 0x00000001859f8328 0x1859f4000 + 17192
3 Sales Aid 0x0000000100487678 0x10038c000 + 1029752
4 Sales Aid 0x0000000100485d90 0x10038c000 + 1023376
5 libdispatch.dylib 0x00000001859f5088 0x1859f4000 + 4232
6 libdispatch.dylib 0x00000001859f5048 0x1859f4000 + 4168
7 libdispatch.dylib 0x00000001859fee48 0x1859f4000 + 44616
8 libdispatch.dylib 0x00000001859ff7d8 0x1859f4000 + 47064
9 libdispatch.dylib 0x0000000185a00200 0x1859f4000 + 49664
10 libdispatch.dylib 0x0000000185a084a0 0x1859f4000 + 83104
11 libsystem_pthread.dylib 0x0000000185c9afe0 0x185c9a000 + 4064
12 libsystem_pthread.dylib 0x0000000185c9ac30 0x185c9a000 + 3120
Thread 8:
0 libsystem_pthread.dylib 0x0000000185c9ac2c 0x185c9a000 + 3116
Thread 9 name: Dispatch queue: com.apple.root.default-qos
Thread 9:
0 libsystem_kernel.dylib 0x0000000185b8a800 0x185b68000 + 141312
1 libdispatch.dylib 0x0000000185a108f8 0x1859f4000 + 116984
2 libdispatch.dylib 0x0000000185a112c0 0x1859f4000 + 119488
3 libdispatch.dylib 0x0000000185a03018 0x1859f4000 + 61464
4 CoreData 0x00000001888aeda8 0x1887d4000 + 896424
5 Sales Aid 0x00000001006503fc 0x10038c000 + 2900988
6 Sales Aid 0x0000000100650038 0x10038c000 + 2900024
7 Sales Aid 0x000000010064ff44 0x10038c000 + 2899780
8 Sales Aid 0x000000010064fec8 0x10038c000 + 2899656
9 Sales Aid 0x0000000100651594 0x10038c000 + 2905492
10 Sales Aid 0x0000000100651948 0x10038c000 + 2906440
11 Sales Aid 0x000000010063dea0 0x10038c000 + 2825888
12 Sales Aid 0x0000000100812e14 0x10038c000 + 4746772
13 Sales Aid 0x0000000100812ca8 0x10038c000 + 4746408
14 Sales Aid 0x00000001006d94f4 0x10038c000 + 3462388
15 Sales Aid 0x00000001006d25c0 0x10038c000 + 3433920
16 Sales Aid 0x000000010081fba4 0x10038c000 + 4799396
17 Sales Aid 0x000000010081e5f0 0x10038c000 + 4793840
18 Sales Aid 0x000000010081ee80 0x10038c000 + 4796032
19 Sales Aid 0x00000001004b5268 0x10038c000 + 1217128
20 Foundation 0x0000000186a38b70 0x186952000 + 945008
21 libdispatch.dylib 0x00000001859f5088 0x1859f4000 + 4232
22 libdispatch.dylib 0x00000001859f5048 0x1859f4000 + 4168
23 libdispatch.dylib 0x0000000185a02378 0x1859f4000 + 58232
24 libdispatch.dylib 0x0000000185a01f10 0x1859f4000 + 57104
25 libsystem_pthread.dylib 0x0000000185c9b130 0x185c9a000 + 4400
26 libsystem_pthread.dylib 0x0000000185c9ac30 0x185c9a000 + 3120
Thread 10 name: Dispatch queue: com.apple.root.default-qos
Thread 10:
0 libsystem_kernel.dylib 0x0000000185b68c00 0x185b68000 + 3072
1 libdispatch.dylib 0x00000001859f73d4 0x1859f4000 + 13268
2 libdispatch.dylib 0x00000001859f7d84 0x1859f4000 + 15748
3 Sales Aid 0x000000010083bbbc 0x10038c000 + 4914108
4 Sales Aid 0x000000010083b6b4 0x10038c000 + 4912820
5 Sales Aid 0x000000010083b13c 0x10038c000 + 4911420
6 Sales Aid 0x000000010070bc50 0x10038c000 + 3669072
7 Sales Aid 0x000000010065db24 0x10038c000 + 2956068
8 Sales Aid 0x000000010065d70c 0x10038c000 + 2955020
9 Sales Aid 0x0000000100828ee4 0x10038c000 + 4837092
10 libdispatch.dylib 0x00000001859f5088 0x1859f4000 + 4232
11 libdispatch.dylib 0x00000001859f5048 0x1859f4000 + 4168
12 libdispatch.dylib 0x00000001859fc090 0x1859f4000 + 32912
13 libdispatch.dylib 0x0000000185a021c8 0x1859f4000 + 57800
14 libdispatch.dylib 0x0000000185a01f10 0x1859f4000 + 57104
15 libsystem_pthread.dylib 0x0000000185c9b130 0x185c9a000 + 4400
16 libsystem_pthread.dylib 0x0000000185c9ac30 0x185c9a000 + 3120
Thread 11:
0 libsystem_pthread.dylib 0x0000000185c9ac2c 0x185c9a000 + 3116
Thread 12:
0 libsystem_pthread.dylib 0x0000000185c9ac2c 0x185c9a000 + 3116
Thread 13:
0 libsystem_pthread.dylib 0x0000000185c9ac2c 0x185c9a000 + 3116
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000010004005 x1: 0x0000000007000806 x2: 0x0000000000000000 x3: 0x0000000000000c00
x4: 0x0000000000002603 x5: 0x00000000ffffffff x6: 0x0000000000000000 x7: 0x0000000189f5e7d0
x8: 0x00000000fffffbbf x9: 0x0000000007000000 x10: 0x0000000007000100 x11: 0x0000000000000040
x12: 0xffffffffffffffff x13: 0x0000000000000001 x14: 0x0a21bd000a21bd00 x15: 0x0000000000000000
x16: 0xffffffffffffffe1 x17: 0x00000000ffffffff x18: 0x0000000000000000 x19: 0x0000000000000000
x20: 0x00000000ffffffff x21: 0x0000000000002603 x22: 0x0000000000000c00 x23: 0x000000016fa72cf8
x24: 0x0000000007000806 x25: 0x0000000000000000 x26: 0x0000000007000806 x27: 0x0000000000000c00
x28: 0x0000000000000001 fp: 0x000000016fa72bf0 lr: 0x0000000185b68a3c
sp: 0x000000016fa72ba0 pc: 0x0000000185b68bc4 cpsr: 0x60000000
答案 0 :(得分:3)
几天前,我遇到了和你一样的错误。经过大量深入的代码研究,我每次都能重现错误并成功解决。此错误仅在iOS 11.0及更高版本上发生。
事实证明,如果多次创建UIBackgroundTaskIdentifier
,应用程序就会崩溃。
在我的测试演示中,我在for循环中创建了一个UIBackgroundTaskIdentifier
并运行了7000次(根据您的代码复杂性,数字可能会有所不同),并且发生了以下错误:
终止说明:SPRINGBOARD,此过程超出了最大允许活动进程断言数
注意:"超越"在实际的错误消息中是拼写错误。
由于Xcode无法捕获此终止描述,因此您需要手动查看设备日志。
因此,对于您的情况,我猜您有太多的并发下载任务,每个下载任务都有一个UIBackgroundTaskIdentifier
。您可以通过减少并发下载任务的数量来解决这个问题,只在需要时创建它们,例如10个或更少。
以下是我的测试代码:
for (int i = 0; i < 7000; i++)
{
//xxxxxx: any code
NSLog(@"==== %zd", i);
__block UIBackgroundTaskIdentifier backgroundTask;
backgroundTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^ {
[[UIApplication sharedApplication] endBackgroundTask: backgroundTask];
backgroundTask = UIBackgroundTaskInvalid;
}];
//xxxxxx: any code
}