react-native-vision-camera
react-native-vision-camera copied to clipboard
fix: properly close Camera session
What
This PR properly closes the Camera session when the Camera view is unmounted
Changes
I rely on the local boolean isMounted
and when false
then close the Camera session.
I tried the same with View inherited isAttachedToWindow
but somehow it is not up to date when update
is called.
Tested on
Pixel 5, API 33: navigating between screens (one using front camera, the other using back camera)
Related issues
Fixes: #1958 Maybe: #2149 Maybe: #2152
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 | Nov 14, 2023 7:31am |
I have few questions:
override fun onAttachedToWindow() {
if (!isMounted) {
isMounted = true
invokeOnViewReady()
}
update()
super.onAttachedToWindow()
}
On this code, it seems you use the isMounted
flag to ensure calling invokeOnViewReady
only once.
But that would mean that onAttachedToWindow
can be called more than once then, right?
In that case, should we re-configre (with the update
call) the Camera session?