Background Assets are integrated into our online Appstore. However, after launching the APP, we collected many crashes of Background Assets framework through our crash system.
1、BADownloadManager.sharedManager.fetchCurrentDownloadsWithCompletionHandler. Then, I am reinitiating the tasks through startForegroundDownload. However, occasionally there is a crash with EXC_BREAKPOINT
[BADownloadManager.sharedManager fetchCurrentDownloadsWithCompletionHandler:^(NSArray<BADownload *> * _Nonnull downloads, NSError * _Nullable error) {
if (error){
return;
}
for (BADownload *download in downloads) {
if ([urlList containsObject:download.identifier]){
if (download.state == BADownloadStateFailed) {
return;
}
NSError *downloadError;
BOOL succes = [BADownloadManager.sharedManager startForegroundDownload:download error:&downloadError];
if (downloadError) {
LogError(BADownloadLog,@"startForegroundDownload url:%@ error:%@",download.identifier,downloadError);
}else if(succes){
LogInfo(BADownloadLog,@"startForegroundDownload:%@",download.identifier);
[self addDowdloadingUrl:download.identifier];
}
}
}
}];
The following crashes exist:
Thread 3 (crashed)
0 BackgroundAssets!-[BADownloadManager startForegroundDownload:error:] + 0x100
Found by: given as instruction pointer in context
1 BackgroundAssets!-[BADownloadManager startForegroundDownload:error:] + 0xe0
Found by: previous frame's frame pointer
2 YYMobile!__46-[YYBADownloadManager executeDownload:finish:]_block_invoke [YYBADownloadManager.m : 180 + 0xc]
Found by: previous frame's frame pointer
3 libdispatch.dylib!_dispatch_call_block_and_release + 0x1c
Found by: previous frame's frame pointer
4 libdispatch.dylib!_dispatch_client_callout + 0x10
Found by: previous frame's frame pointer
5 libdispatch.dylib!_dispatch_lane_serial_drain + 0x298
Found by: previous frame's frame pointer
6 libdispatch.dylib!_dispatch_lane_invoke + 0x17c
Found by: previous frame's frame pointer
7 libdispatch.dylib!_dispatch_workloop_worker_thread + 0x284
Found by: previous frame's frame pointer
8 libsystem_pthread.dylib!_pthread_wqthread + 0x11c
Found by: previous frame's frame pointer
See attachment "iOS.crash" for the complete crash file.
Ask what, do I need to use exclusive control when accessing BADownload?2、Handling failed callbacks in background download extension, rearranging necessary resources crashed
- (void)backgroundDownload:(BADownload *)download failedWithError:(NSError *)error
{
// Extension was woken because a download failed.
// A download can be rescheduled with BADownloadManager if necessary.
if (![download isKindOfClass:[BAURLDownload class]]) {
return;
}
if (download.isEssential){
BADownload *nonEssential = [download copyAsNonEssential];
[BADownloadManager.sharedManager scheduleDownload:nonEssential error:nil];
}
}
Have a crash:
hread 1 Crashed:
0 BackgroundAssets 0x0000000245b47dac -[BADownload setPriority:] + 176 (BADownload.m:249)
1 BackgroundAssets 0x0000000245b47bb4 -[BADownload copyWithZone:] + 188 (BADownload.m:217)
2 BackgroundAssets 0x0000000245b46db0 -[BAURLDownload copyWithZone:] + 52 (BAURLDownload.m:127)
3 BackgroundAssets 0x0000000245b47f7c -[BADownload copyAsNonEssential] + 20 (BADownload.m:368)
4 YYBackgroundDownload 0x0000000100de8a88 0x100de4000 + 19080
5 BackgroundAssets 0x0000000245b3fd50 __88-[BADownloaderExtensionConnection backgroundDownload:failedWithError:completionHandler:]_block_invoke + 56 (BADownloaderExtensionConnection.m:178)
6 libdispatch.dylib 0x00000001d8080320 _dispatch_call_block_and_release + 32 (init.c:1518)
7 libdispatch.dylib 0x00000001d8081eac _dispatch_client_callout + 20 (object.m:560)
8 libdispatch.dylib 0x00000001d8089534 _dispatch_lane_serial_drain + 668 (inline_internal.h:2640)
9 libdispatch.dylib 0x00000001d808a0a4 _dispatch_lane_invoke + 384 (queue.c:3966)
10 libdispatch.dylib 0x00000001d8094cdc _dispatch_workloop_worker_thread + 648 (queue.c:6913)
11 libsystem_pthread.dylib 0x0000000230547ddc _pthread_wqthread + 288 (pthread.c:2618)
12 libsystem_pthread.dylib 0x0000000230547b7c start_wqthread + 8 (:-1)
Details see attachment