Skip to content

[Impeller] Text with shadows decreases performance when using Impeller #165116

@RocksteadyDog

Description

@RocksteadyDog

Steps to reproduce

  1. Run the example (I tested on pixel 6, honor x8b, realme c30, huawei matepad 11.5), debug/release not important
  2. Will scroll through the list, everything is nice and smooth
  3. Bring back the shadow in the sample -
    shadows: [
    Shadow(
    blurRadius: 8.0,
    color: Colors.black.withValues(alpha: 0.24),
    offset: Offset(2.0, 2.0),
    ),
    ],
  4. Scroll through the list, noticeable performance degradation
  5. Run the example with - flutter run --no-enable-impeller
  6. Everything is fine and smooth when text is shadowed

Code sample

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

void main() async {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Test',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(
          seedColor: Color(0xff6750a4),
          brightness: Brightness.light,
          dynamicSchemeVariant: DynamicSchemeVariant.tonalSpot,
        ),

        useMaterial3: true,
      ),

      debugShowCheckedModeBanner: false,
      home: const MainScreen(),
    );
  }
}

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

  @override
  State<MainScreen> createState() => _MainScreenState();
}

class _MainScreenState extends State<MainScreen> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Main', style: TextStyle(fontWeight: FontWeight.bold)),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [const TestListView(), const SizedBox(height: 8)],
        ),
      ),
    );
  }
}

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

  @override
  State<TestListView> createState() => _TestListViewState();
}

class _TestListViewState extends State<TestListView> {
  final PageController _pageController = PageController(initialPage: 0);

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    _pageController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        GridView.builder(
          itemCount: 64,
          shrinkWrap: true,
          physics: const NeverScrollableScrollPhysics(),
          padding: EdgeInsets.symmetric(horizontal: 8.0),
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2,
            crossAxisSpacing: 12.0,
            mainAxisSpacing: 12.0,
            childAspectRatio: 1.0,
          ),
          itemBuilder: (context, index) {
            return Card(
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(16.0),
              ),
              clipBehavior: Clip.antiAlias,
              child: Stack(
                fit: StackFit.expand,
                children: [
                  Image.asset('assets/images/kitty.jpeg', fit: BoxFit.cover),
                  Padding(
                    padding: const EdgeInsets.all(18.0),
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisSize: MainAxisSize.max,
                      children: [
                        Expanded(
                          child: Text(
                            'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
                            overflow: TextOverflow.fade,
                            style: Theme.of(
                              context,
                            ).textTheme.titleLarge?.copyWith(
                              color: Colors.white,
                              fontWeight: FontWeight.bold,
                              // shadows: [
                              //   Shadow(
                              //     blurRadius: 8.0,
                              //     color: Colors.black.withValues(alpha: 0.24),
                              //     offset: Offset(2.0, 2.0),
                              //   ),
                              // ],
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            );
          },
        ),
      ],
    );
  }
}

What target platforms are you seeing this bug on?

Android

OS/Browser name and version | Device information

pixel 6
honor x8b
realme c30
huawei matepad 11.5

Does the problem occur on emulator/simulator as well as on physical devices?

Yes

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.1, on macOS 15.3.1 24D70 darwin-arm64, locale ru-RU) [1 296ms]
    • Flutter version 3.29.1 on channel stable at /Users/denis/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 09de023485 (13 days ago), 2025-02-28 13:44:05 -0800
    • Engine revision 871f65ac1b
    • Dart version 3.7.0
    • DevTools version 2.42.2

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [7,9s]
    • Android SDK at /Users/denis/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [2,4s]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [15ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [14ms]
    • 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 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.98.1) [13ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.106.0

[✓] Connected device (6 available) [7,8s]
    • Pixel 6 (mobile)                   • 26101FDF60002Q            • android-arm64  • Android 15 (API 35)
    • iPad (Денис) (wireless) (mobile)   • 00008030-001600623E22202E • ios            • iOS 18.3.1 22D72
    • iPhone (Денис) (wireless) (mobile) • 00008101-001564E21861401E • ios            • iOS 18.3.1 22D72
    • macOS (desktop)                    • macos                     • darwin-arm64   • macOS 15.3.1 24D70 darwin-arm64
    • Mac Designed for iPad (desktop)    • mac-designed-for-ipad     • darwin         • macOS 15.3.1 24D70 darwin-arm64
    • Chrome (web)                       • chrome                    • web-javascript • Google Chrome 134.0.6998.89

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

Screenshots

Screenshots

Impeller-Shadows
Image
Impeller-Without Shadows
Image
Without Impeller-Shadows
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: performanceRelates to speed or footprint issues (see "perf:" labels)e: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30from: performance templateIssues created via a performance issue templatehas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-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