Skip to content

[web][html]Applying ShaderMask on gradients makes the gradient not render #99045

@h65wang

Description

@h65wang

Putting a ShaderMask on a Container with some gradient decorations, works fine on mobile, desktop, and the web (when viewed from desktop Chrome and Safari) but does not work on mobile browsers.

For example, a minimal reproducible code:

ShaderMask(
  shaderCallback: (Rect bounds) {
    return LinearGradient(
      colors: [Colors.red, Colors.yellow],
    ).createShader(bounds);
  },
  child: Container(
    width: 300,
    height: 300,
    decoration: BoxDecoration(
      gradient: LinearGradient(
        colors: [Colors.grey, Colors.white],
      ),
    ),
  ),
)

When viewed everywhere else, it looks fine:

image

But when viewed from mobile, for example on Chrome on Android 12 (and also tested on iOS, same problem), it looks like this:

image

Flutter doctor:

[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[!] Android Studio - Unable to find bundled Java version.
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.64.2)
[✓] Connected device (3 available)

Metadata

Metadata

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolec: renderingUI glitches reported at the engine/skia or impeller rendering levele: web_htmlHTML rendering backend for Webengineflutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions