Status Update
Comments
mm...@gmail.com <mm...@gmail.com>
ps...@google.com <ps...@google.com>
ps...@google.com <ps...@google.com> #2
class FixDrawerLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
) : DrawerLayout(context, attrs) {
fun registerToFragmentLifecycle(fragment: Fragment) {
fragment.viewLifecycleOwner.launchOnLifecycleDestroy {
super.onDetachedFromWindow()
}
}
}
mm...@gmail.com <mm...@gmail.com> #3
With markdown the same:
I have a project on SingleActivity. And in manifest android:enableOnBackInvokedCallback="true". I have a Root Fragment with a toolbar to which I attach a DrawerLayout.
<!-- XML Root Fragment -->
<androidx.drawerlayout.widget.DrawerLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.appbar.MaterialToolbar />
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<androidx.core.widget.NestedScrollView
android:layout_gravity="start">
</androidx.drawerlayout.widget.DrawerLayout>
On button click in DrawerLayout I change RootFragment and lose all View in this Xml after onDestroyView. I don't call close() or closeDrawer() because I need the old state when I return to this fragment. But!
The DrawerLayout calls onDetachedFromWindow() which calls updateBackInvokedCallbackState() where ViewCompat.isAttachedToWindow(this) returns true and all the following condition is also true.
boolean shouldBeRegistered = visibleDrawer != null
&& currentDispatcher != null
&& getDrawerLockMode(visibleDrawer) == LOCK_MODE_UNLOCKED
&& ViewCompat.isAttachedToWindow(this);
As a consequence, the following code cannot be executed:
} else if (!shouldBeRegistered && mBackInvokedDispatcher != null) {
Api33Impl.tryUnregisterOnBackInvokedCallback(
mBackInvokedDispatcher, mBackInvokedCallback);
mBackInvokedDispatcher = null;
}
Where mBackInvokedDispatcher != null is true, and shouldBeRegistered is true (but !shouldBeRegistered is false).
Consequently, my mechanical back button or slide (back gesture) is blocked and not called on a new Root fragment when the DrawerLayout is Destroyed.
<!-- new Root fragment -->
<androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.appbar.MaterialToolbar />
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
There may be a workaround, but that's not all. The fact is that LeakCanary reacts to this error, which claims that after registerOnBackInvokedCallback and not called tryUnregisterOnBackInvokedCallback, a memory leak occurs.
fast fix: android:enableOnBackInvokedCallback="false" or downgrade DrawerLayout to 1.1.1 or
Description
What
User experience
What type of issue is this?
Display or rendering issue
What steps would let us observe this issue?
What did you expect to happen?
Play Collections shows an app installed and Widget is showing thumbnails
What actually happened?
App Library is blank and Widget does not render thumbnails.
What was the effect of this issue on your device usage, such as lost time or work?
None - device worked normally
Additional comments
I tried to uninstall the update and clear the cache many times but the problem still exists. While another phone is showing normally, my Pixel 8a is not.
When
Time and frequency
When did this happen?
Mar 3, 2025 5:41 PM GMT+07:00
How often has this happened?
Every time
Where
Component
Originating component: <not visible> (1684638)
Build and device data
- Build Number: google/akita_beta/akita:Baklava/BP22.250124.010/13116449:user/release-keys
(Note: It is the build when sending this report. For exact build reference, please see the attached bugreport.)
Related apps
Google Play Store
com.android.vending
Version 84511230 (45.1.12-31 [0] [PR] 729649519)
System App (Updated)
Debugging information
Google Play services
com.google.android.gms
Version 250861035 (25.08.61 (260400-731857739))
System App (Updated)
Android System WebView
com.google.android.webview
Version 699803943 (134.0.6998.39)
System App (Updated)
Network operator: TRUE-H
SIM operator: TRUE-H
Network operator: dtac.Better Together
SIM operator: dtac
Filed by Android Beta Feedback. Version (Updated): 2.46-betterbug.external_20241023_RC01 (DOGFOOD)https://developer.android.com/preview/feedback#feedback-app .
To learn more about our feedback process, please visit