Skip to content

[web] Render bounded ImageFilter.blur on wimp - #196081

Merged
auto-submit[bot] merged 7 commits into
flutter:masterfrom
harryterkelsen:implement-bounded-imagefilter-blur-in-the-web-2
Nov 12, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:masterfrom
harryterkelsen:implement-bounded-imagefilter-blur-in-the-web-2

Conversation

@harryterkelsen

Copy link
Copy Markdown
Contributor

This PR passes the bounds of ui.ImageFilter.blur through to the web renderers, so wimp (the Impeller-based variant of skwasm) renders a real bounded blur.

ImageFilter.blur(bounds: ...) enables "bounded blur": samples from outside the rectangle are treated as transparent and the result is renormalized, so nothing outside the rectangle bleeds into the blur. That is what iOS-style frosted glass needs (ImageFilterConfig.blur(bounded: true)). The previous change made the web dart:ui filter keep bounds for ==, hashCode and its description, but the value still never reached a renderer. Impeller already implements bounded blur, and wimp already ships that shader, so this PR passes the value down:

  • Renderer.createBlurImageFilter takes an optional ui.Rect? bounds, which EngineBlurImageFilter passes in.
  • Skwasm converts bounds to a native rect (or passes nullptr), and the imageFilter_createBlur export takes a new nullable const DlRect* that it forwards to DlBlurImageFilter::Make(..., bounds). This is the same pattern canvas_saveLayer uses for its optional rect.
  • Under skwasm-Skia, the same DisplayList filter goes through the shared dl_sk_conversions.cc, which ignores bounds. That matches native Skia without any web-specific code.
  • CanvasKit accepts bounds and ignores it, because its JS bindings can't express a bounded blur. A TODO links to [Web] Implement bounded blur #175899.

Part of #175899

Behavioral Changes

  • Wimp: ImageFilter.blur(..., bounds: r) now renders a bounded blur. bounds is in the canvas's local coordinate space, so it follows the current transform.
    • Before: the blur was unbounded, and content outside r bled in. With red to the left of r and blue inside it, the pixel 3px inside r read about [80, 0, 176, 255].
    • After: nothing bleeds in from outside r. The same pixel stays pure blue ([≤8, 0, ≥247, 255]).
  • CanvasKit and skwasm-Skia: no change. They still render an unbounded blur, as native Skia does.
  • All backends: unchanged for blurs without bounds, for zero-sigma blurs (still an identity filter), and for filterBounds.

Where to focus

  • Primary review files: engine/src/flutter/skwasm/filters.cc, engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/filters.dart and engine/src/flutter/lib/web_ui/test/ui/bounded_blur_test.dart.

  • Nullable rect on the existing export rather than a new one: this keeps one call site and one binding, mirroring canvas_saveLayer. When bounds is null, the path is equivalent to before, because DlImageFilter::MakeBlur already forwarded to DlBlurImageFilter::Make with std::nullopt. Make copies the DlRect into a std::optional, so no pointer into the Dart stack scope outlives the call.

  • Caching: bounds doesn't add a cache key. It is fixed for each EngineBlurImageFilter instance, and it is passed on every backend recreation, including the per-TileMode re-creation.

  • Fallback is silent on purpose: CanvasKit and skwasm-Skia fall back without warning or throwing, matching native Skia. Apps that set bounded: true for an iOS look keep working everywhere.

  • Tests: these are pixel-probe tests, not goldens. A red/blue split scene is blurred and one pixel just inside the bounds is read. A control test proves the probe can see bleed from an unbounded blur. The wimp-only tests cover:

    • no bleed
    • the canvas transform
    • ImageFilter.compose
    • reusing the filter after it backed a backdrop filter

    On the fallback backends, a test checks that the bounded blur matches the unbounded one. Zero-sigma and degenerate bounds are checked on all backends.

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.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically team-web Owned by Web platform team labels Nov 6, 2026
@harryterkelsen
harryterkelsen marked this pull request as ready for review November 11, 2026 00:19

@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 introduces support for bounded blur in the Web UI engine by adding an optional bounds parameter to the blur image filter creation methods across the CanvasKit and Skwasm renderers, as well as updating the underlying Skwasm C++ bindings. It also adds a comprehensive suite of tests to verify bounded blur behavior under different backends. The review feedback suggests a performance optimization in SkwasmBlurImageFilter to avoid allocating a StackScope when the bounds parameter is null.

@harryterkelsen harryterkelsen added the CICD Run CI/CD label Nov 11, 2026
@harryterkelsen harryterkelsen added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Nov 12, 2026
Merged via the queue into flutter:master with commit 040d429 Nov 12, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Nov 12, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 13, 2026
…13653)

