Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Catch InitializationException and rethrow in onError callback #3373

Closed
wants to merge 1 commit into from

Conversation

mrousavy
Copy link
Owner

What

The CameraProvider Future was throwing an InitializationException when less Cameras can be found than anticipated:

- androidx.camera.core.InitializationException: androidx.camera.core.CameraUnavailableException: Device reporting less cameras than anticipated. On real devices: Retrying initialization might resolve temporary camera errors. On emulators: Ensure virtual camera configuration matches supported camera features as reported by PackageManager#hasSystemFeature. Available cameras: 0
-     at androidx.camera.core.CameraX.lambda$initAndRetryRecursively$2$androidx-camera-core-CameraX(CameraX.java:433)
-     at androidx.camera.core.CameraX$$ExternalSyntheticLambda2.run(D8$$SyntheticClass:0)
-     at java.util.concurrent.ThreadPoolExecutor.processTask(ThreadPoolExecutor.java:1187)
-     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
-     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
-     at java.lang.Thread.run(Thread.java:784)

This PR catches this issue when it happens in a configure(...) call, and rethrows it in the onError callback (the React prop to <Camera />).

This makes sure the app doesn't crash and can still be handled by the user.

Changes

Tested on

Related issues

Copy link

vercel bot commented Jan 20, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 20, 2025 9:42am

@rb-adnan
Copy link

rb-adnan commented Jan 23, 2025

@mrousavy please check the pipeline failure. seems issue in accessing val due to try catch scope. need this MR asap!! thanks

@mrousavy
Copy link
Owner Author

Dude stop being impatient this is free software - if you need this "asap" do it yourself.

I'll focus on this when I have free time.

@mrousavy
Copy link
Owner Author

overruled by #3385

@mrousavy mrousavy closed this Jan 30, 2025
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.

🐛 InitializationException - Device reporting less cameras than anticipated
2 participants