fix: Catch routine CameraX cancellation rejections in internal updater hooks#4093
Open
ssahil97 wants to merge 1 commit into
Open
fix: Catch routine CameraX cancellation rejections in internal updater hooks#4093ssahil97 wants to merge 1 commit into
ssahil97 wants to merge 1 commit into
Conversation
|
@ssahil97 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.
What
The internal prop-sync hooks fire
CameraControllercalls without awaiting or catching them:useZoomUpdater→controller.setZoom(..)useTorchModeUpdater→controller.setTorchMode(..)useExposureUpdater→controller.setExposureBias(..)useCameraControllerConfiguration→ uncaughtload()aroundcontroller.configure(..)On Android, CameraX rejects a pending control operation with
OperationCanceledExceptionwhen a newer value supersedes an in-flight one ("Cancelled due to another zoom value being set") or when the camera is not currently active ("Camera is not active"). Because the hooks fire-and-forget, every such routine cancellation surfaces as an unhandled promise rejection in the app — which error reporters (Sentry etc.) capture as an error flood.This PR adds a small shared helper,
ignoreCameraCancellation(promise), and routes all four call sites through it. Routine cancellations are swallowed; any other error is re-thrown inside the catch, so non-cancellation failures keep exactly their previous unhandled-rejection visibility — nothing new gets silently hidden.Why #3901 doesn't fully cover this
#3909 was closed pointing to #3901 (awaitable
start()/stop(), merged pre-5.1.0). That fix helps the session lifecycle, but the JS hooks still fire the controller calls unawaited, and "Camera is not active" / supersede cancellations still legitimately occur (e.g. atorchprop write while the session isn't running yet, or rapid pinch-zoom superseding in-flight zoom values).Production evidence on 5.1.0 (which includes #3901): in our app (React Native 0.83, new architecture, Android 15 devices incl. Samsung S23 and Lenovo TB352XU) we see continuous Sentry unhandled-rejection events from both
ZoomControl.applyZoomState("Cancelled due to another zoom value being set" / "Camera is not active") andTorchControl.setTorchAsync("Camera is not active" — we only ever settorch="off"). Thelib/hooks/internalcode in 5.1.1 is unchanged, so the leak persists on latest.Closes #3907 (torch variant of #3909).
Notes
VisionCameraWorkletsProxy.bindUIUpdatesToController) is untouched — this PR only covers the JS effect call sites.pnpm patchin production and it eliminates the rejection flood without masking real errors.🤖 Generated with Claude Code
https://claude.ai/code/session_01846JqK8mH4c3BrQyksjwbz