Skip to content

[web] Honor requested upscaling in instantiateImageCodecWithSize and ImageDescriptor.instantiateCodec - #195836

Merged
auto-submit[bot] merged 5 commits into
flutter:masterfrom
harryterkelsen:honor-resizeimage-allowupscaling-in-web
Nov 3, 2026
Merged

auto-submit[bot] merged 5 commits into
flutter:masterfrom
harryterkelsen:honor-resizeimage-allowupscaling-in-web

Conversation

@harryterkelsen

Copy link
Copy Markdown
Contributor

On the web, instantiateImageCodecWithSize and ImageDescriptor.instantiateCodec (encoded path) forwarded to the codec with a hardcoded allowUpscaling: false. Any requested target size larger than the intrinsic size was silently clamped back down, so ResizeImage(allowUpscaling: true) could never upscale on web.

This PR removes the hardcoded flag so both entry points decode to the size the caller asked for, matching native dart:ui. The upscaling policy already lives in the framework: ResizeImage's getTargetSize clamps to the intrinsic size when its own allowUpscaling is false, so that case behaves exactly as before.

Changes:

  • engine/src/flutter/lib/web_ui/lib/painting.dart: drop allowUpscaling: false in instantiateImageCodecWithSize and in the encoded branch of ImageDescriptor.instantiateCodec. Every callee defaults to allowUpscaling: true, so this enables upscaling uniformly across the ImageDecoder, createImageBitmap, and Skia fallback paths.
  • engine/src/flutter/lib/web_ui/test/ui/image_test.dart: new tests that decode a 10x10 image to larger sizes through both entry points, including non-square, mixed up/down, and width-only (aspect-preserving) targets. The existing Image.onCreate/onDispose hook resets now use addTearDown, so a failing assertion can't leak hooks into later tests.
  • packages/flutter/test/painting/image_provider_resize_image_test.dart: remove skip: isBrowser from group('resizing'). Its 43 tests now run on web and pass on CanvasKit and Skwasm.

Fixes #195193

Where to focus

  • Key decision: honor the caller's size instead of adding a web-only knob. The public dart:ui signatures are unchanged. The web engine now trusts the target size it is given, as native does, rather than applying a second, stricter upscaling policy underneath the framework's.
  • Non-obvious: the argument is removed, not set to true. true is already the default at every hop (engineInstantiateImageCodec → browser/static/Skia codecs → scaleImageIfNeeded), and writing it explicitly trips avoid_redundant_argument_values.
  • Non-obvious: the old clamp wasn't applied evenly. The Skwasm Skia fallback already resized natively and ignored the flag. After this change, every decode path behaves the same.
  • Primary review file: engine/src/flutter/lib/web_ui/lib/painting.dart (two call sites). Then engine/src/flutter/lib/web_ui/test/ui/image_test.dart.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@harryterkelsen harryterkelsen added a: images Loading, displaying, rendering images team-web Owned by Web platform team CICD Run CI/CD labels Nov 2, 2026
@harryterkelsen
harryterkelsen marked this pull request as ready for review November 2, 2026 21:58

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request enables image upscaling in the web UI by removing the allowUpscaling: false constraint from instantiateImageCodecWithSize and ImageDescriptor.instantiateCodec. It adds unit tests to verify upscaling behavior, utilizes addTearDown for test state cleanup, and enables a previously skipped test on the browser. The review feedback points out that several new tests fail to dispose of the created imageBuffer instances, which can lead to memory leaks.

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. platform-web Web applications specifically labels Nov 2, 2026

@mdebbar mdebbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 3, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 3, 2026
Merged via the queue into flutter:master with commit e516485 Nov 3, 2026
40 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 3, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 3, 2026
Roll Flutter from fcfb4f203eae to 934720261be0 (38 revisions)

flutter/flutter@fcfb4f2...9347202

