Skip to content

Windows Android emulator performances drop when using a foregroundDecoration BlendMode.saturation #169263

@EArminjon

Description

@EArminjon

Steps to reproduce

  1. Run app
  2. Click on Image tab
  3. Image tab load fast
  4. Click on Home tab
  5. Enable the saturation
  6. Click on Image tab
  7. Image tab is very slow , 5 secondes to load !

Expected results

Image tab should load fast.

Actual results

Android emulator on Windows load very slowly.
Android emulator on MacOS load fast, no issue.

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData.light(),
      scrollBehavior: const MaterialScrollBehavior().copyWith(
        overscroll: false,
      ),
      home: const HomePage(),
    ),
  );
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int selected = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: NavigationBar(
        selectedIndex: selected,
        onDestinationSelected: (int index) {
          setState(() => selected = index);
        },
        destinations: <Widget>[
          const NavigationDestination(
            icon: Icon(Icons.home_outlined),
            selectedIcon: Icon(Icons.home),
            label: 'Home',
          ),
          const NavigationDestination(
            icon: Icon(Icons.image_outlined),
            selectedIcon: Icon(Icons.image),
            label: 'Image',
          ),
        ],
      ),
      body: PopScope(
        canPop: selected == 0,
        onPopInvokedWithResult: (bool didPop, _) {
          if (didPop) return;
          setState(() => selected = 0);
        },
        child: IndexedStack(
          index: selected,
          children: <Widget>[const HomeTab(), const ImagesTab()],
        ),
      ),
    );
  }
}

class HomeTab extends StatelessWidget {
  const HomeTab({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Home tab')),
      body: ValueListenableBuilder<bool>(
        valueListenable: saturationNotifier,
        builder: (BuildContext context, bool enabled, _) => Center(
          child: Padding(
            padding: const EdgeInsets.all(16),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: <Widget>[
                const Text(
                  'When you enable the saturation, the Android Emulator on Windows became very laggy.',
                ),
                const SizedBox(height: 16),
                SwitchListTile(
                  contentPadding: EdgeInsets.zero,
                  title: const Text('Enable the saturation'),
                  value: enabled,
                  onChanged: (bool value) => saturationNotifier.value = value,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}

final ValueNotifier<bool> saturationNotifier = ValueNotifier<bool>(false);

class ImagesTab extends StatelessWidget {
  const ImagesTab({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Home tab')),
      body: ValueListenableBuilder<bool>(
        valueListenable: saturationNotifier,
        builder: (BuildContext context, bool enabled, _) => ListView.separated(
          padding: const EdgeInsets.all(16),
          itemCount: 100,
          separatorBuilder: (BuildContext context, int index) =>
              const SizedBox(height: 16),
          itemBuilder: (BuildContext context, int index) =>
              ImageListTile(title: 'Image $index', enabled: enabled),
        ),
      ),
    );
  }
}

class ImageListTile extends StatelessWidget {
  const ImageListTile({required this.title, required this.enabled, super.key});

  final String title;
  final bool enabled;

  @override
  Widget build(BuildContext context) {
    return Card(
      clipBehavior: Clip.hardEdge,
      margin: EdgeInsets.zero,
      child: Container(
        foregroundDecoration: enabled
            ? const BoxDecoration(
                color: Colors.grey,
                backgroundBlendMode: BlendMode.saturation,
              )
            : null,
        child: ListTile(
          onTap: () {},
          contentPadding: const EdgeInsets.only(right: 8),
          leading: SizedBox(
            height: double.maxFinite,
            width: 80,
            child: Image.network(
              'https://www.francebleu.fr/s3/cruiser-production-eu3/2025/05/a9b4cbd3-6f6a-4338-9e52-f68a934ea8c9/1200x680_sc_250515-fich-diff-lapin-belier-robert-reader-getty.jpg',
              fit: BoxFit.cover,
            ),
          ),
          title: Text(title),
          trailing: const Icon(Icons.add),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen_recording_20250522_120255.webm

Logs

Logs

No logs

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.32.0, on Microsoft Windows [version 10.0.22631.5039], locale fr-FR) [598ms]
    • Flutter version 3.32.0 on channel stable at C:\Users\engue\fvm\versions\3.32.0
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision be698c48a6 (3 days ago), 2025-05-19 12:59:14 -0700
    • Engine revision 1881800949
    • Dart version 3.8.0
    • DevTools version 2.45.1

[√] Windows Version (11 Professionnel 64-bit, 23H2, 2009) [4,3s]

[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2,8s]
    • Android SDK at D:\Android
    • Platform android-35, build-tools 35.0.0
    • Java binary at: C:\Users\engue\.jdks\corretto-17.0.13\bin\java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Corretto-17.0.13.11.1 (build 17.0.13+11-LTS)
    • All Android licenses accepted.

[√] Chrome - develop for the web [264ms]
    • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2019 16.11.45) [263ms]
    • Visual Studio at D:\dev
    • Visual Studio Community 2019 version 16.11.35826.135
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2024.3.2) [182ms]
    • Android Studio at C:\Users\engue\AppData\Local\Programs\Android Studio
    • 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 21.0.6+-13368085-b895.109)

[√] IntelliJ IDEA Ultimate Edition (version 2025.1) [180ms]
    • IntelliJ at C:\Users\engue\AppData\Local\Programs\IntelliJ IDEA Ultimate
    • Flutter plugin version 85.3.2
    • Dart plugin version 251.25410.28

[√] Connected device (4 available) [408ms]
    • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64    • Android 15 (API 35) (emulator)
    • Windows (desktop)            • windows       • windows-x64    • Microsoft Windows [version 10.0.22631.5039]
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 136.0.7103.114
    • Edge (web)                   • edge          • web-javascript • Microsoft Edge 135.0.3179.98

[√] Network resources [459ms]
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: performanceRelates to speed or footprint issues (see "perf:" labels)engineflutter/engine repository. See also e: labels.platform-windowsBuilding on or for Windows specificallyteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions