Skip to content

[Impeller] Stack + Positioned + Transform with FilterQuality clips the widget. #131182

@AlessandroToschi

Description

@AlessandroToschi

Is there an existing issue for this?

Steps to reproduce

The following hierarchy clips the child when rotated using the Impeller renderer:
Stack --> Positioned --> Transform.rotate with FilterQuality --> Solid Color Container

Stack(
  fit: StackFit.expand,
  children: [
    Positioned.fromRect(
      rect: Rect.fromLTWH(0.0, 0.0, 500.0, 500.0),
      child: Transform.rotate(
        angle: 0.4,
        filterQuality: FilterQuality.low,
        child: Container(color: Colors.green),
      ),
    ),

Expected results

The solid color container should not be clipped.

Actual results

The solid color container is clipped.

This affects only the Impeller renderer and not the Skia one.
Removing the FilterQuality solves the issue.

Code sample

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  double _rotation = 0.0;

  static const _width = 500.0;
  static const _height = 500.0;

  static const _sliderBottom = 48.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: LayoutBuilder(
        builder: (context, constraints) {
          final x = (constraints.maxWidth - _width) / 2.0;
          final y = (constraints.maxHeight - _sliderBottom - _height) / 2.0;
          return Stack(
            fit: StackFit.expand,
            children: [
              Positioned.fromRect(
                rect: Rect.fromLTWH(x, y, _width, _height),
                child: Transform.rotate(
                  angle: _rotation,
                  filterQuality: FilterQuality.low,
                  child: Container(color: Colors.green),
                ),
              ),
              Positioned(
                left: 0.0,
                right: 0.0,
                bottom: _sliderBottom,
                child: Slider(
                  value: _rotation,
                  min: 0.0,
                  max: math.pi * 2.0,
                  onChanged: (rotation) => setState(
                    () => _rotation = rotation,
                  ),
                ),
              )
            ],
          );
        },
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Impeller

IMG_4065

Skia

IMG_4064

Flutter Doctor output

Doctor output
[!] Flutter (Channel unknown, 3.10.6, on macOS 12.6 21G115 darwin-arm64, locale en-US)
    ! Flutter version 3.10.6
    • Framework revision 3d8478a247 (2 hours ago), 2023-07-24 10:12:39 +0200
    • Engine revision 6f8ff0e653
    • Dart version 3.0.6
    • DevTools version 2.23.1
    • Flutter download mirror https://storage.googleapis.com/clay-flutter-storage
    • 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.1.0-rc1)
    • Android SDK at /Users/aleto/Library/Android/sdk
    • Platform android-33, build-tools 32.1.0-rc1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode142.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

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

[✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.3.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 72.1.4
    • Dart plugin version 223.8214.16

[✓] VS Code (version 1.80.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

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

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.10Found to occur in 3.10found in release: 3.13Found to occur in 3.13has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions