Is there a way for me to programmatically query whether if my AVAudioSession is able to play even when app is minimized/screen is locked? I need this to debug background audio permissions as my AVAudioSession keeps getting paused while app goes into background and it resumes once it goes into the foreground. Moreover, when I try to call setActive for AVAudioSession in didEnterBackground, it gives me the error code 561015905 which says it is permission related.
My Info.plist already has
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
added to it.
Post
Replies
Boosts
Views
Activity
Good day,
I have a use case that I am currently facing problems with.
I am currently implementing a downloader service that uses some c++ code to download in the foreground, and when the user backgrounds the app, NSURLSession kicks in.
Due to chunking, we have a bunch of endpoints that contain ~1mb worth of data for each chunk, and these chunks make up a full file when processed. Small files would be downloaded as is.
As such, there might potentially be ten thousands worth of endpoints that NSURLSession might need to download from in the background.
From what I've read around here, there are four things to take note of.
Resume Rate Limiter
Number of tasks queued into nsurlsessiond
Number of concurrently running tasks
NSUrlSessionDownloadTask creation
My current implementation is to create a bunch of tasks in applicationDidEnterBackground(_:) and then starting them all at once. However, NSUrlSessionDownloadTask creation is very expensive. As a reference, it takes 3.7 seconds to create 400 tasks on my iPhone 7+.
Upwards of 500 task creation and it runs into the territory of the OS terminating my app as I did not return out of applicationDidEnterBackground(_:) in five seconds.
Creation of new tasks when the first batch ends is also not an option because of resume rate limiter. According to here, the delay is really heavy and is something I would like to avoid.
Are there any viable solutions that would solve my problem of downloading many files in the background? Thanks in advance!
Hey everyone,
My iPhone Simulator is crashing and I have no idea why. I do not have any other version of xcode installed. Help would be much appreciated, thank you!
Things I've tried:
Restarting my Mac
Deleting DerivedData
Removing and adding simulators again
Deleting simulator devices folder
Deleting and reinstalling XCode
Logs:
Path: /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc/Contents/MacOS/com.apple.CoreSimulator.CoreSimulatorService
Identifier: com.apple.CoreSimulator.CoreSimulatorService
Version: 757.5 (757.5)
Build Info: CoreSimulator-757005000000000~3
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: com.apple.CoreSimulator.CoreSimulatorService [11520]
User ID: 502
Date/Time: 2021-07-13 13:57:24.473 +0800
OS Version: macOS 11.3.1 (20E241)
Report Version: 12
Bridge OS Version: 5.4 (18P4663)
Anonymous UUID: DA87579E-F81A-C741-91FF-F40AB201657A
Time Awake Since Boot: 6400 seconds
System Integrity Protection: enabled
Crashed Thread: 4 Dispatch queue: com.apple.CoreSimulator.SimDevice.bootstrapQueue.BA21E3E3-75C5-45D2-A436-F239AE809C23
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-createLaunchdJobWithError:extraEnvironment:disabledJobs: failed, but it did not return an error.'
terminating with uncaught exception of type NSException
abort() called
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff2052698b __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff2025ed92 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2054faf2 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff2134482c -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 166
4 CoreSimulator 0x000000010ca45f70 -[SimDevice _onBootstrapQueue_bootWithOptions:deathMonitorPort:error:] + 4210
5 CoreSimulator 0x000000010ca447b2 -[SimDevice _onBootstrapQueue_bootWithOptions:error:] + 1142
6 CoreSimulator 0x000000010ca5be0b __67-[SimDevice bootstrapQueueAsync:completionQueue:completionHandler:]_block_invoke + 41
7 libdispatch.dylib 0x00007fff20208603 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x00007fff202097e6 _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fff2020f5ca _dispatch_lane_serial_drain + 606
10 libdispatch.dylib 0x00007fff202100c0 _dispatch_lane_invoke + 417
11 libdispatch.dylib 0x00007fff20219bed _dispatch_workloop_worker_thread + 811
12 libsystem_pthread.dylib 0x00007fff203b04c0 _pthread_wqthread + 314
13 libsystem_pthread.dylib 0x00007fff203af493 start_wqthread + 15
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff2037e32a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff2037e69c mach_msg + 60
2 com.apple.CoreFoundation 0x00007fff204acc6f __CFRunLoopServiceMachPort + 316
3 com.apple.CoreFoundation 0x00007fff204ab34f __CFRunLoopRun + 1328
4 com.apple.CoreFoundation 0x00007fff204aa75c CFRunLoopRunSpecific + 563
5 com.apple.HIToolbox 0x00007fff286cc203 RunCurrentEventLoopInMode + 292
6 com.apple.HIToolbox 0x00007fff286cbf65 ReceiveNextEventCommon + 587
7 com.apple.HIToolbox 0x00007fff286cbd03 _BlockUntilNextEventMatchingListInModeWithFilter + 70
8 com.apple.AppKit 0x00007fff22ca6b32 _DPSNextEvent + 864
9 com.apple.AppKit 0x00007fff22ca5305 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1364
10 com.apple.AppKit 0x00007fff22c97679 -[NSApplication run] + 586
11 com.apple.AppKit 0x00007fff22c6b85c NSApplicationMain + 816
12 libxpc.dylib 0x00007fff201023eb _xpc_objc_main + 919
13 libxpc.dylib 0x00007fff20101cd3 xpc_main + 116
14 com.apple.CoreSimulator.CoreSimulatorService 0x000000010c9f3ec1 main + 1597
15 libdyld.dylib 0x00007fff203cef3d start + 1
Thread 1:
0 libsystem_pthread.dylib 0x00007fff203af484 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x00007fff203af484 start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x00007fff203af484 start_wqthread + 0
Thread 4 Crashed:: Dispatch queue: com.apple.CoreSimulator.SimDevice.bootstrapQueue.BA21E3E3-75C5-45D2-A436-F239AE809C23
0 libsystem_kernel.dylib 0x00007fff20384946 __pthread_kill + 10
1 libsystem_pthread.dylib 0x00007fff203b3615 pthread_kill + 263
2 libsystem_c.dylib 0x00007fff20308411 abort + 120
3 libc++abi.dylib 0x00007fff20376ef2 abort_message + 241
4 libc++abi.dylib 0x00007fff203685fd demangling_terminate_handler() + 266
5 libobjc.A.dylib 0x00007fff2026158d _objc_terminate() + 96
6 libc++abi.dylib 0x00007fff20376307 std::__terminate(void (*)()) + 8
7 libc++abi.dylib 0x00007fff203762a9 std::terminate() + 41
8 libdispatch.dylib 0x00007fff202097fa _dispatch_client_callout + 28
9 libdispatch.dylib 0x00007fff2020f5ca _dispatch_lane_serial_drain + 606
10 libdispatch.dylib 0x00007fff202100c0 _dispatch_lane_invoke + 417
11 libdispatch.dylib 0x00007fff20219bed _dispatch_workloop_worker_thread + 811
12 libsystem_pthread.dylib 0x00007fff203b04c0 _pthread_wqthread + 314
13 libsystem_pthread.dylib 0x00007fff203af493 start_wqthread + 15
I can provide additional logs if needed.