-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
Improve RequestBuilder.submitAsync() to ensure the coroutine continuation is resumed only once #4436
Improve RequestBuilder.submitAsync() to ensure the coroutine continuation is resumed only once #4436
Conversation
…e in RequestBuilder.submitAsync()
This is still not working, the following crash is reported in the Google Play console for version 26.0:
😭 |
Glide's API is a mess. |
Glide's application If a request like this one is still tracked and Glide detects the app came back to the foreground, it will send the result again to the target even if the request is complete:
So this is the cause of the issue. There is no clean way to fix this. The extension method doesn't have access to the It is not possible to unregister a request listener on a Request after is has been registered, so the target will keep tracking the continuation until the weak reference disappears. It is possible to set the request to What looks the best to me is to create a |
Maybe we should just catch the exception? |
We can test |
…request is restarted (#4569) This is the third attempt to fix `RequestBuilder.submitAsync()`. For the rationale, see the comments of #4436. We now clear the continuation reference after resuming it, to make sure that: 1) It will only be resumed once 2) It will not leak the coroutine when Glide keeps the `Request` around.
RequestListener.onResourceReady()
may also be called to provide the placeholder image when the request is starting or when it is cleared.Check if the current request is complete (its status set to COMPLETE) to determine if the Glide resource is for a thumbnail/placeholder or the final image, and resume the coroutine only for the final image (or in case of error).
This logic is borrowed from the Glide Flow API.