We're getting several crashes recently with this stack:
Thread : Fatal Exception: NSInternalInconsistencyException, via: Assert(_asyncTaskCount >= 0);
0 CoreFoundation 0x30082fd3 __exceptionPreprocess + 130
1 libobjc.A.dylib 0x3ac4accf objc_exception_throw + 38
2 CoreFoundation 0x30082ead +[NSException raise:format:]
3 Foundation 0x30a2fdb7 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 86
4 <myApp> 0x00702b9f _AssertFailed (Test.m:348)
5 <myApp> 0x006c8a4f -[CBL_Replicator asyncTasksFinished:] + 106
6 <myApp> 0x006cd041 __33-[CBL_Puller pullRemoteRevision:]_block_invoke (CBL_Puller.m:431)
7 <myApp> 0x006d5733 -[CBLRemoteRequest respondWithResult:error:] (CBLRemoteRequest.m:153)
8 <myApp> 0x006d5885 -[CBLRemoteRequest stop] (CBLRemoteRequest.m:174)
9 CoreFoundation 0x2fff31f5 -[NSArray makeObjectsPerformSelector:] + 300
10 <myApp> 0x006c9f67 -[CBL_Replicator stopRemoteRequests] (CBL_Replicator.m:730)
11 <myApp> 0x006c8457 -[CBL_Replicator goOffline] (CBL_Replicator.m:414)
12 <myApp> 0x006cbdef -[CBL_Puller goOffline] (CBL_Puller.m:197)
13 <myApp> 0x006c86f1 -[CBL_Replicator reachabilityChanged:] (CBL_Replicator.m:460)
14 <myApp> 0x006c8895 -[CBL_Replicator updateActive] (CBL_Replicator.m:482)
15 <myApp> 0x006cd041 __33-[CBL_Puller pullRemoteRevision:]_block_invoke (CBL_Puller.m:431)
16 <myApp> 0x006d5733 -[CBLRemoteRequest respondWithResult:error:] (CBLRemoteRequest.m:153)
17 <myApp> 0x006d6425 -[CBLRemoteRequest connection:didFailWithError:] (CBLRemoteRequest.m:369)
18 <myApp> 0x006d5957 -[CBLRemoteRequest cancelWithStatus:] (CBLRemoteRequest.m:184)
19 <myApp> 0x006e0efd -[CBLMultipartDownloader connection:didReceiveResponse:] (CBLMultipartDownloader.m:87)
20 Foundation 0x309c1fc3 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 54
21 Foundation 0x309c1f07 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 206
22 Foundation 0x309c1e21 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 60
23 Foundation 0x309c1ddf _NSURLConnectionDidReceiveResponse + 82
...
36 <myApp> 0x006c5803 -[CBL_Server runServerThread] (CBL_Server.m:113)
What exactly is CBLMultipartDownloader? Does it relate to CBL attachments? There should be no reason for this document to be downloading an attachment, BUT we last updated CBL April 16. The last code we got was
b9221d0 was from Jens Alfke, April 15 "Merge branch 'master' into stable. Which I found out today means we have a CBL bug (introduced March 31) where attachments get uploaded/downloaded more often than they need to (issue #326).
I'll try to arrange a pull of CBL in the next week, which should fix that particular bug, but am worried it would merely mask whatever crashing bug is happening in this stack, by making binary attachment transfer only happen when it actually needs to (which isn't that often for us).
Note that in all the crashlytics stacks, the percentage of crashes when the app is in the foreground is 0%. So this is only happening when our app has been sent to the background, which I assume may help diagnose the problem...
I see that issue #336 also refers to this same assertion (_asyncTaskCount >= 0), but that stack refers to CBLMultipartUploader, followed by reachabilityChanged: whereas the crash I'm seeing is CBLMultipartDownloader followed by reachabilityChanged. I'm not sure if that makes this a different issue or the same issue.
-- Tim Gogolin
Adobe Systems Inc.