I have an iOS app that can play audio books as FairPlay DRM'd audio streams. I'm using AVContentKeySession
to fetch keys and AVQueuePlayer
to play. It works great on iOS, but on Catalyst (Monterey 12.3.1, M1 Max MacBook Pro) it crashes. When it happens in debug, I get a message "Too few bits left in input buffer" printed to the console, and an exception is thrown in the guts of what appears to be core media. Here's the output from [NSThread callStackSymbols]
when paused on an exception breakpoint at that point:
0 ??? 0x0000000156b8cc9c 0x0 + 5749918876,
1 BRFree 0x000000010445cf08 main + 0,
2 AudioCodecs 0x0000000157918c24 _ZL11GetPropertyPvjPjS_ + 52,
3 AudioToolboxCore 0x00000001862536a4 _ZN15ADTSAudioStream11ParseHeaderER27AudioFileStreamContinuation + 1060,
4 AudioToolboxCore 0x000000018624259c AudioFileStreamParseBytes + 412,
5 MediaToolbox 0x00000001915f7d98 FigManifoldCreateForICY + 2176,
6 MediaToolbox 0x00000001915f7718 FigManifoldCreateForICY + 512,
7 MediaToolbox 0x00000001916bbd78 FigPlayerStreamCreate + 315920,
8 MediaToolbox 0x0000000191a269a0 FigMetadataConverterCreateForQuickTimeToFromiTunes + 45888,
9 MediaToolbox 0x0000000191a4a290 FigMetadataConverterCreateForQuickTimeToFromiTunes + 191536,
10 MediaToolbox 0x0000000191a2a470 FigMetadataConverterCreateForQuickTimeToFromiTunes + 60944,
11 MediaToolbox 0x0000000191a28c34 FigMetadataConverterCreateForQuickTimeToFromiTunes + 54740,
12 MediaToolbox 0x0000000191a413b4 FigMetadataConverterCreateForQuickTimeToFromiTunes + 154964,
13 MediaToolbox 0x0000000191a2f144 FigMetadataConverterCreateForQuickTimeToFromiTunes + 80612,
14 MediaToolbox 0x00000001917cae64 FigAlternateFilterMonitorCreateForThermalNotification + 30428,
15 MediaToolbox 0x00000001917ccb44 FigAlternateFilterMonitorCreateForThermalNotification + 37820,
16 MediaToolbox 0x00000001917cb134 FigAlternateFilterMonitorCreateForThermalNotification + 31148,
17 CFNetwork 0x0000000189937cd4 _CFHostIsDomainTopLevelForCertificatePolicy + 27728,
18 Foundation 0x0000000185ba980c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 24,
19 Foundation 0x0000000185ba96b4 -[NSBlockOperation main] + 104,
20 Foundation 0x0000000185ba9644 __NSOPERATION_IS_INVOKING_MAIN__ + 24,
21 Foundation 0x0000000185ba88dc -[NSOperation start] + 788,
22 Foundation 0x0000000185ba85c0 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__ + 24,
23 Foundation 0x0000000185ba8478 __NSOQSchedule_f + 184,
24 libdispatch.dylib 0x00000001099f60f4 _dispatch_block_async_invoke2 + 148,
25 libdispatch.dylib 0x00000001099e2394 _dispatch_client_callout + 20,
26 libdispatch.dylib 0x00000001099eb778 _dispatch_lane_serial_drain + 980,
27 libdispatch.dylib 0x00000001099ec814 _dispatch_lane_invoke + 492,
28 libdispatch.dylib 0x00000001099f9fc8 _dispatch_root_queue_drain + 408,
29 libdispatch.dylib 0x00000001099f9d3c _dispatch_worker_thread + 264,
30 libsystem_pthread.dylib 0x00000001094e1890 _pthread_start + 148,
31 libsystem_pthread.dylib 0x00000001094ebaa8 thread_start + 8
In the Debug Navigator, the top of the stack looks a little different:
#0 0x0000000184bdeb3c in __cxa_throw ()
#1 0x000000015791941c in ACMP4AACLowComplexityDecoder::GetProperty(unsigned int, unsigned int&, void*) ()
#2 0x0000000157918c24 in GetProperty(void*, unsigned int, unsigned int*, void*) ()
#3 0x00000001862536a4 in ADTSAudioStream::ParseHeader(AudioFileStreamContinuation&) ()
#4 0x000000018624259c in AudioFileStreamParseBytes ()
#5 0x00000001915f7d98 in ___lldb_unnamed_symbol598$$MediaToolbox ()
What's going wrong here? Can anyone give me direction on what to fix? Or is FairPlay audio not even expected to work in Catalyst at this point?