Coder Social home page Coder Social logo

Comments (7)

gmk57 avatar gmk57 commented on September 7, 2024

I couldn't press Back quickly enough, but it is easily reproducible programmatically, by calling FragmentManager.popBackStack() immediately after commit(), or from second fragment's onCreate().

from viewbindingpropertydelegate.

RuslanDemyanov avatar RuslanDemyanov commented on September 7, 2024

Also reproduced this error when switching fragments programmatically, is there any way to destroy binding without using a handler?

from viewbindingpropertydelegate.

kirich1409 avatar kirich1409 commented on September 7, 2024

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 clear()

from viewbindingpropertydelegate.

kirich1409 avatar kirich1409 commented on September 7, 2024

Need to check the bug with AndroidX Fragment 1.3.0. @midery , please do this and write about results

from viewbindingpropertydelegate.

midery avatar midery commented on September 7, 2024

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:

  1. Fragment B: onCreateView
  2. Fragment B: BackPressed
  3. Fragment A: onDestroyView
  4. Fragment A: onCreateView <-- valid viewBinding here
  5. Fragment A: onStart
  6. Fragment A: onResume //on destroy is never called

TL;DR: Update the AndroidX Fragment artifact to version 1.3.0+ and this issue will be fixed.

from viewbindingpropertydelegate.

gmk57 avatar gmk57 commented on September 7, 2024

viewBindings would not be cleared

Sorry, but this is exactly the issue. I see no difference between Fragment 1.2.5 & 1.3.0 in this respect.
Here is a sample project to reproduce. After forward-back navigation the text on screen is wrong, because FirstFragment's binding still points to old view during onViewCreated.

from viewbindingpropertydelegate.

kirich1409 avatar kirich1409 commented on September 7, 2024

viewBindings would not be cleared

Sorry, but this is exactly the issue. I see no difference between Fragment 1.2.5 & 1.3.0 in this respect.
Here is a sample project to reproduce. After forward-back navigation the text on screen is wrong, because FirstFragment's binding still points to old view during onViewCreated.

Please open separate issue with your bug

from viewbindingpropertydelegate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.