-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
✨ Add possibility to cleanup resources when camera is being unmounted in frame processor plugin #3152
Comments
Guten Tag, Hans here! 🍻 Ze request for cleaning up resources when mounting ze camera is a valid enhancement! It seems you’ve identified a potential issue with listeners draining battery after unmounting. Consider adding a cleanup method in your frame processor plugin to unregister listeners, as you mentioned in your alternatives. If this needs further clarification or goes deeper than expected, feel free to open a discussion on our discussions page. If you want to support ze project and get quicker responses from mrousavy, consider sponsoring mrousavy. Let’s see how ze community responds!
|
Hm, it's hard to add such lifecycle listeners because the Camera has no connection or knowledge of any of it's plugins. You can add that code in the |
@mrousavy I think it's okey to manually cleanup resources from react's The problem occurs when users leaves application in background - then it would be nice to cleanup all listeners in order to prevent battery drain. So, if you clean listeners in Maybe it is possible to add some kind of lifecycle indicator in |
Good idea, yes we can add something like |
Also, Nitro Modules will have proper memory management and can be eagerly released - but that is still not public |
What feature or enhancement are you suggesting?
Currently, if frame processor plugin registers some listeners in it's constructor (for example,
OrientationEventListener
or any kind of sensors), there is no way to unregister those listeners when camera component unmounts.The only way to unregister listeners is using
onHostPause
andonHostDestroy
fromLifecycleEventListener
, but in that case listeners will drain battery even if user closed camera activity.What Platforms whould this feature/enhancement affect?
iOS, Android
Alternatives/Workarounds
It is possible to register native module that will be able to cleanup resources, and call the native method from JS in
useEffect
when camera is being unmounted.Additional information
The text was updated successfully, but these errors were encountered: