Describe the bug
KiwixReaderFragment is leaking
Expected behavior
No memory leaks should be present.
Steps to reproduce the behavior:
Screenshots
β¬βββ
β GC Root: System class
β
ββ android.view.inputmethod.InputMethodManager class
β Leaking: NO (InputMethodManagerβ is not leaking and a class is never leaking)
β β static InputMethodManager.sInstance
ββ android.view.inputmethod.InputMethodManager instance
β Leaking: NO (DecorViewβ is not leaking and InputMethodManager is a singleton)
β β InputMethodManager.mNextServedView
ββ com.android.internal.policy.DecorView instance
β Leaking: NO (RecyclerViewβ is not leaking and View attached)
β mContext instance of com.android.internal.policy.DecorContext, wrapping activity org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β Parent android.view.ViewRootImpl not a android.view.View
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mWindowAttachCount = 1
β β DecorView.mAttachInfo
ββ android.view.View$AttachInfo instance
β Leaking: NO (RecyclerViewβ is not leaking)
β β View$AttachInfo.mScrollContainers
ββ java.util.ArrayList instance
β Leaking: NO (RecyclerViewβ is not leaking)
β β ArrayList.elementData
ββ java.lang.Object[] array
β Leaking: NO (RecyclerViewβ is not leaking)
β β Object[].[2]
ββ androidx.recyclerview.widget.RecyclerView instance
β Leaking: NO (View attached)
β mContext instance of org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β View.parent android.widget.LinearLayout attached as well
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mID = R.id.right_drawer_list
β View.mWindowAttachCount = 1
β β RecyclerView.mAdapter
β ~~~~~~
ββ org.kiwix.kiwixmobile.core.main.TableDrawerAdapter instance
β Leaking: UNKNOWN
β β TableDrawerAdapter.listener
β ~~~~~~
ββ org.kiwix.kiwixmobile.core.main.CoreReaderFragment$7 instance
β Leaking: UNKNOWN
β Anonymous class implementing org.kiwix.kiwixmobile.core.main.TableDrawerAdapter$TableClickListener
β β CoreReaderFragment$7.this$0
β ~~~~
β°β org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragment instance
β Leaking: YES (ObjectWatcher was watching this because org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragment received Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
β key = b9dd5d25-5ae3-4c56-83d1-f3e2fdae4252
β watchDurationMillis = 8963
β retainedDurationMillis = 3963
METADATA
Build.VERSION.SDK_INT: 29
Build.MANUFACTURER: OnePlus
LeakCanary version: 2.4
App process name: org.kiwix.kiwixmobile
Analysis duration: 10339 ms
Setting the tableDrawerAdapters listener to null semms to fix this leak, but another shows up:
β¬βββ
β GC Root: System class
β
ββ android.view.inputmethod.InputMethodManager class
β Leaking: NO (InputMethodManagerβ is not leaking and a class is never leaking)
β β static InputMethodManager.sInstance
ββ android.view.inputmethod.InputMethodManager instance
β Leaking: NO (DecorViewβ is not leaking and InputMethodManager is a singleton)
β β InputMethodManager.mNextServedView
ββ com.android.internal.policy.DecorView instance
β Leaking: NO (RecyclerViewβ is not leaking and View attached)
β mContext instance of com.android.internal.policy.DecorContext, wrapping activity org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β Parent android.view.ViewRootImpl not a android.view.View
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mWindowAttachCount = 1
β β DecorView.mAttachInfo
ββ android.view.View$AttachInfo instance
β Leaking: NO (RecyclerViewβ is not leaking)
β β View$AttachInfo.mScrollContainers
ββ java.util.ArrayList instance
β Leaking: NO (RecyclerViewβ is not leaking)
β β ArrayList.elementData
ββ java.lang.Object[] array
β Leaking: NO (RecyclerViewβ is not leaking)
β β Object[].[2]
ββ androidx.recyclerview.widget.RecyclerView instance
β Leaking: NO (RelativeLayoutβ is not leaking and View attached)
β mContext instance of org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β View.parent android.widget.LinearLayout attached as well
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mID = R.id.right_drawer_list
β View.mWindowAttachCount = 1
β β RecyclerView.mChildren
ββ android.view.View[] array
β Leaking: NO (RelativeLayoutβ is not leaking)
β β View[].[0]
ββ android.widget.RelativeLayout instance
β Leaking: NO (View attached)
β mContext instance of org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β View.parent androidx.recyclerview.widget.RecyclerView attached as well
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mWindowAttachCount = 3
β β RelativeLayout.mListenerInfo
β ~~~~~~~~~~~
ββ android.view.View$ListenerInfo instance
β Leaking: UNKNOWN
β β View$ListenerInfo.mOnClickListener
β ~~~~~~~~~~~~~~
ββ org.kiwix.kiwixmobile.core.main.TableDrawerAdapter$sam$android_view_View_OnClickListener$0 instance
β Leaking: UNKNOWN
β Anonymous class implementing android.view.View$OnClickListener
β β TableDrawerAdapter$sam$android_view_View_OnClickListener$0.function
β ~~~~~~
ββ org.kiwix.kiwixmobile.core.main.TableDrawerAdapter$onBindViewHolder$1 instance
β Leaking: UNKNOWN
β Anonymous subclass of kotlin.jvm.internal.FunctionReference
β β TableDrawerAdapter$onBindViewHolder$1.receiver
β ~~~~~~
ββ org.kiwix.kiwixmobile.core.main.CoreReaderFragment$7 instance
β Leaking: UNKNOWN
β Anonymous class implementing org.kiwix.kiwixmobile.core.main.TableDrawerAdapter$TableClickListener
β β CoreReaderFragment$7.this$0
β ~~~~
β°β org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragment instance
β Leaking: YES (ObjectWatcher was watching this because org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragment received Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
β key = 5c2f320e-626c-420a-9d2f-22a8b2603781
β watchDurationMillis = 15543
β retainedDurationMillis = 10509
METADATA
Build.VERSION.SDK_INT: 29
Build.MANUFACTURER: OnePlus
LeakCanary version: 2.4
App process name: org.kiwix.kiwixmobile
Analysis duration: 16812 ms
@Frans-Lukas Do you wanna work on this issue?
@gouri-panda I won't until next weekend so if you feel like doing it before then, go ahead.
@gouri-panda If you can fix it quickly this would be much appreciated, I believe nobody is comfortable with the idea of shipping 3.4.1 with known memoery leaks.
@gouri-panda I will be taking over this ticket in the interest of expediting it
@Frans-Lukas I cannot reproduce this issue using the repro steps. Can you reverify this leak on latest develop?
Still reproducible, could it be book specific?
β¬βββ
β GC Root: System class
β
ββ android.view.inputmethod.InputMethodManager class
β Leaking: NO (InputMethodManagerβ is not leaking and a class is never leaking)
β β static InputMethodManager.sInstance
ββ android.view.inputmethod.InputMethodManager instance
β Leaking: NO (DecorViewβ is not leaking and InputMethodManager is a singleton)
β β InputMethodManager.mNextServedView
ββ com.android.internal.policy.DecorView instance
β Leaking: NO (RecyclerViewβ is not leaking and View attached)
β mContext instance of com.android.internal.policy.DecorContext, wrapping activity org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β Parent android.view.ViewRootImpl not a android.view.View
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mWindowAttachCount = 1
β β DecorView.mAttachInfo
ββ android.view.View$AttachInfo instance
β Leaking: NO (RecyclerViewβ is not leaking)
β β View$AttachInfo.mScrollContainers
ββ java.util.ArrayList instance
β Leaking: NO (RecyclerViewβ is not leaking)
β β ArrayList.elementData
ββ java.lang.Object[] array
β Leaking: NO (RecyclerViewβ is not leaking)
β β Object[].[2]
ββ androidx.recyclerview.widget.RecyclerView instance
β Leaking: NO (View attached)
β mContext instance of org.kiwix.kiwixmobile.main.KiwixMainActivity with mDestroyed = false
β View.parent android.widget.LinearLayout attached as well
β View#mParent is set
β View#mAttachInfo is not null (view attached)
β View.mID = R.id.right_drawer_list
β View.mWindowAttachCount = 1
β β RecyclerView.mAdapter
β ~~~~~~
ββ org.kiwix.kiwixmobile.core.main.TableDrawerAdapter instance
β Leaking: UNKNOWN
β β TableDrawerAdapter.listener
β ~~~~~~
ββ org.kiwix.kiwixmobile.core.main.CoreReaderFragment$7 instance
β Leaking: UNKNOWN
β Anonymous class implementing org.kiwix.kiwixmobile.core.main.TableDrawerAdapter$TableClickListener
β β CoreReaderFragment$7.this$0
β ~~~~
β°β org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragment instance
β Leaking: YES (ObjectWatcher was watching this because org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragment received Fragment#onDestroy() callback and Fragment#mFragmentManager is null)
β key = e2d4fa0d-7fad-4970-9cb9-09cd05c6c623
β watchDurationMillis = 6936
β retainedDurationMillis = 1915
METADATA
Build.VERSION.SDK_INT: 29
Build.MANUFACTURER: OnePlus
LeakCanary version: 2.4
App process name: org.kiwix.kiwixmobile
Analysis duration: 10368 ms