Skip to content

fix(macos): pair compatible format/range in set_all - #249

Open
ikuo wants to merge 1 commit into
l1npengtul:0.10from
ikuo:fix/usb-camera-set_all-0.10
Open

ikuo wants to merge 1 commit into
l1npengtul:0.10from
ikuo:fix/usb-camera-set_all-0.10

Conversation

@ikuo

@ikuo ikuo commented Aug 14, 2026 •

Copy link
Copy Markdown

Previously, when a camera advertises the requested resolution under multiple formats (e.g. a UVC camera exposing 720p at both 30fps and 5fps), the outer loop overwrote for each
resolution-matching format while was left pointing at an earlier format's frame rate. The resulting activeFormat + activeVideoMinFrameDuration mismatch made AVFoundation throw NSInvalidArgumentException, which unwinds through nokhwa's non-unwinding objc exception bridge and hard-aborts the process.

Break out of the loop as soon as a format provides a frame-rate range compatible with the requested fps, so selected_format and selected_range always come from the same AVCaptureDeviceFormat.


(appended)

I just realized this duplicates #248, which fixes the same root cause (#247) and is already open. Sorry for the overlap.

Mine is intentionally minimal (a one-line break once a compatible format/range pair is found), so feel free to close this PR if #248 is preferable. No hard feelings either way.

Previously, when a camera advertises the requested resolution under
multiple formats (e.g. a UVC camera exposing 720p at both 30fps and
5fps), the outer loop overwrote  for each
resolution-matching format while  was left pointing at
an earlier format's frame rate. The resulting activeFormat +
activeVideoMinFrameDuration mismatch made AVFoundation throw
NSInvalidArgumentException, which unwinds through nokhwa's non-unwinding
objc exception bridge and hard-aborts the process.

Break out of the loop as soon as a format provides a frame-rate range
compatible with the requested fps, so selected_format and
selected_range always come from the same AVCaptureDeviceFormat.
@ikuo
ikuo force-pushed the fix/usb-camera-set_all-0.10 branch from 3a6bd59 to 93f7707 Compare August 14, 2026 14:07
@ikuo
ikuo marked this pull request as ready for review August 14, 2026 14:34
@akx

akx commented Sep 4, 2026

Copy link
Copy Markdown

Also addressed in my #246, which also fixes other bugs for macOS support on 0.10.

There's also my looser-core-video-sys branch that may be of interest if you're getting duplicate core-video-sys deps...

nokhwa = { git = "https://github.com/akx/nokhwa", branch = "looser-core-video-sys" }

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