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: Fix blackscreen issues and lifecycle when closing Camera #2339

Merged
merged 34 commits into from
Jan 8, 2024

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Jan 2, 2024

What

Fixes various blackscreen and out-of-sync issues on Android by deterministically closing and cleaning up the session.

Following changes:

  • fix: Fix a scenario where the concurrent configure { ... } mechanism could drop important updates
  • fix: Fix Android lifecycle by allowing Android to close the CameraDevice when isActive=false
  • fix: Fix Android blackscreens by refactoring CameraSession setup
  • fix: Fix "photo/video is not enabled" errors
  • perf: Don't re-create anything if session is closing down
  • feat: Support 60 FPS on Samsung devices (if available)

Changes

Tested on

Related issues

Copy link

vercel bot commented Jan 2, 2024

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 5, 2024 3:01pm

@mrousavy mrousavy merged commit 0d21bc3 into main Jan 8, 2024
12 checks passed
@mrousavy mrousavy deleted the fix/blackscreen branch January 8, 2024 10:41
@vijaykhandal1290

This comment was marked as off-topic.

@xseignard
Copy link
Contributor

xseignard commented Jan 11, 2024

Hello
I just updated our apps to 3.7.0 and at the first try I have the famous black screen of the not unmounted camera on android 🫤

I'd love to see our sponsoring dedicated to fix lifecycle issues and stability on Android
Capture d’écran 2024-01-11 à 10 55 15

@mrousavy
Copy link
Owner Author

Hey @xseignard - that's weird, I cannot reproduce this bug at all. Is there an open issue for that which uses 3.7.0? Need the adb logcat logs and a reproduction example please.

& thanks for your sponsorship, much appreciated!

@xseignard
Copy link
Contributor

Hey @mrousavy, couldn't recreate in an isolated example
But I reproduced this one #2378

You said this PR fixed #2240, but it seems it does not. May I ask how you tested it fixes the problem?

@mrousavy
Copy link
Owner Author

Hey - I tested in the Example app by navigating from and to the code scanner screen. That worked

@xseignard
Copy link
Contributor

xseignard commented Jan 11, 2024

Well, looking at all the newly raised issues with 3.7.0 on Android, the example app is definitely not a good proofing 🤷

isaaccolson pushed a commit to isaaccolson/deliveries-mobile that referenced this pull request Oct 30, 2024
…vy#2339)

* fix: Fix Blackscreen by deterministically destroying session if `isActive=false`

* Re-open Camera if session died

* Simplify Camera

* Disconnect is optional, block when resetting state

* fix: Log in `configure { ... }`

* fix: Make concurrent configure safe

* fix: Don't resize preview

* fix: Use current `CameraConfiguration`

* Don't start if no outputs are available

* Only mount with preview outputs

* Update CameraSession.kt

* Update PreviewView.kt

* Better logging

* Update CameraSession.kt

* Extract

* fix: Rebuild entire session if `isActive` changed

* isActive safe

* Start session at 1

* Create ActiveCameraDevice.kt

* interrupts

* chore: Freeze `frame` in `useFrameProcessor`

* Revert "chore: Freeze `frame` in `useFrameProcessor`"

This reverts commit dff93d5.

* chore: Better logging

* fix: Move HDR to `video`/`photo` config

* fix: Fix hdr usage

* fix: Ignore any updates after destroying Camera

* fix: Fix video HDR

* chore: Format code

* fix: Check Camera permission

* Remove unneeded error

* Update CameraSession.kt

* Update CameraPage.tsx

* Delete OutputConfiguration.toDebugString.kt

* Update CameraSession.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment