Failing harness repro: setOutputSettings({ codec }) crashes (uncatchable) when a targetBitRate is set#4037
Open
radko93 wants to merge 2 commits into
Open
Conversation
…n a targetBitRate is set
Calling `videoOutput.setOutputSettings({ codec })` after `targetBitRate` was
configured aborts the process with an uncatchable Objective-C
NSInvalidArgumentException (SIGTRAP).
`HybridCameraVideoOutput.setOutputSettings` reads the fully-expanded
`output.outputSettings(for: connection)` dict and writes it back. When
`targetBitRate` is set, that dict already contains AVVideoCompressionPropertiesKey
plus width/height/color keys. `AVCaptureMovieFileOutput.setOutputSettings:forConnection:`
rejects the non-codec/compression keys, raising an ObjC exception Swift cannot
catch, so the whole app aborts. No JS try/catch can prevent it.
Adds a harness test that configures a targetBitRate, then calls
setOutputSettings({ codec: 'h264' }) and expects it to resolve without crashing.
Expected to crash the harness app on current main.
|
@radko93 is attempting to deploy a commit to the Margelo Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a reproduction: it adds a failing harness test only, so the AWS Device Farm run shows the crash. A proposed fix is in the collapsible section — but note it is reasoned, not yet verified (see below).
What
On iOS,
videoOutput.setOutputSettings({ codec })called after atargetBitRatewas configured aborts the whole process with an uncatchable Objective-CNSInvalidArgumentException(SIGTRAP). No JStry/catchcan prevent it.Why
HybridCameraVideoOutput.setOutputSettings(ios/.../HybridCameraVideoOutput.swift) does a read-modify-write of the fully-expanded settings dict:When
targetBitRateis set,setBitRate(...)has already populated the connection, sooutputSettings(for:)returns a dict containingAVVideoCompressionPropertiesKeyplus width/height/color keys.AVCaptureMovieFileOutput.setOutputSettings:forConnection:rejects the non-codec keys with an ObjC exception that Swift can't catch → abort.(It doesn't bite without
targetBitRatebecause the expanded dict is then minimal enough.)Test
Adds an
it(...)toapps/simple-camera/__tests__/visioncamera.video.harness.ts: configure atargetBitRate, then callsetOutputSettings({ codec: 'h264' })and expect it to resolve. On current main the harness app crashes rather than the assertion failing cleanly — that crash is the reproduction. I haven't run the harness locally (no signed device build), so the Device Farm run is the verification.Observed on iPhone18,1 / iOS 26.5.1,
com.margelo.camera.videoqueue.Proposed fix (reasoned, NOT verified — we worked around it by not calling setOutputSettings)
Don't round-trip the expanded
outputSettings(for:). Write only the keysAVCaptureMovieFileOutputaccepts — the codec, and the existing compression properties if present (whichsetBitRatealready writes successfully):This mirrors what
setBitRatealready does (it builds a minimal[AVVideoCodecKey, AVVideoCompressionPropertiesKey]dict and ships without crashing). I have not verified this exact patch on a device — our production workaround was simply to stop callingsetOutputSettings— so treat it as a starting point for discussion. The maintainer may know the precise set of keysAVCaptureMovieFileOutputpermits.