glide
glide copied to clipboard
Fatal Exception: java.lang.IllegalStateException: Cannot recycle a resource while it is still acquired
I am currently using Glide version : 4.11.0 implementation 'com.github.bumptech.glide:glide:4.11.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
Cannot recycle a resource while it is still acquired com.bumptech.glide.load.engine.EngineResource.recycle (EngineResource.java:68) com.bumptech.glide.load.engine.ResourceRecycler$ResourceRecyclerCallback.handleMessage (ResourceRecycler.java:37) android.os.Handler.dispatchMessage (Handler.java:103) android.os.Looper.loop (Looper.java:227) android.app.ActivityThread.main (ActivityThread.java:7822) java.lang.reflect.Method.invoke (Method.java) com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:492) com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1026)
We've got exactly the same issue. It seems that the glide crashes randomly on production - this issue cannot be replicated locally.
Full stack log:
Fatal Exception: java.lang.IllegalStateException: Cannot recycle a resource while it is still acquired
at com.bumptech.glide.load.engine.EngineResource.recycle(EngineResource.java:68)
at com.bumptech.glide.load.engine.ResourceRecycler$ResourceRecyclerCallback.handleMessage(ResourceRecycler.java:37)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6680)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Environment:
- Android 9
- Glide 4.12.0
Do you have any ideas how to debug this issue?
For my case i have invalidate my current bitmap clear glide cache and then reassigned bitmap thus it solved the problem but the main problem it arrose. It slowed down the loading of receyclerview images
On Tue, Nov 2, 2021, 2:44 PM mkocus @.***> wrote:
We've got exactly the same issue. It seems that the glide crashes randomly on production - this issue cannot be replicated locally.
Full stack log:
Fatal Exception: java.lang.IllegalStateException: Cannot recycle a resource while it is still acquired at com.bumptech.glide.load.engine.EngineResource.recycle(EngineResource.java:68) at com.bumptech.glide.load.engine.ResourceRecycler$ResourceRecyclerCallback.handleMessage(ResourceRecycler.java:37) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6680) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Environment:
- Android 9
- Glide 4.12.0
Do you have any ideas how to debug this issue?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bumptech/glide/issues/4507#issuecomment-957273856, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXVZCUHA6A5IGWTDHFYW63UJ6XJTANCNFSM4YB6LR3A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Well, we are using glide a lot and cannot locate where precisely this crash happen :/ The steps that you are proposing are totally destructive - clearing glide cache all the time basically kills the performance and is a no-go for us.
I didn't say clear cache from everyone just from the glide which is used inside the receyclerview However if you can solve the actual problem.it is inside the cache it doesn't let to update the cache which changes in iteration behavior which causes the crash as what i observe
On Tue, Nov 2, 2021, 2:59 PM mkocus @.***> wrote:
Well, we are using glide a lot and cannot locate where precisely this crash happen :/ The steps that you are proposing are totally destructive - clearing glide cache all the time basically kills the performance and is a no-go for us.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bumptech/glide/issues/4507#issuecomment-957284961, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXVZCUTMYTKEXVZ6K76AKDUJ6ZBVANCNFSM4YB6LR3A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Of course, but this is what I have in mind - we just don't want to clear glide cache.
Cool, thanks!
On Tue, Nov 2, 2021, 3:05 PM mkocus @.***> wrote:
Of course, but this is what I have in mind - we just don't want to clear glide cache.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bumptech/glide/issues/4507#issuecomment-957289392, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXVZCQ36CWM4FPEFKV5UF3UJ6ZXHANCNFSM4YB6LR3A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
We still didn't managed to fix this issue. Do you have a knowledge when the glide tries to recycle resource? The stacktrace only shows that this is an async code which receives message to recycle resource - but who sent it and why?
I think with a modification shown in https://github.com/bumptech/glide/pull/5310, it would be possible to diagnose this further. But I think that PR is not production ready to be merged to Glide.
If you want to investigate this further, one thing I could recommend is hacking the Glide Engine to use this recycler in the PR to be able to see where the recycle is being called from, which might reveal further leads to fix this. To do this, one would need the following setup:
// put this in a LibraryGlideModule:
val engine = Glide::class.java.getDeclaredField("engine").apply { isAccessible = true }.get(glide) as Engine
val modifiedRecycler = InstanceOfResourceRecyclerFromPR()
Engine::class.java.getDeclaredField("resourceRecycler").apply { isAccessible = true }.set(engine, modifiedRecycler)
// If there's ProGuard/R8 add keep rules for the accessed fields.
Note: if we have a repro, things would change a lot, but from what I see in these two issues, there's inconclusive evidence. Out of curiosity how many crashes of this are there in the wild?
cc @lyjSmile @hpdx @ayyaztalat @mkocus
Galaxy A20 Android 11 The crash doesn't point to any specific line of code in the application.
Fatal Exception: java.lang.IllegalStateException: Cannot recycle a resource while it is still acquired
at com.bumptech.glide.load.engine.EngineResource.recycle(EngineResource.java:68)
at com.bumptech.glide.load.engine.ResourceRecycler$ResourceRecyclerCallback.handleMessage(ResourceRecycler.java:37)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:246)
at android.app.ActivityThread.main(ActivityThread.java:8645)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)