-
-
Notifications
You must be signed in to change notification settings - Fork 387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix another crash in ShareShortcutHelper #4431
Conversation
My bad, I should have looked closer at the Glide API! I'll take a look later today as soon as I come back home. |
Here's a recap of my struggles with the Glide API to retrieve an image outside of a View. My apologies for the long read.
My next objective was to implement a custom However, it turns out that both I dug up further into the Glide codebase and found out that it's possible to find out if the resource is the placeholder or the actual image by checking if the current I also found out that Glide provides an experimental module containing methods to retrieve a
In conclusion: the Glide API is a mess but I still managed to find a way to properly detect if the image is the final result and return it once. I'll send the code later. |
Here's the updated implementation:
I added a test in |
Not related to the bug: to avoid converting the fallback vector drawable to a
|
Thanks @cbeyls, looks good, please send a PR! |
Glide sometimes calls the callback more than once (for the placeholder, then for the actual image), but a coroutine can only resume once. ``` Exception java.lang.IllegalStateException: at kotlinx.coroutines.CancellableContinuationImpl.alreadyResumedError (CancellableContinuationImpl.kt:555) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl (CancellableContinuationImpl.kt:520) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default (CancellableContinuationImpl.kt:493) at kotlinx.coroutines.CancellableContinuationImpl.resumeWith (CancellableContinuationImpl.kt:364) at com.keylesspalace.tusky.util.GlideExtensionsKt$submitAsync$2$target$1.onResourceReady (GlideExtensions.kt:39) at com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:650) at com.bumptech.glide.request.SingleRequest.onResourceReady (SingleRequest.java:596) at com.bumptech.glide.request.SingleRequest.begin (SingleRequest.java:243) at com.bumptech.glide.manager.RequestTracker.resumeRequests (RequestTracker.java:115) at com.bumptech.glide.RequestManager.resumeRequests (RequestManager.java:339) at com.bumptech.glide.RequestManager.onStart (RequestManager.java:364) at com.bumptech.glide.manager.ApplicationLifecycle.addListener (ApplicationLifecycle.java:15) at com.bumptech.glide.RequestManager$1.run (RequestManager.java:84) at android.os.Handler.handleCallback (Handler.java:958) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:230) at android.os.Looper.loop (Looper.java:319) at android.app.ActivityThread.main (ActivityThread.java:8893) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1103) ``` While removing the placeholder fixes the problem here, we should probably put some safeguards into `submitAsync` so that this can't happen again elsewhere. Any ideas how to do that, @cbeyls?
Glide sometimes calls the callback more than once (for the placeholder, then for the actual image), but a coroutine can only resume once.
While removing the placeholder fixes the problem here, we should probably put some safeguards into
submitAsync
so that this can't happen again elsewhere. Any ideas how to do that, @cbeyls?