App randomly be terminated due to Capture Application Requirements Unmet

Hi. I encounter some random crashes of my camera app. After some investigations, I found that it's terminated by the system and the crash log did be generated but the information is not quite useful, and here is the log found via the Console app.

Termination & Crash log

"Camera not actively used; AVCaptureEventInteraction not installed":

Received termination request from [osservice<com.apple.SpringBoard>:10931] on <RBSProcessPredicate <RBSProcessInstancePredicate| [app<com.juniperphoton.PhotonCam]>> with context <RBSTerminateContext| explanation:Capture Application Requirements Unmet: "Camera not actively used; AVCaptureEventInteraction not installed" reportType:CrashLog maxTerminationResistance:Interactive>

The crash log exported from the device will have some common information like:

It's a EXC_CRASH (SIGKILL) type with no termination reason.

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: RUNNINGBOARD 0 

It's triggered by the main thread, but it seems to be waiting for an event to process.

Triggered by Thread:  0

Thread 0 name:   Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib        	       0x1ee165788 mach_msg2_trap + 8
1   libsystem_kernel.dylib        	       0x1ee168e98 mach_msg2_internal + 80
2   libsystem_kernel.dylib        	       0x1ee168db0 mach_msg_overwrite + 424
3   libsystem_kernel.dylib        	       0x1ee168bfc mach_msg + 24
4   CoreFoundation                	       0x19cbe47f4 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                	       0x19cbe3ea0 __CFRunLoopRun + 1212
6   CoreFoundation                	       0x19cc36274 CFRunLoopRunSpecific + 588
7   GraphicsServices              	       0x1e9d6d4c0 GSEventRunModal + 164
8   UIKitCore                     	       0x19f783480 -[UIApplication _run] + 816
9   UIKitCore                     	       0x19f3a9410 UIApplicationMain + 340
10  UIKitCore                     	       0x19fae4bb0 0x19f394000 + 7670704
11  PhotonCam                     	       0x1002e7e3c 0x1002cc000 + 114236
12  dyld                          	       0x1c2d5ade8 start + 2724

Address size fault on the main thread

Thread 0 crashed with ARM Thread State (64-bit):
    ...
   far: 0x0000000000000000  esr: 0x56000080  Address size fault

I have once tried to reproduce this issue when the app is attached with debugger, and it says:

Terminated due to signal 9

When the crash or termination happened, the app:

  1. No AVCaptureSession is running.
  2. The app is in the foreground and users are interacting with some functions like viewing photos or editing photos in the app. When users exit the camera view, like entering the gallery or settings, the camera session will be stopped.
  3. Both TestFlight and Debug build will have the same issue.
  4. No 3rd party crash reporter is installed(I deliberately disable it in Debug build and TestFlight build)
  5. It has adopted the LockedCameraCapture, but current it's running on the main app target(if not, my app will have a button of unlock, so I can confirm about this).

Also, when it comes to the memory consumption, there is no JetsamEvent around the crash time.

Device and app information

Additionally, some information about the tech stack and the current state of my device and my app:

  1. iPhone 16 Pro with iOS 18.2 Beta 3.
  2. The app is a camera based app(it's PhotonCam and you can find it on the App Store), its main functionality is the camera feature using AVFoundation + Core Image + Metal to deliver camera functionality.
  3. It has adopted the Camera Control, AVCaptureEventInteraction and LockedCameraCapture features.
  4. If I remember it right, it occurs in iOS 18.1 Release build, but currently I have no such device to confirm. But in iOS 17.x the issue has never happened.

Regarding to this termination, on top of my head is the "watchdog" mechanism that will terminate the process that is running on the LockedCameraCapture feature. However I can make sure that currently the app is running as the main target on the home screen.

Has anybody encountered this kind of issue and has found some solutions? Thanks in advance.

Update: Since the termination is due to "Camera not actively used; AVCaptureEventInteraction not installed", I have tried this way to see if the issue can be solved:

  • Using onCameraCaptureEvent API from iOS 18 in my SwiftUI view.

And after adopting this, it seems that I haven't encounter this issue any more. But I do have a few concerns:

  • Previously I use AVCaptureEventInteraction, which is available since iOS 17.2 and add it to the keyWindow?.rootViewController?.view. Does onCameraCaptureEvent API using the same approach behind the scene?
  • Still, the app is running as the main target (Not the CaptureExtension), why does the system decide to monitor whether the camera is active and AVCaptureEventInteraction is installed or not?
App randomly be terminated due to Capture Application Requirements Unmet
 
 
Q