Skip to content

fix(ios): guard unsupportedCaptureOutputClasses against SimCam crash on simulator#3826

Closed
therealpurplemana wants to merge 1 commit intomrousavy:mainfrom
therealpurplemana:fix/simcam-simulator-crash
Closed

fix(ios): guard unsupportedCaptureOutputClasses against SimCam crash on simulator#3826
therealpurplemana wants to merge 1 commit intomrousavy:mainfrom
therealpurplemana:fix/simcam-simulator-crash

Conversation

@therealpurplemana
Copy link
Copy Markdown

@therealpurplemana therealpurplemana commented Apr 30, 2026

Problem

When using SimCam (Software Mansion's simulator camera injection tool) with VisionCamera on the iOS Simulator, the app crashes immediately on launch with EXC_BAD_ACCESS (SIGSEGV) on the com.margelo.camera.session queue.

Crash stack:

Thread crashed: com.margelo.camera.session
0  AVFCapture   -[AVCaptureDeviceFormat isStreamingDisparitySupported]  <-- SIGSEGV (null ptr @ 0x59)
1  AVFCapture   -[AVCaptureDeviceFormat unsupportedCaptureOutputClasses]
2  VisionCamera  AVCaptureDeviceFormat.supportsOutput(_:)  (AVCaptureDevice.Format+supportsOutput.swift:13)
3  VisionCamera  ConstraintResolver.filterFormats(_:outputs:isMultiCam:)  (ConstraintResolver.swift:176)
4  VisionCamera  HybridCameraSession.configureConnection(_:isMultiCam:)  (HybridCameraSession.swift:120)

Root cause: SimCam injects a DummyCaptureDeviceFormat into the simulator. When ConstraintResolver.filterFormats calls format.supportsOutput() for each camera format at session startup, it reads unsupportedCaptureOutputClasses, which internally calls isStreamingDisparitySupported. SimCam's dummy format has a null ivar at offset 0x59 for this property, causing the crash.

Fix

Guard unsupportedCaptureOutputClasses behind #if targetEnvironment(simulator). On the simulator the camera is fake regardless, so assuming all outputs are supported is correct and safe.

Testing

Tested on iOS Simulator (iOS 26.3) with SimCam running — app no longer crashes on launch and the simulated camera feed displays correctly. Tested iPhone Air device confirming camera working correctly. Tested on Android Pixel 8 confirming camera working correctly.

…ent(simulator)

SimCam injects a DummyCaptureDeviceFormat into the iOS Simulator to fake
camera input. When VisionCamera's ConstraintResolver calls supportsOutput()
on startup, it reads unsupportedCaptureOutputClasses, which internally calls
isStreamingDisparitySupported. That method crashes with SIGSEGV (null pointer
dereference at offset 0x59) because SimCam's dummy format doesn't implement it.

On simulator, skip the output class check entirely — the camera is fake anyway
and all outputs can be assumed supported.

Crash stack:
  AVCaptureDeviceFormat.isStreamingDisparitySupported  <-- SIGSEGV
  AVCaptureDeviceFormat.unsupportedCaptureOutputClasses
  AVCaptureDeviceFormat.supportsOutput (this file)
  ConstraintResolver.filterFormats
  HybridCameraSession.configureConnection
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 2026

@therealpurplemana is attempting to deploy a commit to the Margelo Team on Vercel.

A member of the Team first needs to authorize it.

@mrousavy
Copy link
Copy Markdown
Owner

It sounds like that might be a bug in SimCam though, if it crashes there?

@therealpurplemana
Copy link
Copy Markdown
Author

therealpurplemana commented Apr 30, 2026 via email

@mrousavy
Copy link
Copy Markdown
Owner

mrousavy commented May 4, 2026

Apparently this has been fixed upstream in StreamCam today, so we shouldn't need this workaround anymore :)

Thanks anyways!

@mrousavy mrousavy closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants