SIGN IN SIGN UP

fix: Deep-compare `constraints` instead of `JSON.stringify`-ing them (#4167)

`useCameraController` kept the user's `constraints` stable by putting
`JSON.stringify(constraints)` into the `useMemo` dependency array. That
works for plain constraints like `{ fps: 60 }`, but it silently breaks for
`{ resolutionBias: someOutput }`.

Nitro `HybridObject`s are created via `Object.create(prototype)` and hold
every property on their shared prototype, so the JS object itself has no own
keys. `JSON.stringify(...)` therefore serializes *every* `CameraOutput` to
`{}` (release) or `{"__type":"HybridObject<CameraPhotoOutput>"}` (debug) -
two different outputs of the same type produce the exact same string. Any
change that only re-points a `resolutionBias` at a different output is
invisible to the memo, and the session is never re-configured.

Replace the stringification with an explicit deep comparison that compares
object literals and arrays by value and everything else (i.e. `HybridObject`s)
by identity. That also drops a full JSON serialization from every render.

Also adds two Harness tests: one that re-renders with an inline `constraints`
array and asserts the session is configured exactly once (and re-configured
once more when the constraint values actually change), and one that asserts
re-pointing a `resolutionBias` constraint at a different output of the same
type does re-configure the session.
M
Marc Rousavy committed
8015396b408c370f47bf89cfcf8ee7ad0cef17cd
Parent: 2ae908a
Committed by GitHub <noreply@github.com> on 8/21/2026, 1:24:44 PM