Status Update
Comments
il...@google.com <il...@google.com> #2
Jeremy, is this still an issue? I think the problem was that you had two transitions targeting the same View for the same action (e.g. two Slide() transitions).
ja...@google.com <ja...@google.com> #3
I have a similar issue with plain AnimatorSet:
set.start()
set.pause()
set.setCurrentPlayTime(100)
set.setCurrentPlayTime(0)
set.setCurrentPlayTime(100)
set.resume()
doesn't play animation in resume().
il...@google.com <il...@google.com> #4
Should clarify that if I filter out setCurrentPlayTime(0)
(or replace it with setCurrentPlayTime(1)
) it works well.
Also even with setCurrentPlayTime(0)
, onAnimationEnd
is notified with correct delay (as if the animation has played).
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #5
@
I think that is intended for Animator. If you set the currentPlayTime
to 0 or the total duration the animator completes. We do some
jb...@google.com <jb...@google.com> #6
Did some investigation on the Fragment side and it seems like the merged transition is targeting correctly.
Exiting Transition: Slide@aa9288e: tgts(android.widget.LinearLayout{f9add3d})
>>>>> ExitingViews <<<<<
View: android.widget.LinearLayout{f9add3d}
Entering Transition: Slide@35b8af: tgts(android.widget.LinearLayout{b7f24bc})
>>>>> EnteringViews <<<<<
View: android.widget.LinearLayout{b7f24bc}
Final merged transition: TransitionSet@7bc1c45:
TransitionSet@e133f9a:
Slide@aa9288e: tgts(android.widget.LinearLayout{f9add3d})
Slide@35b8af: tgts(android.widget.LinearLayout{b7f24bc})
merged transition passed to controlDelayedTransition: TransitionSet@7bc1c45:
TransitionSet@e133f9a:
Slide@aa9288e: tgts(android.widget.LinearLayout{f9add3d})
Slide@35b8af: tgts(android.widget.LinearLayout{b7f24bc})
Still digging.
pr...@google.com <pr...@google.com> #7
Branch: androidx-main
commit 567b7459329d1ec8d27a8c6fe1c4a86442065d7d
Author: Jeremy Woods <jbwoods@google.com>
Date: Tue Sep 26 20:06:54 2023
Add additional logging for transitions
Adding more debug logging in transitions to track the entering and
exiting transitions as well as the final merged transition and its
targets.
Test: added logging
Bug: 300157785
Change-Id: I0d9ad72b865422493c6c895ddb6115abf85eed16
M fragment/fragment/src/main/java/androidx/fragment/app/DefaultSpecialEffectsController.kt
Description
Component used: Fragment
The new "predictive back" feature has surfaced some interesting issues when dealing with the Fragment backstack. In general, there seems to be a mismatch in expectations as to whether a "destroyed" instance of a Fragment will be re-created or not.
On one hand, when the FragmentManager's predictive back detects that the user canceled the gesture, it will take the Fragment instance that was previously destroyed and add it back to the top of the stack, driving the create/start/resume lifecycle again. It does this by by re-committing the FragmentTransaction that added it .
On the other hand, utilities like the lifecycle-bound coroutine scope do not handle the state re-entering "creation" after its destruction. The scope is created once here and when the destroyed state is reached the supervisor job is canceled and the lifecycle observer is removed.
These two behaviors are incompatible, if I'm following this code correctly.
Technically, the destruction of a Fragment does not prohibit its reuse, and so the FragmentManager behavior is not wrong from what I can tell. However, in practice I can imagine that reusing Fragments this way will inherently lead to bugs that will be difficult to diagnose whenever a lifecycle-dependent behavior assumes that destruction is final. In essence, this introduces a lifecycle transition (destroyed -> created) that many fragments may not be designed to support.
If instead the FragmentManager recreates the Fragment from scratch, that would avoid these issues but there will likely be negative performance implications.
It's worth noting that a user may in fact trigger a predictive back gesture without realizing it. In some cases, a tap near the side edge of the device will trigger the beginning and cancellation of the gesture, without any visual cue that this happened. That will exacerbate the difficulty of reproducing and diagnosing these types of lifecycle state bugs.