Skeleton
Skeleton copied to clipboard
Leak canary detects memory leaks when using view based skeleton
skeletonScreen = Skeleton.bind(rootView)
.color(R.color.tlShimmerColor)
.load(R.layout.item_skeleton_view_profile)
.show();
Leads to FrameLayout
being leaked. My analysis is that this is due to this function:
private ShimmerLayout generateShimmerContainerLayout(ViewGroup parentView) {
final ShimmerLayout shimmerLayout = (ShimmerLayout) LayoutInflater.from(mActualView.getContext()).inflate(R.layout.layout_shimmer, parentView, false);
shimmerLayout.setShimmerColor(mShimmerColor);
shimmerLayout.setShimmerAngle(mShimmerAngle);
shimmerLayout.setShimmerAnimationDuration(mShimmerDuration);
View innerView = LayoutInflater.from(mActualView.getContext()).inflate(mSkeletonResID, shimmerLayout, false);
ViewGroup.LayoutParams lp = innerView.getLayoutParams();
if (lp != null) {
shimmerLayout.setLayoutParams(lp);
}
shimmerLayout.addView(innerView);
shimmerLayout.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() {
@Override
public void onViewAttachedToWindow(View v) {
shimmerLayout.startShimmerAnimation();
}
@Override
public void onViewDetachedFromWindow(View v) {
shimmerLayout.stopShimmerAnimation();
}
});
shimmerLayout.startShimmerAnimation();
return shimmerLayout;
}
A new object is being inflated which internally uses the rootView but it is never destroyed explicitly.
setting mViewReplacer to null fixed this issue (did it using reflection as a quick hack).
don't think anyone is managing this project or responding to PRs now.
where is mViewReplacer, I don't see in the above code
setting mViewReplacer to null fixed this issue (did it using reflection as a quick hack). don't think anyone is managing this project or responding to PRs now.
Hi @bhpcode Can you please eloborate how you fixed this, I am facing same issue