2026-11-03 [email protected] Roll Skia from 5bceaa033999 to c733ad3e37cb (5 revisions) (flutter/flutter#195872)
2026-11-03 [email protected] Roll Skia from 34d2bf479385 to 5bceaa033999 (9 revisions) (flutter/flutter#195864)
2026-11-03 [email protected] fix: prefer pointer events over semantics tap for mouse clicks on web (flutter/flutter#191529)
2026-11-03 [email protected] [VPAT] Expose a semantics text field value while it is not being edited (flutter/flutter#195445)
2026-11-03 [email protected] [Impeller] Make a GL context current before constructing an AiksContext without a surface (flutter/flutter#195629)
2026-11-03 [email protected] [flutter_tools] Eliminate globals.dart from project.dart (flutter/flutter#194066)
2026-11-03 [email protected] [tool] Complete context runner elimination and migrate AppContext usages to ToolContext (flutter/flutter#190797)
2026-11-03 [email protected] [web] Unify font collections between CanvasKit and Skwasm (flutter/flutter#195539)
2026-11-03 [email protected] [Android] Replay predictive back state for retained engines (flutter/flutter#192286)
2026-11-03 [email protected] [vulkan]: Adds depth/stencil synchronization for subpasses (flutter/flutter#195689)
2026-11-03 [email protected] [web] Honor requested upscaling in instantiateImageCodecWithSize and ImageDescriptor.instantiateCodec (flutter/flutter#195836)
2026-11-03 [email protected] Roll Skia from 866b61ca92c9 to 34d2bf479385 (9 revisions) (flutter/flutter#195848)
2026-11-03 [email protected] Roll Fuchsia Test Scripts from xl1LWBuppzu-BnOzV... to B6zarykZp6PKWRueg... (flutter/flutter#195847)
2026-11-03 [email protected] Remove unused ffi (flutter/flutter#195710)
2026-11-02 [email protected] Revert: [Android] Let the raster thread use every core of a chip without little cores (flutter/flutter#195838)
2026-11-02 [email protected] Run 10 impeller iOS benchmarks as one devicelab task (flutter/flutter#195661)
2026-11-02 [email protected] Use named uniforms instead of setFloat in StretchEffect (flutter/flutter#195372)
2026-11-02 [email protected] [flutter_tools] Report when the browser disconnects during a web test run (flutter/flutter#192198)
2026-11-02 [email protected] fix: Resolve memory leak in image_list example (flutter/flutter#189526)
2026-11-02 [email protected] Only run the common local engine configurations in presubmit (flutter/flutter#195688)
2026-11-02 [email protected] Update gcloud_version to version [email protected] (flutter/flutter#195769)
2026-11-02 [email protected] [Impeller] Order the Vulkan copy-texture-to-texture layout transition after the copy (flutter/flutter#195814)
2026-11-02 [email protected] [Impeller] Order the Vulkan ResizeTexture layout transition after its blit (flutter/flutter#195721)
2026-11-02 [email protected] [web] Fix CanvasKit fragment shader uniforms being freed or mutated after recording (flutter/flutter#195718)
2026-11-02 [email protected] Roll Fuchsia Linux SDK from MqypI6RNyVZ_FLUE-... to T_-6-6X1lDMghhAvX... (flutter/flutter#195809)
2026-11-02 [email protected] [Android] Log why Impeller falls back to OpenGLES (flutter/flutter#194764)
2026-11-02 [email protected] Roll Skia from 3f35fb6e591b to 866b61ca92c9 (11 revisions) (flutter/flutter#195802)
2026-11-02 [email protected] Roll Skia from 3f35fb6e591b to 866b61ca92c9 (11 revisions) (flutter/flutter#195802)
2026-11-02 [email protected] Only run the common local engine configurations in presubmit (flutter/flutter#195688)
2026-11-02 [email protected] Balance tool_integration_tests subshards by expected duration (flutter/flutter#195628)
2026-11-02 [email protected] [web_paragraph] Map code units without a cluster to a cluster (flutter/flutter#195384)
2026-11-02 [email protected] [web] Hide synthetic autofill inputs from assistive technology (flutter/flutter#195618)
2026-11-02 [email protected] Roll Packages from 3742a4e to 3f34a6f (8 revisions) (flutter/flutter#195795)
2026-11-02 [email protected] [web] Unskip web tests that pass on CanvasKit and Skwasm: platform_view_test, route_notification_messages_test (flutter/flutter#195605)
2026-11-02 [email protected] Roll Skia from e5ad3868b8db to 3f35fb6e591b (1 revision) (flutter/flutter#195789)
2026-11-02 [email protected] Roll Skia from f5215e74aa16 to e5ad3868b8db (3 revisions) (flutter/flutter#195779)
2026-11-02 [email protected] Roll Skia from e43478a2f9f8 to f5215e74aa16 (1 revision) (flutter/flutter#195776)
2026-11-01 [email protected] Roll Fuchsia Linux SDK from kW0A0xxNkqf38ljm4... to MqypI6RNyVZ_FLUE-... (flutter/flutter#195768)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: images Loading, displaying, rendering images CICD Run CI/CD engine flutter/engine related. See also e: labels. framework flutter/packages/flutter repository. See also f: labels. platform-web Web applications specifically team-web Owned by Web platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[web] instantiateImageCodecWithSize hardcodes allowUpscaling: false, breaking ResizeImage(allowUpscaling: true)

2 participants