-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Unexpected behavior on quick forward-back navigation in Fragments #35
Comments
I couldn't press Back quickly enough, but it is easily reproducible programmatically, by calling |
Also reproduced this error when switching fragments programmatically, is there any way to destroy binding without using a handler? |
Yes, you can keep reference to the delegate instance and call |
…tent action issue fix reference: androidbroadcast/ViewBindingPropertyDelegate#35
…tent action (#9) issue fix reference: androidbroadcast/ViewBindingPropertyDelegate#35
Need to check the bug with AndroidX Fragment 1.3.0. @midery , please do this and write about results |
Checked this issue in AndroidX Fragment 1.3.0. Surprisingly, it isn't reproducing anymore. It happens because the Fragment.onDestroyView call is now "postponed" and cancellable in new FragmentManager implementation. Fragment.destroyFragmentView now is bound to a FragmentTransition, which is used to show fragment's removal. If the transition is not yet completed - Fragment's view won't be destroyed. Thus, if we will try to press back after the new fragment is added and current fragment is being replaced, it will happen before transition's completion, and the viewBindings would not be cleared. So, the logs now are showing something like this:
TL;DR: Update the AndroidX Fragment artifact to version 1.3.0+ and this issue will be fixed. |
Sorry, but this is exactly the issue. I see no difference between Fragment 1.2.5 & 1.3.0 in this respect. |
Please open separate issue with your bug |
Hello! Thanks for the great library and simple approach for viewBinding initialization.
I've discovered really annoying bug: if we will use fragment view bindings, try to replace current fragment with new fragment, and then quickly press back - our current fragment will not show all initialization data, which we will provide in it in
onCreateView
call.This happens because we're calling
handler.post { viewBinding = null }
inClearOnDestroyLifecycleObserver.onDestroy
. method. Thus, if we happen to open next screen, and exit from it really fast, the viewBinding, that is accessed in onCreateView method will be this undestroyed binding.Method call list will be such:
The text was updated successfully, but these errors were encountered: