-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat(mobile): Prevent premature image cache eviction when higher image loading is enabled #26208
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,7 +48,7 @@ mixin CancellableImageProviderMixin<T extends Object> on CancellableImageProvide | |||||||||||||
| return null; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| Stream<ImageInfo> loadRequest(ImageRequest request, ImageDecoderCallback decode) async* { | ||||||||||||||
| Stream<ImageInfo> loadRequest(ImageRequest request, ImageDecoderCallback decode, {bool evictOnError = true}) async* { | ||||||||||||||
| if (isCancelled) { | ||||||||||||||
| this.request = null; | ||||||||||||||
| PaintingBinding.instance.imageCache.evict(this); | ||||||||||||||
|
|
@@ -57,14 +57,19 @@ mixin CancellableImageProviderMixin<T extends Object> on CancellableImageProvide | |||||||||||||
|
|
||||||||||||||
| try { | ||||||||||||||
| final image = await request.load(decode); | ||||||||||||||
| if (image == null || isCancelled) { | ||||||||||||||
| if ((image == null && evictOnError) || isCancelled) { | ||||||||||||||
| PaintingBinding.instance.imageCache.evict(this); | ||||||||||||||
| return; | ||||||||||||||
| } else if (image == null) { | ||||||||||||||
| return; | ||||||||||||||
| } | ||||||||||||||
| yield image; | ||||||||||||||
| } catch (e) { | ||||||||||||||
| PaintingBinding.instance.imageCache.evict(this); | ||||||||||||||
| rethrow; | ||||||||||||||
| } catch (e, stack) { | ||||||||||||||
| if (evictOnError) { | ||||||||||||||
| PaintingBinding.instance.imageCache.evict(this); | ||||||||||||||
| rethrow; | ||||||||||||||
| } | ||||||||||||||
| _log.warning('Non-fatal image load error', e, stack); | ||||||||||||||
|
Comment on lines
+70
to
+72
|
||||||||||||||
| rethrow; | |
| } | |
| _log.warning('Non-fatal image load error', e, stack); | |
| } | |
| _log.warning('Non-fatal image load error', e, stack); | |
| rethrow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats intended in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be logged for cancelled images? It seems potentially noisy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would only show for images that get loaded when evictOnError is false, and image is null.
This only happens in the FullImageProvider which is used for the asset view.
But you are right, we don't have to log this, as the eviction in the similar case also isn't logged.