iOS: This process has exceeded the maximum allowable number of active process assertions

Viewed 657

We have developed an app where a number of file downloads take place. The error occurs randomly when the process is on going on. I have done research about a similar issue like "active assertions beyond permitted time" and it's pretty straightforward. What can be causing this issue? The error report is as follows. We are using JGDownloadAcceleration and the download occurs with multipart download.

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 exceeded 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
1 Answers

Several days ago, I faced the same error as yours. After a lot of deep code research, I was able to reproduce the error every time and solved it successfully. This error occurred only on iOS 11.0 and later.

It turns out that if a UIBackgroundTaskIdentifier is created many many times, the app would crash.

In my test demo, I created a UIBackgroundTaskIdentifier in a for-loop and ran it 7000 times (the number could be different according to your code complexity), and this error occurred:

Termination Description: SPRINGBOARD, This process has exceeded the maximum allowable number of active process assertions

Since Xcode cannot catch this termination description, you need to view the device logs manually.

screenshot showing termination description

So for your case, I guess you have too many concurrent download tasks and each download task has a UIBackgroundTaskIdentifier. You can solve it by reducing the number of concurrent download tasks, creating them only as needed, like 10 or fewer.

Below is my test code:

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
}
Related