Skip to content

3.24.x introduced a regression in Golden Tests using a widget with a matrix perspective transform #155450

Description

@FufferKS

I'm using matrix transform to achieve a perspective view in my app. I'm also using golden tests heavily.
Upon migrating from 3.22.3 to 3.24.3, some of my goldens do not render the widgets properly anymore. The widgets render fine in the app.
One example uses an svg(I stripped this one down and attached as a code sample).
I also have issues with a png, so I don't think its svg specific.

I'm tagging @Hixie, since I've seen a couple of mentions to golden changes in release notes of 3.24, so I'm hoping you might know something.

Steps to reproduce

  • in pubspec.yaml add:
flutter:
  uses-material-design: true
  assets:
    - assets/icons/
  • in pubspec.yaml add:
    flutter_svg: ^1.1.6 dependency

  • add the svg under /assets/icons as ic_pound_sign.svg
    ic_pound_sign
    source:

<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 10.4628V12.6087H7.84923C7.86115 12.7279 7.86115 12.8471 7.86115 12.9663C7.86115 14.9215 6.88359 16.1613 5.19074 16.4355V20H18.7454V16.0898H11.1396V15.9467C12.2244 15.2314 12.5582 13.9439 12.5582 12.7518C12.5582 12.7041 12.5582 12.6564 12.5582 12.6087H17.3506V10.4628H12.1648C12.0337 9.96213 11.9144 9.49719 11.9144 9.03226C11.9144 7.64937 12.892 6.7195 15.014 6.7195C16.2539 6.7195 17.3029 6.91024 18.0659 7.24404V3.64376C17.446 3.28612 15.7532 3 14.108 3C9.60168 3 7.07433 5.16971 7.07433 8.12623C7.07433 8.92496 7.25316 9.69986 7.4439 10.4628H5Z" fill="white"/>
</svg>

  • Add a test with the attached code sample, run it with flutter test --update-goldens

Code sample

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

Future<void> main() async {
  group('Flutter Perspective in goldens regression', () {
    for (final usePerspective in [false, true]) {
      testWidgets(
        'Simple widget ${usePerspective ? 'under' : 'without'} perspective',
        (widgetTester) async {
          const topLevelKey = Key('top level key');
          await widgetTester.pumpWidget(
            Center(
              child: Container(
                key: topLevelKey,
                color: Colors.red,
                height: 50,
                width: 50,
                child: Transform(
                  transform: Matrix4.identity()
                    ..setEntry(3, 1, usePerspective ? 0.015 : 0),
                  alignment: Alignment.bottomCenter,
                  child: Container(
                    alignment: Alignment.bottomCenter,
                    child: SvgPicture.asset('assets/icons/ic_pound_sign.svg'),
                  ),
                ),
              ),
            ),
          );
          await widgetTester.pump();
          await expectLater(
            find.byKey(topLevelKey),
            matchesGoldenFile(
              'goldens/simple_widget_${usePerspective ? 'under' : 'without'}_perspective.png',
            ),
          );
        },
      );
    }
  });
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]
3.22.3:

simple_widget_under_perspective_3_22
simple_widget_without_perspective_3_22

3.24.3:

simple_widget_under_perspective_3_24
simple_widget_without_perspective_3_24

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output

3.24:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.3, on macOS 14.5 23F79 darwin-arm64, locale en-PL)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
[✓] Xcode - develop for iOS and macOS (Xcode 16.0)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Community Edition (version 2023.2.1)
[✓] VS Code (version 1.93.1)
[✓] Connected device (4 available)            
[✓] Network resources

• No issues found!

3.22:

[16](https://moneysatnav.slack.com/archives/D03C7D43F4N/p1726830992665529)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.3, on macOS 14.6.1 23G93 darwin-arm64 (Rosetta), locale en-BG)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.93.1)
[✓] Connected device (5 available)
[✓] Network resources
• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsc: regressionIt was better in the past than it is nowfound in release: 3.24Found to occur in 3.24found in release: 3.26Found to occur in 3.26frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions