Improve camera device error reporting#3410
Conversation
📋 PR Review Helper📱 Mobile App Build⏳ Waiting for build... 🕶️ ASG Client Build✅ Ready to test! (commit 🔀 Test Locallygh pr checkout 3410 |
PR Agent Orchestrator State{
"cycle": 1,
"fixRound": 0,
"totalReviewerRuns": 1,
"consecutiveNoNewReviews": 1,
"openFindings": [],
"resolvedFindings": [],
"nitFindings": [],
"phase": "discovery",
"status": "in_progress",
"stagnationFixRounds": 0,
"fingerprintReopenCounts": {},
"mutedFingerprints": [],
"lastPair": [],
"lastOpenCount": 0
} |
🤖 PR Agent Review — cycle 1✅ No blocking findings · 0 blocking · 0 nits No model reviews ran this cycle. Updated automatically by the PR Agent Orchestrator each review cycle. Nits do not block merge. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b44b97368
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| void onPhotoCaptured(String filePath, @Nullable JSONObject captureMetadata); | ||
|
|
||
| void onPhotoError(String errorMessage); | ||
| void onPhotoError(CameraOperationError error); |
There was a problem hiding this comment.
Keep legacy photo error callbacks source-compatible
For callers that still implement the previously documented string callback, this new typed overload is abstract, so an existing anonymous class passed to takePictureWithCallback/enqueuePhotoRequest with only onPhotoCaptured(...) and onPhotoError(String) now fails to compile despite the added default string overload. If the string callback is meant to remain backward-compatible, make the typed overload default/delegate to the string path or otherwise keep the old abstract contract so existing camera integrations are not forced to change.
Useful? React with 👍 / 👎.
Summary
Translate Android Camera2 device callback errors into stable, actionable error codes and messages before they leave the glasses.
This change:
CameraOperationErrorshared by photo capture and camera warm-upCameraDevice.StateCallbackerror valuesPhotoSessionand every photo delivery pathphoto_status,photo_response, andcamera_statuseventsCAMERA_CAPTURE_FAILEDorcamera_warm_up_failedWhy
A React Native
requestPhoto()call was rejected with:The integer is an Android Camera2 implementation detail. Error 4 means
ERROR_CAMERA_DEVICE: the opened camera device encountered a fatal device-level error and must be closed and reopened. Neither an SDK consumer nor an example-app user should need to look up that integer to understand whether retrying is appropriate.In the observed failure, a camera FOV setting restarted the HAL, warm-up was rejected during the restart cooldown, and the subsequent photo reached camera open just after the fixed cooldown expired. Camera2 then reported error 4 before the request reached configuring or capturing. The new response for that failure is:
The ASG diagnostic log still records:
Error mapping
ERROR_CAMERA_IN_USECAMERA_IN_USEERROR_MAX_CAMERAS_IN_USEMAX_CAMERAS_IN_USEERROR_CAMERA_DISABLEDCAMERA_DISABLEDERROR_CAMERA_DEVICECAMERA_DEVICE_ERRORERROR_CAMERA_SERVICECAMERA_SERVICE_ERRORUnknown callback integers use
CAMERA_DEVICE_ERRORand include the raw integer in the message.Propagation
The typed failure is preserved through:
Legacy string-only internal failures are wrapped in the existing generic codes, so this does not require a compatibility shim in the phone SDK.
Validation
PhotoSessionunchanged.camera_warm_up_failedfallback.:app:testDebugUnitTestsuite successfully.Note
Medium Risk
Changes how error codes surface to phone/SDK clients across all photo and warm-up paths; behavior is backward-compatible for string callbacks but new codes may affect apps that assumed only CAMERA_CAPTURE_FAILED.
Overview
Introduces
CameraOperationError(stablecode+ human-readablemessage) and threads it from Camera2 through photo capture and warm-up instead of opaque strings likeCamera device error: 4.Camera open failures now map all five
CameraDevice.StateCallbackerror constants to named codes (CAMERA_IN_USE,CAMERA_DEVICE_ERROR, etc.); logs still include the raw Android integer.PhotoSessionandCameraNeoServicepass typed errors end-to-end; warm-up busy/reject paths usecamera_busyvia the same type.MediaCaptureServiceforwardserror.code()anderror.message()intophoto_status,photo_response, andcamera_statuson every photo delivery path (offline, local-save, webhook, BLE). Legacy string-only failures are wrapped asCAMERA_CAPTURE_FAILEDorcamera_warm_up_failed; callback interfaces gain optionalonPhotoError(CameraOperationError)/onCameraError(CameraOperationError)defaults that delegate to the string overloads.Unit tests cover the mapping table, callback delegation, and lifecycle preservation of structured errors during warm-up vs capture.
Reviewed by Cursor Bugbot for commit a15d584. Bugbot is set up for automated code reviews on this repo. Configure here.