Skip to content

Surrounding color leaks into widgets when BackdropFilter with ImageFilter.blur is applied #99691

Closed

Description

@Ruzo

I'm having an issue with a GridView of blurred tiles using BackdropFilter with ImageFilter.blur where any surrounding color leaks into them:

imagefilter_blur_issue

ImageFilter_blur_issue_white_color

Here is a Dartpad example: https://dartpad.dev/?id=1196002918293fdd251557b037d2d786

Here is the code sample:
import 'dart:ui';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'ImageFilter Color Leak Issue',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        backgroundColor: Colors.white,
        appBar: AppBar(
          title: const Text('ImageFilter.blur Color Leak Issue'),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Expanded(
              child: Container(
                color: Colors.white,
                width: double.infinity,
                child: FittedBox(
                  fit: BoxFit.contain,
                  child: Padding(
                    padding: const EdgeInsets.all(40),
                    child: Container(
                      width: 400,
                      height: 400,
                      color: const Color(0xFF0000FF),
                      child: GridView.count(
                        padding: EdgeInsets.zero,
                        shrinkWrap: true,
                        physics: const NeverScrollableScrollPhysics(),
                        crossAxisCount: 3,
                        children: tiles(),
                      ),
                    ),
                  ),
                ),
              ),
            ),
            Expanded(
              child: Container(
                color: Colors.black,
                width: double.infinity,
                child: FittedBox(
                  fit: BoxFit.contain,
                  child: Padding(
                    padding: const EdgeInsets.all(40),
                    child: Container(
                      width: 400,
                      height: 400,
                      color: const Color(0xFF0000FF),
                      child: GridView.count(
                        padding: EdgeInsets.zero,
                        shrinkWrap: true,
                        physics: const NeverScrollableScrollPhysics(),
                        crossAxisCount: 3,
                        children: tiles(),
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  List<Widget> tiles() => List<Widget>.generate(
        9,
        (_) => ClipRRect(
          child: BackdropFilter(
            filter: ImageFilter.blur(
              sigmaX: 20,
              sigmaY: 20,
            ),
            child: Container(
              decoration: BoxDecoration(
                color: Colors.white.withOpacity(0.2),
                borderRadius: BorderRadius.circular(12),
              ),
            ),
          ),
        ),
      );
    }
flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.3, on macOS 11.5.1 20G80 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.66.0-insider)
[✓] Connected device (1 available)
    ! Device emulator-5562 is offline.
[✓] HTTP Host Availability

• No issues found!

Activity

  1. darshankawar commented on Mar 8, 2022

    @darshankawar
    Member

    @Ruzo
    From the attached link, can you try the workarounds mentioned as below and see if it helps ?

    As a suggestion for a workaround, you can try playing with the TileMode in the ImageFilter constructor to see if you can minimize the issue. I'm guessing "mirror" might help as that will reflect some of the other pixels near the edge into the "off-edge" samples that get used. Another option would be to play with the blend mode of the BackdropFilter. It is currently defaulted to "SrcOver" which blends the fading white at the edge of the blurred background with the implicit black of the background and results in the "fade to black" you see. Perhaps using "Src" instead might fill it with "faded white" instead of a blend of that over black and you might get white, but that depends on how it interprets storing a non-opaque color into a framebuffer that has no alpha.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 8, 2022
  3. Ruzo commented on Mar 8, 2022

    @Ruzo
    Author

    @darshankawar Thanks for the reply. I've tried these workarounds (again) but nothing works. None of them made a difference.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 8, 2022
  5. darshankawar commented on Mar 9, 2022

    @darshankawar
    Member

    Thanks for the update. I do see the same behavior upon running the code sample using latest stable and master. Also, the workarounds mentioned in the related issue doesn't have any effect.

    stable, master flutter doctor -v
    
    [✓] Flutter (Channel stable, 2.10.3, on macOS 12.2.1 21D62 darwin-x64, locale
        en-GB)
        • Flutter version 2.10.3 at /Users/dhs/documents/fluttersdk/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 7e9793dee1 (11 hours ago), 2022-03-02 11:23:12 -0600
        • Engine revision bd539267b4
        • Dart version 2.16.1
        • DevTools version 2.9.2
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    [✓] Flutter (Channel master, 2.11.0-0.0.pre.831, on macOS 12.2.1 21D62
        darwin-x64, locale en-GB)
        • Flutter version 2.11.0-0.0.pre.831 at
          /Users/dhs/documents/fluttersdk/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 3172065fba (3 hours ago), 2022-03-08 19:35:20 -0600
        • Engine revision 5c760759fe
        • Dart version 2.17.0 (build 2.17.0-182.0.dev)
        • DevTools version 2.11.1
    
    [!] Xcode - develop for iOS and macOS (Xcode 12.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        ! Flutter recommends a minimum Xcode version of 13.
          Download the latest version or update via the Mac App Store.
        • CocoaPods version 1.11.2
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] VS Code (version 1.62.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.21.0
    
    [✓] Connected device (5 available)
        • SM G975F (mobile)       • RZ8M802WY0X • android-arm64   • Android 11 (API 30)
        • Darshan's iphone (mobile)  • 21150b119064aecc249dfcfe05e259197461ce23 •
          ios            • iOS 14.4.1 18D61
        • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729     •
          ios            • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
        • macOS (desktop)            • macos                                    •
          darwin-x64     • Mac OS X 10.15.4 19E2269 darwin-x64
        • Chrome (web)               • chrome                                   •
          web-javascript • Google Chrome 98.0.4758.80
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    ! Doctor found issues in 1 category.
    
    
    
  6. added
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    engineflutter/engine related. See also e: labels.
    and removed
    in triagePresently being triaged by the triage team
    on Mar 9, 2022
  7. zanderso commented on Mar 14, 2022

    @zanderso
    Member

    @flar Is this working as documented? It makes sense that the fragment at the edge needs to sample from nearby fragments already in the framebuffer, right?

  8. added
    P2Important issues not at the top of the work list
    on Mar 14, 2022
  9. 23 remaining items

  10. knopp commented on Nov 1, 2024

    @knopp
    Member

    I think part of the issue is that tile mode in Flutter applies to edge of texture being sampled from as opposed other blur implementations where tile mode is applied to pixels sampled anywhere outside of blur area. It would probably help if the tile mode was applied to pixels sampled from outside of the blur clip instead.

  11. dkwingsmt commented on May 16, 2025

    @dkwingsmt
    Contributor

    I think this is the same issue as #164267. I investigated the issue and found a matching algorithm, which I've recorded under #164267. I'm planning to work on it, although I have to finish what I have on hand now.

    Edit, to provide more context: There are some structural obstacles for this problem. Simply put, the engine uses a shader that blurs the entire surface altogether (with some masks for performance), meaning that the shader only takes a sigma as the parameter, while this new algorithm at least needs another rectangle parameter (if we simplify the support to only rectangular areas instead of arbitrary masks). Since the current shader algorithm lacks information, merely switching between current TileMode values is not sufficient.

    Also of course the shader will need an additional variable to track alpha.

  12. Ruzo commented on Jun 11, 2025

    @Ruzo
    Author

    I think this is the same issue as #164267. I investigated the issue and found a matching algorithm, which I've recorded under #164267. I'm planning to work on it, although I have to finish what I have on hand now.

    Edit, to provide more context: There are some structural obstacles for this problem. Simply put, the engine uses a shader that blurs the entire surface altogether (with some masks for performance), meaning that the shader only takes a sigma as the parameter, while this new algorithm at least needs another rectangle parameter (if we simplify the support to only rectangular areas instead of arbitrary masks). Since the current shader algorithm lacks information, merely switching between current TileMode values is not sufficient.

    Also of course the shader will need an additional variable to track alpha.

    That's great to hear!

    I'm thinking that Apple's new Liquid Glass will bring new focus on this issue.

  13. dkwingsmt commented on Jun 11, 2025

    @dkwingsmt
    Contributor

    Definitely. Just for the record, yes the Liquid Glass should not invalidate it at all, since Liquid Glass also involves blurring.

  14. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jan 5, 2026
  15. github-actions commented on Jan 19, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  16. locked as resolved and limited conversation to collaborators on Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listcustomer: silverengineflutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10found in release: 2.11Found to occur in 2.11frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagesr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions