Fixed
Status Update
Comments
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit aa357b3a352169875da4fd9416e276936e421843
Author: Dake Gu <dake@google.com>
Date: Mon May 17 15:30:30 2021
leanback: fix details fragment lost background
The parallax background drawable should not be cleared in onDestroyView(), it
is created on or before onCreate() and should be same life cycle as fragment.
Sample app already cleared bitmap calling setCoverBitmap(null) in onStop().
Added verfication in test check if Bitmap is released.
Bug: 187577716
Test: DetailsSupportFragmentTest#viewLeakTest
Change-Id: I6c50ebdcf713c991ca0e97d4946a66832d53d9cc
M leanback/leanback/src/androidTest/java/androidx/leanback/app/DetailsFragmentTest.java
M leanback/leanback/src/androidTest/java/androidx/leanback/app/DetailsSupportFragmentTest.java
M leanback/leanback/src/main/java/androidx/leanback/app/DetailsFragment.java
M leanback/leanback/src/main/java/androidx/leanback/app/DetailsSupportFragment.java
M leanback/leanback/src/main/java/androidx/leanback/app/SearchFragment.java
https://android-review.googlesource.com/1709911
Branch: androidx-main
commit aa357b3a352169875da4fd9416e276936e421843
Author: Dake Gu <dake@google.com>
Date: Mon May 17 15:30:30 2021
leanback: fix details fragment lost background
The parallax background drawable should not be cleared in onDestroyView(), it
is created on or before onCreate() and should be same life cycle as fragment.
Sample app already cleared bitmap calling setCoverBitmap(null) in onStop().
Added verfication in test check if Bitmap is released.
Bug: 187577716
Test: DetailsSupportFragmentTest#viewLeakTest
Change-Id: I6c50ebdcf713c991ca0e97d4946a66832d53d9cc
M leanback/leanback/src/androidTest/java/androidx/leanback/app/DetailsFragmentTest.java
M leanback/leanback/src/androidTest/java/androidx/leanback/app/DetailsSupportFragmentTest.java
M leanback/leanback/src/main/java/androidx/leanback/app/DetailsFragment.java
M leanback/leanback/src/main/java/androidx/leanback/app/DetailsSupportFragment.java
M leanback/leanback/src/main/java/androidx/leanback/app/SearchFragment.java
Description
Component used: androidx.leanback:leanback
Version used: 1.1.0-rc01
The
DetailsSupportFragmentBackgroundController
class no longer works correctly.When following the documentation linked above, it seems to work fine. The cover bitmap appears. However, when you navigate to another screen (for example using the AndroidX Navigation component), and then go back again, the cover bitmap does not appear. In my app it shows just a grey background. So for some reason the background is not set.
I looked into this bug and it seems that it was introduced when fixing memory leaks here:https://android.googlesource.com/platform/frameworks/support/+/2f2fa284ef504e466c21b91820b7bb3a18ddea30%5E%21/#F3
Specifically, it is caused by setting
mBackgroundDrawable
tonull
inonDestroyView
. So when you navigate to another fragment, and then back again,mBackgroundDrawable
isnull
which was not the case before.Thehttps://android.googlesource.com/platform/frameworks/support/+/2f2fa284ef504e466c21b91820b7bb3a18ddea30/leanback/leanback/src/main/java/androidx/leanback/app/DetailsSupportFragment.java#477 . But as this value is now set to
DetailsSupportFragment
automatically usesmBackgroundDrawable
inonCreateView
to configure the background:null
this does not work anymore.The fix is to not set
mBackgroundDrawable
tonull
inonDestroyView
. As far as I know that cannot cause a leak as the drawable does not reference any views.A workaround which I am using at the moment is the following class: