Skip to content

Adds debugLabel for the image stream completer - #984

Merged
rickdijk merged 5 commits into
Baseflow:mainfrom
AlexV525:feat/debug-label
Sep 29, 2026
Merged

rickdijk merged 5 commits into
Baseflow:mainfrom
AlexV525:feat/debug-label

Conversation

@AlexV525

@AlexV525 AlexV525 commented Nov 3, 2024 •

Copy link
Copy Markdown
Contributor

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

This is a bug fix. Fixes #973

This also helps to display the info in the Flutter Inspector.

As a reference, this is how the MultiFrameImageStreamCompleter implements the debugLevel.
https://github.com/flutter/flutter/blob/574b7e765d86f3f70eac8817a2906ac3099c0bf9/packages/flutter/lib/src/painting/image_stream.dart#L967

⤵️ What is the current behavior?

======== Exception caught by painting library ======================================================
The following message was thrown while painting an image:
Image null has a display size of 794×529 but a decode size of 1956×1280, which uses an additional 10849KB (assuming a device pixel ratio of 2.625).

Consider resizing the asset ahead of time, supplying a cacheWidth parameter of 794, a cacheHeight parameter of 529, or using a ResizeImage.

🆕 What is the new behavior (if this is a feature change)?

======== Exception caught by painting library ======================================================
The following message was thrown while painting an image:
Image https://example.com/redact.jpeg has a display size of 794×529 but a decode size of 1956×1280, which uses an additional 10849KB (assuming a device pixel ratio of 2.625).

Consider resizing the asset ahead of time, supplying a cacheWidth parameter of 794, a cacheHeight parameter of 529, or using a ResizeImage.

💥 Does this PR introduce a breaking change?

No.

@rickdijk

Copy link
Copy Markdown
Collaborator

This repository now uses main as its only branch, so I have retargeted this PR from develop to main. Nothing about the review changes. If GitHub now shows a conflict, a rebase onto main will clear it, and we will follow up on that separately.

@rickdijk
rickdijk changed the base branch from develop to main September 23, 2026 17:50
@AlexV525

Copy link
Copy Markdown
Contributor Author

@rickdijk PTAL

@rickdijk rickdijk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, here's a few comments:

  • adhere to contributing guidelines by adding a CHANGELOG entry as well as a version bump in pubspec.yaml
  • Not a blocker, but nice to have and easy to write: please add a test. Something like: build a MultiImageStreamCompleter with a label and check that ImageInfo.debugLabel matches

@AlexV525

AlexV525 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor Author

@rickdijk Addressed in a04c3d6, with the branch rebased onto main. PTAL.

  • CHANGELOG.md and pubspec.yaml: entry added and version bumped to 4.0.3 — 4.0.2 is already tagged on main, so this fix rides the next patch.
  • Tests added:
    • test/image_stream_completer_test.dart: a MultiImageStreamCompleter built with a debugLabel emits ImageInfos whose debugLabel matches, covering both the static-image and the animated-image emit paths.
    • test/image_provider_test.dart: resolving a CachedNetworkImageProvider emits an ImageInfo whose debugLabel is the URL, which is the behavior from the issue report.

All three tests fail without the fix and pass with it. From cached_network_image/: dart format --set-exit-if-changed ., flutter analyze and flutter test (40 tests) are green.

@rickdijk rickdijk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply the change and this PR is approved when it completes CI

Comment thread cached_network_image/test/image_provider_test.dart Outdated
Co-authored-by: Rick van Dijk <rickavdijk@gmail.com>
@AlexV525

Copy link
Copy Markdown
Contributor Author

@rickdijk Thanks. CI is green so I've applied the suggestion.

@rickdijk
rickdijk merged commit 71a1e1b into Baseflow:main Sep 29, 2026
10 checks passed
@rickdijk rickdijk mentioned this pull request Sep 29, 2026
4 tasks done
@AlexV525
AlexV525 deleted the feat/debug-label branch September 29, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the ability to set debugLabel

2 participants