Fixed
Status Update
Comments
il...@google.com <il...@google.com>
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #3
Project: platform/frameworks/support
Branch: androidx-main
commit 66bcb0e2ad3ed698318475f3c6147506207362cc
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Feb 03 16:11:45 2022
Clear ObserverMap with LifecycleRegistry is DESTROYED
After the LifecycleRegistry is DESTROYED it will not get anymore
callbacks so we should just clear our the Observers.
RelNote: "`LifecycleRegistry` will now clear their observers when they
reach the DESTROYED state."
Test: all existing tests pass
Bug: 142925860
Change-Id: I4f8ddff68b9daebbd89aaa6d9abe7d462081d45e
M lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
https://android-review.googlesource.com/1972160
Branch: androidx-main
commit 66bcb0e2ad3ed698318475f3c6147506207362cc
Author: Jeremy Woods <jbwoods@google.com>
Date: Thu Feb 03 16:11:45 2022
Clear ObserverMap with LifecycleRegistry is DESTROYED
After the LifecycleRegistry is DESTROYED it will not get anymore
callbacks so we should just clear our the Observers.
RelNote: "`LifecycleRegistry` will now clear their observers when they
reach the DESTROYED state."
Test: all existing tests pass
Bug: 142925860
Change-Id: I4f8ddff68b9daebbd89aaa6d9abe7d462081d45e
M lifecycle/lifecycle-runtime/src/main/java/androidx/lifecycle/LifecycleRegistry.java
il...@google.com <il...@google.com> #4
This has been fixed internally and will be available in Lifecycle 2.5.0-alpha03.
Description
Observation #2: LifecycleRegistry.moveToState(next) immediately returns if next state == current state.
Therefore any observer remaining in LifecycleRegistry's mObserverMap is completely useless and will never be notified again after the LifecycleRegistry has reached State.DESTROYED.
Please clear mObserverMap when LifecycleRegistry reaches State.DESTROYED, allowing the observers to be garbage collected immediately.