Skip to content

feat: Add selectedVideoResolution to CameraSessionConfig - #4223

Open
don4325 wants to merge 1 commit into
margelo:mainfrom
don4325:feat/ios-selected-video-resolution
Open

don4325 wants to merge 1 commit into
margelo:mainfrom
don4325:feat/ios-selected-video-resolution

Conversation

@don4325

@don4325 don4325 commented Oct 16, 2026 •

Copy link
Copy Markdown

Problem

There is no way to learn the video dimensions the constraint resolver negotiated before the
session starts. onSessionConfigSelected hands back a CameraSessionConfig with the selected
FPS, stabilization modes, dynamic range, pixel format and so on, but not the resolution. The
only other source is an output's currentResolution, which on iOS reads the input port's
formatDescription, and that is legitimately absent until the session is running. A caller
that wants to size UI or validate a recording plan from the resolved config has nothing to read.

Change

  • Spec: CameraSessionConfig.selectedVideoResolution?: Size (reuses the existing
    common-types/Size). Documented as "may be undefined when the platform cannot report it
    before the session starts".
  • iOS: HybridCameraSessionConfig.selectedVideoResolution returns
    Size(dimensions: negotiatedFormat.format.formatDescription.dimensions); added to toString().
  • Android: HybridCameraSessionConfig.selectedVideoResolution returns null, with a comment:
    CameraX does not expose an authoritative use-case resolution before binding, so callers keep
    reading an output's currentResolution from the configured callback there. Added to
    toString().
  • Bindings regenerated with bun run specs in packages/react-native-vision-camera
    (Nitrogen 0.37.0, the version pinned in the package). The generated diff is limited to the
    eight CameraSessionConfig spec files (shared C++ .hpp/.cpp, iOS Swift/Swift_cxx/C++ .hpp,
    Android Kotlin and JNI .hpp/.cpp). lib/ is build output and is not committed.

Verification

  • bun run typecheck (tsc --noEmit) in the package: passes.
  • biome check on the changed spec: passes.
  • swift format (config/.swift-format) on the hand-edited Swift file: no diff.
  • ktlint --editorconfig=config/.editorconfig on the hand-edited Kotlin file: clean.
  • Regenerating on pristine main first: the only drift is trailing-whitespace-only lines in
    four unrelated generated files (HybridTapToFocusGestureControllerSpec.kt,
    VisionCamera-Swift-Cxx-Bridge.{cpp,hpp}, PhotoFile.swift); that drift is pre-existing
    and is not included here.
  • The eleven resulting files are byte-identical to the ones we have carried as a pnpm patch on
    react-native-vision-camera@5.2.3 in a shipping app.
  • No Xcode or Gradle build was run while preparing this branch.

Limits and open questions

  • iOS reports the active format's dimensions. That is the sensor stream the resolver picked, not
    a per-output size after any stabilization crop or output scaling. The existing
    currentResolution reads the same source, so this is not a regression, but a different name
    (selectedFormatResolution, nativeResolution) might describe it better. Open to renaming.
  • Android returning undefined is deliberate but asymmetric; if a CameraX path to the resolved
    use-case size before bind exists that I have missed, I will wire it.
  • Not verified against a written asset's track dimensions across stabilization modes,
    photo+video sessions, and camera flips.

🤖 Generated with Claude Code

Expose the video dimensions the constraint resolver negotiated so a
caller can read them from `onSessionConfigSelected` before the session
starts. The only other source is an output's `currentResolution`, which
depends on an input-port `formatDescription` that is legitimately
absent until the session is running.

iOS reads the dimensions from the negotiated `AVCaptureDevice.Format`.
Android returns `undefined`: CameraX does not expose an authoritative
use-case resolution before binding, so callers keep reading an output's
`currentResolution` from the configured callback there.

Bindings regenerated with `bun run specs` (Nitrogen 0.37.0); the
generated diff is limited to the `CameraSessionConfig` spec files.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 16, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@ismaelsousa

Copy link
Copy Markdown
Contributor

Hi @don4325, my PR can solve this problem, I expose the resolution ready to be use!

@don4325

don4325 commented Nov 17, 2026

Copy link
Copy Markdown
Author

Device follow-up for the "not verified against a written asset" limit, on a development build running this change as a patch on 5.2.3, with a video-only session targeting 1080x1440:

Device Camera videoStabilizationMode constraint selectedVideoResolution (before start) Recorded file
iPhone 14 Pro, iOS 26.6.2 back, front 'standard' 1920x1440 1920x1440
iPhone 14 Pro, iOS 26.6.2 back, front none 1440x1080 1440x1080
iPhone 13 mini, iOS 27.0.1 back 'standard' 1920x1440 not recorded

The value read before session start matched the recorded file wherever a file was recorded. Photo plus video sessions were not covered.

main has since moved to Nitrogen 0.37.2 (#4243). Merging this branch into current main gives the same files as regenerating there with bun run specs, so no rebase is needed for the bindings.

On #4224: that PR adds onPreviewResolution for the Preview stream's upright size. This one reports the negotiated capture format from the session config, before the session starts, so the two do not overlap.

This branch has not been deployed

No deployments
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