TWiStErRob / net.twisterrob.inventory

Magic Home Inventory https://play.google.com/store/apps/details?id=net.twisterrob.inventory
https://www.twisterrob.net/project/inventory/
20 stars 1 forks source link

Cursor leak on back-navigation #248

Open TWiStErRob opened 1 year ago

TWiStErRob commented 1 year ago
StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1986)
    at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
    at android.database.AbstractCursor.finalize(AbstractCursor.java:531)
    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:319)
    at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:306)
    at java.lang.Daemons$Daemon.run(Daemons.java:140)
    at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.Throwable: Explicit termination method 'AbstractCursor.close' not called
    at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
    at dalvik.system.CloseGuard.open(CloseGuard.java:257)
    at android.database.AbstractCursor.<init>(AbstractCursor.java:227)
    at android.database.MergeCursor.<init>(MergeCursor.java:43)
    at net.twisterrob.inventory.android.view.adapters.SingleHeaderAdapter.swapCursor(SingleHeaderAdapter.java:33)
    at net.twisterrob.inventory.android.view.RecyclerViewLoadersController.setData(RecyclerViewLoadersController.java:29)
    at net.twisterrob.inventory.android.view.RecyclerViewLoadersController.setData(RecyclerViewLoadersController.java:15)
    at net.twisterrob.inventory.android.view.RecyclerViewController.updateAdapter(RecyclerViewController.java:144)
    at net.twisterrob.inventory.android.view.RecyclerViewLoadersController$1.preOnLoadFinished(RecyclerViewLoadersController.java:38)
    at net.twisterrob.inventory.android.content.Loaders$18.onLoadFinished(Loaders.java:161)
    at net.twisterrob.inventory.android.content.Loaders$18.onLoadFinished(Loaders.java:153)
    at androidx.loader.app.LoaderManagerImpl$LoaderObserver.onChanged(LoaderManagerImpl.java:254)
    at androidx.lifecycle.LiveData.considerNotify(LiveData.java:131)
    at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:149)
    at androidx.lifecycle.LiveData.setValue(LiveData.java:307)
    at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
    at androidx.loader.app.LoaderManagerImpl$LoaderInfo.setValue(LoaderManagerImpl.java:188)
    at androidx.loader.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManagerImpl.java:173)
    at androidx.loader.content.Loader.deliverResult(Loader.java:131)
    at net.twisterrob.android.content.loader.AsyncLoader.deliverResult(AsyncLoader.java:41)
    at net.twisterrob.inventory.android.content.Loaders$LoadersCursorLoader.deliverResult(Loaders.java:262)
    at net.twisterrob.inventory.android.content.Loaders$LoadersCursorLoader.deliverResult(Loaders.java:231)
    at androidx.loader.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:239)
    at androidx.loader.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:79)
    at androidx.loader.content.ModernAsyncTask.finish(ModernAsyncTask.java:275)
    at androidx.loader.content.ModernAsyncTask$3.run(ModernAsyncTask.java:143)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7872)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
TWiStErRob commented 1 year ago
StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1986)
    at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:336)
    at android.database.AbstractCursor.finalize(AbstractCursor.java:531)
    at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:319)
    at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:306)
    at java.lang.Daemons$Daemon.run(Daemons.java:140)
    at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.Throwable: Explicit termination method 'AbstractCursor.close' not called
    at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:288)
    at dalvik.system.CloseGuard.open(CloseGuard.java:257)
    at android.database.AbstractCursor.<init>(AbstractCursor.java:227)
    at android.database.MatrixCursor.<init>(MatrixCursor.java:45)
    at net.twisterrob.inventory.android.view.adapters.SingleHeaderAdapter.swapCursor(SingleHeaderAdapter.java:37)
    at net.twisterrob.inventory.android.fragment.data.CategoryContentsFragment$CategoriesItemsController.setData(CategoryContentsFragment.java:135)
    at net.twisterrob.inventory.android.fragment.data.CategoryContentsFragment$CategoriesItemsController.setData(CategoryContentsFragment.java:122)
    at net.twisterrob.inventory.android.view.RecyclerViewController.updateAdapter(RecyclerViewController.java:144)
    at net.twisterrob.inventory.android.fragment.data.CategoryContentsFragment$CategoriesItemsController$Callbacks.refreshAdapter(CategoryContentsFragment.java:236)
    at net.twisterrob.inventory.android.fragment.data.CategoryContentsFragment$CategoriesItemsController$Callbacks.preOnLoadFinished(CategoryContentsFragment.java:213)
    at net.twisterrob.inventory.android.content.Loaders$18.onLoadFinished(Loaders.java:161)
    at net.twisterrob.inventory.android.content.Loaders$18.onLoadFinished(Loaders.java:153)
    at androidx.loader.app.LoaderManagerImpl$LoaderObserver.onChanged(LoaderManagerImpl.java:254)
    at androidx.lifecycle.LiveData.considerNotify(LiveData.java:131)
    at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:149)
    at androidx.lifecycle.LiveData.setValue(LiveData.java:307)
    at androidx.lifecycle.MutableLiveData.setValue(MutableLiveData.java:50)
    at androidx.loader.app.LoaderManagerImpl$LoaderInfo.setValue(LoaderManagerImpl.java:188)
    at androidx.loader.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManagerImpl.java:173)
    at androidx.loader.content.Loader.deliverResult(Loader.java:131)
    at net.twisterrob.android.content.loader.AsyncLoader.deliverResult(AsyncLoader.java:41)
    at net.twisterrob.inventory.android.content.Loaders$LoadersCursorLoader.deliverResult(Loaders.java:262)
    at net.twisterrob.inventory.android.content.Loaders$LoadersCursorLoader.deliverResult(Loaders.java:231)
    at androidx.loader.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:239)
    at androidx.loader.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:79)
    at androidx.loader.content.ModernAsyncTask.finish(ModernAsyncTask.java:275)
    at androidx.loader.content.ModernAsyncTask$3.run(ModernAsyncTask.java:143)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7872)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
TWiStErRob commented 1 year ago
sequenceDiagram
    autonumber

    box Adapter
    participant GalleryAdapter
    participant SingleHeaderAdapter
    participant CursorRecyclerAdapter
    end
    participant Android
    box Fragment
    participant XListFragment
    participant BaseGalleryFragment
    participant BaseFragment
    end
    box Controller
    participant BaseGalleryController
    participant RecyclerViewLoadersController
    participant RecyclerViewLoaderController
    participant RecyclerViewController
    end

    XListFragment ->> BaseGalleryController: <init>
    activate RecyclerViewController
    activate XListFragment
    BaseGalleryController -> RecyclerViewController: <init>
    RecyclerViewController -->> BaseGalleryFragment: controller
    deactivate RecyclerViewController
    deactivate XListFragment

    Android ->> BaseGalleryFragment: onViewCreated()
    activate XListFragment
    BaseGalleryFragment ->> + RecyclerViewController: controller.setView()
    RecyclerViewController ->> + RecyclerViewController: onViewSet()
    RecyclerViewController ->> + RecyclerViewController: setupList()
    RecyclerViewController ->> + BaseGalleryController: setupList()
    BaseGalleryController ->> + BaseGalleryFragment: setupGallery()
    BaseGalleryFragment ->> BaseGalleryFragment: createAdapter()
    BaseGalleryFragment -->> - BaseGalleryController: adapter
    BaseGalleryController -->> - RecyclerViewController: adapter
    deactivate RecyclerViewController
    deactivate RecyclerViewController
    deactivate RecyclerViewController
    deactivate XListFragment

    Android ->> BaseFragment: onActivityCreated
    activate XListFragment
    BaseFragment ->> BaseGalleryFragment: onStartLoading()
    BaseGalleryFragment ->> RecyclerViewLoaderController: startLoad()
    RecyclerViewLoaderController ->> RecyclerViewLoadersController: startLoad()
    RecyclerViewLoadersController ->> LoaderManager: initLoader()
    LoaderManager ->> RecyclerViewController: updateAdapter()
    RecyclerViewController ->> RecyclerViewController: setData(data: D)
    RecyclerViewController ->> RecyclerViewLoadersController: setData(data: Cursor)
    RecyclerViewLoadersController ->> SingleHeaderAdapter: swapCursor(data: Cursor)
    SingleHeaderAdapter ->> CursorRecyclerAdapter: swapCursor(data: MergeCursor)
    deactivate XListFragment

    Android ->> BaseFragment: onDestroy
    activate XListFragment
    BaseGalleryFragment ->> RecyclerViewLoadersController: close()
    RecyclerViewLoadersController ->> LoaderManager: destroyLoader()
    LoaderManager ->> RecyclerViewLoadersController: onLoaderReset /preOnLoaderReset()
    RecyclerViewLoadersController ->> RecyclerViewController: updateAdapter(null)
    RecyclerViewController ->> RecyclerViewController: setData(data: D = null)
    RecyclerViewController ->> RecyclerViewLoadersController: setData(data: Cursor = null)
    RecyclerViewLoadersController ->> SingleHeaderAdapter: swapCursor(data: Cursor = null)
    SingleHeaderAdapter ->> CursorRecyclerAdapter: swapCursor(data: MergeCursor)
    %%RecyclerViewLoadersController ->> CursorRecyclerAdapter: changeCursor(null)
    %%CursorRecyclerAdapter ->> SingleHeaderAdapter: swapCursor(data: Cursor)
    %%SingleHeaderAdapter ->> CursorRecyclerAdapter: swapCursor(data: MergeCursor)
    deactivate XListFragment