Manual roll Flutter from 9c427b5d7b1c to 1b9585481095 (32 revisions)

Manual roll requested by [email protected]

flutter/flutter@9c427b5...1b95854

2026-11-13 [email protected] Roll pub packages (flutter/flutter#196541)
2026-11-13 [email protected] Do not route PRs for review without cla, convert to draft (flutter/flutter#196341)
2026-11-13 [email protected] Roll Skia from d87a6c04da74 to 11f46cfe8838 (13 revisions) (flutter/flutter#196533)
2026-11-13 [email protected] [flutter_tools, flutter_test] Deprecate --experimental-faster-testing (flutter/flutter#196123)
2026-11-13 [email protected] [flutter_tools] Handle RPCError in ScreenshotCommand.runSkia (flutter/flutter#196132)
2026-11-13 [email protected] Roll Dart SDK from a8b961fd48bb to c91e8b6674e2 (2 revisions) (flutter/flutter#196502)
2026-11-13 [email protected] Roll Skia from 0c5ce4960cef to d87a6c04da74 (12 revisions) (flutter/flutter#196497)
2026-11-13 [email protected] Don't call `skia_image()`  for raster-owned images in `DlImage::Equals` (flutter/flutter#196473)
2026-11-13 [email protected] [flutter_tools] Require FlutterCommandRunner DI fields and extract findCommandName (flutter/flutter#196331)
2026-11-13 [email protected] [web] Unify ui.Canvas behind a shared EngineCanvas frontend (flutter/flutter#196348)
2026-11-13 [email protected] Link to MediaQuery.displayFeaturesOf from DisplayFeatures (flutter/flutter#193728)
2026-11-13 [email protected] Removes reference to unnecessary ensureSemantics call in doc (flutter/flutter#195831)
2026-11-13 [email protected] [flutter_tools] Register trackWidgetCreation in AppleBuildOptionsBundle (flutter/flutter#196078)
2026-11-12 [email protected] [Android] Skip the HardwareBuffer defect fallback for platform views (flutter/flutter#193441)
2026-11-12 [email protected] Fix supports_decal check in framebuffer_blend.frag (flutter/flutter#196227)
2026-11-12 [email protected] [ios] Update the screen in didUpdateEffectiveGeometry (flutter/flutter#195508)
2026-11-12 [email protected] [flutter_tools] Add `Cache-Control` headers for web test assets (flutter/flutter#196414)
2026-11-12 [email protected] Roll Skia from 3b71ec08218f to 0c5ce4960cef (16 revisions) (flutter/flutter#196472)
2026-11-12 [email protected] [web] Render bounded ImageFilter.blur on wimp (flutter/flutter#196081)
2026-11-12 [email protected] Roll Dart SDK from 69567bd3c427 to a8b961fd48bb (2 revisions) (flutter/flutter#196464)
2026-11-12 [email protected] [engine] Release the Skia OpenGL resource context on shutdown (flutter/flutter#193592)
2026-11-12 [email protected] [web] Fix decoding of still AVIF images on Chrome (flutter/flutter#195958)
2026-11-12 [email protected] Gate SurfaceControl context setting on API 34+ (flutter/flutter#196394)
2026-11-12 [email protected] [flutter_tools] Only pass on a valid root tool in DASH__TOOL (flutter/flutter#196228)
2026-11-12 [email protected] Support GL_TEXTURE_EXTERNAL_OES embedder textures in Impeller (flutter/flutter#195857)
2026-11-12 [email protected] Stop building linux/wasm_release in local_engine_builds (flutter/flutter#196345)
2026-11-12 [email protected] Split flame out of Linux customer_testing (flutter/flutter#196347)
2026-11-12 Jiwon Lee [Windows] Fix Space input after Alt+Space with previous Microsoft IME (flutter/flutter#192105)
2026-11-12 [email protected] [flutter_tools] Add ToolExtensionException, exit() guard, graceful shutdown, and base modifiers (flutter/flutter#195908)
2026-11-12 [email protected] Roll Packages from 653628e to 14f9933 (9 revisions) (flutter/flutter#196450)
2026-11-12 [email protected] Roll Dart SDK from e5add7a25b32 to 69567bd3c427 (2 revisions) (flutter/flutter#196437)
2026-11-12 [email protected] Roll Skia from 9aa2513a4ac9 to 3b71ec08218f (1 revision) (flutter/flutter#196436)

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

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: 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.

2 participants