You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are at least two problem cases with ShimmerLayout animation logic.
If the ShimmerLayout has parent view/container and you hide parent view, animation logic inside ShimmerLayout doesn't stop. For example, we have some xml
then our ShimmerLayout will run recursivelly in startShimmerAnimation method, although we have not even shown it to the user.
More than that it leads to memory leak when using Activity#recreate method:
a) ShimmerLayout#startShimmerAnimation subscribes to ViewTreeObserver#onPreDraw to detect own width;
b) ShimmerLayout don't stop animation logic when parent view becomes hidden or the ShimmerLayout is detached from the window.;
com.example.app.MyFragment has leaked:
static WindowManagerGlobal.sDefaultWindowManager
↳ WindowManagerGlobal.mRoots
↳ ArrayList.elementData
↳ array Object[].[0]
↳ ViewRootImpl.!(mAttachInfo)!
↳ View$AttachInfo.!(mTreeObserver)!
↳ ViewTreeObserver.!(mOnPreDrawListeners)!
↳ ViewTreeObserver$CopyOnWriteArray.!(mData)!
↳ ArrayList.!(elementData)!
↳ array Object[].!([1])!
↳ ShimmerLayout$1.!(this$0)! (anonymous implementation of android.view.ViewTreeObserver$OnPreDrawListener)
↳ ShimmerLayout.mContext
↳ MainActivity.navigationController
↳ DefaultBottomBarController.adapter
↳ CachePagerAdapter.mCurrentPrimaryItem
↳ MyFragment
The text was updated successfully, but these errors were encountered:
issue: I believe the answer to this is very obvious. If you animate a View with built-in classes like ObjectAnimator and the animated View becomes hidden, then the animation will continue regardless. With this library, it is the same.
issue: good finding. I could reproduce the memory leak, a fix will come.
There are at least two problem cases with ShimmerLayout animation logic.
<androidx.cardview.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="8dp"
android:visibility="gone">
</androidx.cardview.widget.CardView>
then our ShimmerLayout will run recursivelly in startShimmerAnimation method, although we have not even shown it to the user.
a) ShimmerLayout#startShimmerAnimation subscribes to ViewTreeObserver#onPreDraw to detect own width;
b) ShimmerLayout don't stop animation logic when parent view becomes hidden or the ShimmerLayout is detached from the window.;
The text was updated successfully, but these errors were encountered: