App crashes randomly in AVCaptureFigVideoDevice _setActiveFormat:resetVideoZoomFactorAndMinMaxFrameDurations

Hi,

My user is experiencing a random crash when trying to launch the video camera. He is using iPhone 11 pro with iOS 13.7. Please find below the logs, I am using UIImagePickerController for launching the video camera.

Can someone please help me why is going on here

Thread 9 name:
Thread 9 Crashed:
0 libsystempthread.dylib 0x000000019f0afa18 threadchkstkdarwin + 64
1 libdispatch.dylib 0x000000019f058fb0
dispatchmachsendandwaitforreply + 440 (mach.c:815)
2 libdispatch.dylib 0x000000019f059414 dispatchmachsendwithresultandwaitforreply + 56 (mach.c:2006)
3 libxpc.dylib 0x000000019ef99a54 xpcconnectionsendmessagewithreplysync + 240 (connection.c:829)
4 CoreMedia 0x00000001a5e01c0c FigXPCRemoteClientSendSyncMessageCreatingReply + 44 (FigXPCClientServer.c:840)
5 CoreMedia 0x00000001a5e01d7c FigXPCSendStdSetPropertyMessage + 132 (FigXPCClientServer.c:870)
6 Celestial 0x00000001ad44d90c captureSourceRemoteSetProperty + 128 (FigCaptureSourceRemote.m:563)
7 AVFoundation 0x00000001a98bcb70
76-[AVCaptureFigVideoDevice setFigCaptureSourceProperty:withValue:cacheOnly:]blockinvoke + 88 (CMBaseObject.h:389)
8 libdispatch.dylib 0x000000019f0435ac dispatchclientcallout + 20 (object.m:495)
9 libdispatch.dylib 0x000000019f050360
dispatchlanebarriersyncinvokeandcomplete + 60 (queue.c:996)
10 AVFoundation 0x00000001a98bcaf0 -[AVCaptureFigVideoDevice setFigCaptureSourceProperty:withValue:cacheOnly:] + 136 (AVCaptureFigVideoDevice.m:5351)
11 AVFoundation 0x00000001a98b754c -[AVCaptureFigVideoDevice
setPhotoSettingsForSceneMonitoring:] + 588 (AVCaptureFigVideoDevice.m:4021)
12 AVFoundation 0x00000001a9993840 -[AVCapturePhotoOutput updateSceneMonitoringForSourceDevice:] + 604 (AVCapturePhotoOutput.m:2798)
13 AVFoundation 0x00000001a9991388 -[AVCapturePhotoOutput
updateSupportedPropertiesForSourceDevice:] + 472 (AVCapturePhotoOutput.m:2237)
14 AVFoundation 0x00000001a999097c -[AVCapturePhotoOutput handleChangedActiveFormat:forDevice:] + 52 (AVCapturePhotoOutput.m:2111)
15 AVFoundation 0x00000001a98daa3c -[AVCaptureSession informSessionMembersOfChangedActiveFormat:forDevice:] + 1148 (AVCaptureSession.m:2186)
16 AVFoundation 0x00000001a98da3ac -[AVCaptureSession handleVideoInputDevice:activeFormatChanged:] + 276 (AVCaptureSession.m:2116)
17 Foundation 0x000000019f76789c NSKeyValueNotifyObserver + 292 (NSKeyValueObserving.m:417)
18 Foundation 0x000000019f769924 NSKeyValueDidChange + 340 (NSKeyValueObserving.m:532)
19 Foundation 0x000000019f7670c8 NSKeyValueDidChangeWithPerThreadPendingNotifications + 152 (NSKeyValueObserving.m:1189)
20 AVFoundation 0x00000001a98ab21c -[AVCaptureFigVideoDevice setActiveFormat:resetVideoZoomFactorAndMinMaxFrameDurations:] + 1540 (AVCaptureFigVideoDevice.m:1186)
21 AVFoundation 0x00000001a98dd7f8 -[AVCaptureSession
updateDeviceActiveFormatsAndActiveConnections] + 3016 (AVCaptureSession.m:3023)
22 AVFoundation 0x00000001a98dc52c -[AVCaptureSession buildAndRunGraph] + 88 (AVCaptureSession.m:2721)
23 AVFoundation 0x00000001a98d648c -[AVCaptureSession
commitConfiguration] + 96 (AVCaptureSession.m:904)
24 Foundation 0x000000019f76789c NSKeyValueNotifyObserver + 292 (NSKeyValueObserving.m:417)
25 Foundation 0x000000019f769924 NSKeyValueDidChange + 340 (NSKeyValueObserving.m:532)
26 Foundation 0x000000019f7670c8 NSKeyValueDidChangeWithPerThreadPendingNotifications + 152 (NSKeyValueObserving.m:1189)
27 AVFoundation 0x00000001a98b9544 -[AVCaptureFigVideoDevice setVideoHDREnabled:] + 176 (AVCaptureFigVideoDevice.m:4501)
28 AVFoundation 0x00000001a98ddf88 -[AVCaptureSession
updateDeviceActiveFormatsAndActiveConnections] + 4952 (AVCaptureSession.m:3136)
29 AVFoundation 0x00000001a98dc52c -[AVCaptureSession buildAndRunGraph] + 88 (AVCaptureSession.m:2721)
30 AVFoundation 0x00000001a98d648c -[AVCaptureSession
commitConfiguration] + 96 (AVCaptureSession.m:904)
31 Foundation 0x000000019f76789c NSKeyValueNotifyObserver + 292 (NSKeyValueObserving.m:417)
32 Foundation 0x000000019f769924 NSKeyValueDidChange + 340 (NSKeyValueObserving.m:532)
33 Foundation 0x000000019f7670c8 NSKeyValueDidChangeWithPerThreadPendingNotifications + 152 (NSKeyValueObserving.m:1189)
34 AVFoundation 0x00000001a98ab21c -[AVCaptureFigVideoDevice setActiveFormat:resetVideoZoomFactorAndMinMaxFrameDurations:] + 1540 (AVCaptureFigVideoDevice.m:1186)
35 AVFoundation 0x00000001a98dd7f8 -[AVCaptureSession
updateDeviceActiveFormatsAndActiveConnections] + 3016 (AVCaptureSession.m:3023)
36 AVFoundation 0x00000001a98dc52c -[AVCaptureSession buildAndRunGraph] + 88 (AVCaptureSession.m:2721)
37 AVFoundation 0x00000001a98d648c -[AVCaptureSession
commitConfiguration] + 96 (AVCaptureSession.m:904)
38 Foundation 0x000000019f76789c NSKeyValueNotifyObserver + 292 (NSKeyValueObserving.m:417)
39 Foundation 0x000000019f769924 NSKeyValueDidChange + 340 (NSKeyValueObserving.m:532)
40 Foundation 0x000000019f7670c8 NSKeyValueDidChangeWithPerThreadPendingNotifications + 152 (NSKeyValueObserving.m:1189)
41 AVFoundation 0x00000001a98b9544 -[AVCaptureFigVideoDevice setVideoHDREnabled:] + 176 (AVCaptureFigVideoDevice.m:4501)
42 AVFoundation 0x00000001a98ddf88 -[AVCaptureSession
updateDeviceActiveFormatsAndActiveConnections] + 4952 (AVCaptureSession.m:3136)
43 AVFoundation 0x00000001a98dc52c -[AVCaptureSession buildAndRunGraph] + 88 (AVCaptureSession.m:2721)
44 AVFoundation 0x00000001a98d648c -[AVCaptureSession
commitConfiguration] + 96 (AVCaptureSession.m:904)
45 Foundation 0x000000019f76789c NSKeyValueNotifyObserver + 292 (NSKeyValueObserving.m:417)
46 Foundation 0x000000019f769924 NSKeyValueDidChange + 340 (NSKeyValueObserving.m:532)
47 Foundation 0x000000019f7670c8 NSKeyValueDidChangeWithPerThreadPendingNotifications + 152 (NSKeyValueObserving.m:1189)
48 AVFoundation 0x00000001a98ab21c -[AVCaptureFigVideoDevice setActiveFormat:resetVideoZoomFactorAndMinMaxFrameDurations:] + 1540 (AVCaptureFigVideoDevice.m:1186)
49 AVFoundation 0x00000001a98dd7f8 -[AVCaptureSession
updateDeviceActiveFormatsAndActiveConnections] + 3016 (AVCaptureSession.m:3023)

Some more information regarding the issue - The stack goes very deep, with roughly the same classes in AVFoundation and Foundation being called 70 times over. We suspect some sort of stack overflow.
The stack trace does not have our app's classes in it.
Interestingly, we're not using AVFoundation, but this thread goes & crashes in AVFoundation-related code.




Is that an Apple crash report? It seems to be missing the first section. If you can post the full report, I may be able to learn more about this.

Regardless, you have definitely hit an infinite recursion within AVFoundation. Consider this:

Code Block
Exception Subtype: KERN_PROTECTION_FAILURE at 0x000000016fdc7ff8
VM Region Info: 0x16fdc7ff8 is in 0x16fdc4000-0x16fdc8000; bytes after start: 16376 bytes before end: 7
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
Stack 000000016fcb0000-000000016fd38000 [ 544K] rw-/rwx SM=PRV thread 8
GAP OF 0x8c000 BYTES
---> STACK GUARD 000000016fdc4000-000000016fdc8000 [ 16K] ---/rwx SM=NUL ... for thread 9
Stack 000000016fdc8000-000000016fe50000 [ 544K] rw-/rwx SM=COW thread 9


which shows that the crashing address is in the guard page off the bottom of the stack and the 510 frames in the crashing threads backtrace, which is the point that crash reporter gives up.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
App crashes randomly in AVCaptureFigVideoDevice _setActiveFormat:resetVideoZoomFactorAndMinMaxFrameDurations
 
 
Q