Skip to content

[Impeller] BlendMode issue due to bad interaction between MaskFilter and the FramebufferBlendContents. #134930

@zhxst

Description

@zhxst

Is there an existing issue for this?

Steps to reproduce

Run the sample code on iOS.
The bug is Impeller only. It's fine with skia (android).

I've tested it on 3.13.4 and 3.15.0-15.1.pre (beta) and 3.14.0-14.0.pre.337 (master).

Expected results

A green circle with blur like style on the screen.

Actual results

The circle is blurred but not green.

Code sample

Code sample

main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SizedBox(
          height: double.infinity,
          width: double.infinity,
          child: CustomPaint(
            painter: BubbleLayerPainter(),
          ),
        ),
      ),
    );
  }
}

class BubbleLayerPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final colorBlur = Paint()
      ..style = PaintingStyle.fill
      ..maskFilter = const MaskFilter.blur(BlurStyle.normal, 60)
      ..color = Colors.black;

    final center = size.center(Offset.zero);
    canvas.drawCircle(center, 110, colorBlur);

    canvas.drawColor(Colors.grey.withAlpha(255), BlendMode.colorDodge);
    final surface = Paint()
      ..blendMode = BlendMode.screen
      ..color = Colors.green;
    canvas.drawPaint(surface);
  }

  @override
  bool shouldRepaint(BubbleLayerPainter oldDelegate) {
    return true;
  }
}

Screenshots or Video

Screenshots / Video demonstration
result on iOS (grey) result on Android (green)

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Warning is about muti version with fvm.

Doctor output
[!] Flutter (Channel stable, 3.13.4, on macOS 13.4.1 22F770820d darwin-arm64,
    locale zh-Hans-CN)
    • Flutter version 3.13.4 on channel stable at /Users/zhx/fvm/versions/stable
    • Framework revision 367f9ea16b (5 days ago), 2023-09-12 23:27:53 -0500
    • Engine revision 9064459a8b
    • Dart version 3.1.2
    • DevTools version 2.25.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/zhx/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode_14.3.1.app/Contents/Developer
    • Build 14E300c
    • CocoaPods version 1.12.1

[✓] Android Studio (version 2022.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.6+0-17.0.6b802.4-9586694)

[✓] VS Code (version 1.82.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.73.20230904

[✓] Connected device (1 available)
    • macOS (desktop) • macos • darwin-arm64 • macOS 13.4.1 22F770820d
      darwin-arm64

[✓] Network resources
    • All expected network resources are available.

</details>

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: renderingUI glitches reported at the engine/skia or impeller rendering levele: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions