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
Lifecycle onPause/onStop/onDestory are never called #42
Comments
I was investigating this, and I think it may be because the lifecycle is not bound to the screen, but the activity. Even when I am using AndroidScreen screens, which I thought replaced the LocalLifecycleOwner composition local. |
I did some more investigating with it, and I tested providing the screen lifecycles to the content and noticed it was not working either. I found that the screens lifecycle never gets passed INITIALIZED. Here is the function I used to test it @Composable
fun ScreenWithLifecycle(screen: Screen) {
if (screen is AndroidScreen) {
val lifecycleOwner by derivedStateOf { (screen.getLifecycleOwner() as AndroidScreenLifecycleOwner) }
val lifecycleState by derivedStateOf { lifecycleOwner.lifecycle.currentState }
LaunchedEffect(lifecycleState) {
logcat("Lifecycle") { lifecycleState.name }
}
CompositionLocalProvider(
LocalLifecycleOwner provides lifecycleOwner
) {
screen.Content()
}
} else {
screen.Content()
}
} |
1.0.0-rc02 now provides a I think it isn't enough yet. Seems I also need to provide a I'm still looking for a way to provide that, but in the meantime, can you confirm if the last modification solves your issue? |
Hmm, I don't think its working. The lifercycle observer is still isnt saving data into the bundle. |
I've encountered this issue. And due to that I can't handle ExoPlayer release() correctly in screen, when app get's paused. |
I have a PR to fix it #87. The fix is also included in my fork of Voyager: https://github.com/Syer10/voyager |
While testing my app with Voyager I noticed some of my AndroidView states were never being saved. Investigating that lead me to my LifecycleObserver's never filling the bundle contained in my rememberSavable variable. I then logged the states that the lifecycle observer goes through and noticed that only onCreate/OnStart/OnResume are ever called, and never the last 3.
Here are the test composables I used
The text was updated successfully, but these errors were encountered: