-
Notifications
You must be signed in to change notification settings - Fork 671
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
Unexpected cancellation - Coil doesn't work with setRetainInstance #1918
Comments
Are all new requests cancelled if they're launched after the view is reattached to the activity? If you use an |
All requests from the retained fragment are immediately cancelled from the moment the device is rotated. It never recovers - e.g. I scroll the recyclerview up and down, and the image requests are all immediately cancelled. As far as I could see, the Scope defined in RealImageLoader is cancelled from the shutdown method, which is called from onConfigurationChanged. The scope is never recreated, so all calls to it are immediately cancelled. |
@darrentaft The scope in |
It's definitely attached - I'm scrolling the RecyclerView up and down the screen, and all image requests (for elements within it) immediately report that they're cancelled. The text elements around the image update correctly. |
@darrentaft Can you share the bit of code using Coil in your Fragment? I'm asking for curiosity. |
When setRetainInstance is true on a fragment, coil refuses to load any images after configuration change. Logs indicate that all the requests are cancelled, as the Coroutine scope is blindly cancelled from onConfigurationChanged.
I suspect this will be marked as WillNotFix as setRetainInstance is deprecated and strongly advised against - we have it in some legacy code that I have now started to refactor as a result of this bug.
Raising here for awareness and to save anyone else potentially spending hours investigating this.
Using Coil 2.5.0
The text was updated successfully, but these errors were encountered: