Skip to content

[Impeller] Image displayed upside down on Xiaomi devices (Redmi 14C) in PageView #177317

@mishaqq

Description

@mishaqq

Steps to reproduce

  1. Check if Impeller is enabled (no <meta-data android:name="io.flutter.embedding.android.EnableImpeller" android:value="false" /> in AndroidManifest.xml)

  2. Run the app in release or debug mode on a Xiaomi device.

  3. You should see the image in the middle with the wrong orientation.

note you should use Flutter 3.29+ (impeller enabled automatically)

Expected results

All images in the PageView should be oriented as in the original image files.

Actual results

The image in the middle is oriented upside down.

Code sample

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

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

class MainCharacter {
  final String id;
  final String imageUrl;

  MainCharacter({required this.id, required this.imageUrl});
}

final List<MainCharacter> characterList = [
  MainCharacter(
    id: 'character1',
    imageUrl: 'assets/characters/0character1.png',
  ),
  MainCharacter(
    id: 'character3',
    imageUrl: 'assets/characters/0character3.png',
  ),
  MainCharacter(
    id: 'character4',
    imageUrl: 'assets/characters/0character4.png',
  ),
];

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Bug Code Snipet',
      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> {
  late PageController _carouselController;
  @override
  void initState() {
    _carouselController = PageController(viewportFraction: 0.5, initialPage: 2);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CharacterCarousel(
        carouselController: _carouselController,
      ),
    );
  }
}

///
/// Carousel
///
class CharacterCarousel extends StatefulWidget {
  final PageController carouselController;

  const CharacterCarousel({super.key, required this.carouselController});

  @override
  _CharacterCarouselState createState() => _CharacterCarouselState();
}

class _CharacterCarouselState extends State<CharacterCarousel> {
  late final PageController _controller;

  late final List<String> images;
  @override
  void initState() {
    super.initState();
    images = [
      characterList[characterList.length - 2].imageUrl,
      characterList.last.imageUrl,
      ...characterList.map((character) => character.imageUrl),
      characterList.first.imageUrl,
      characterList[1].imageUrl,
    ];

    _controller = widget.carouselController;

    _controller.addListener(() {
      final page = _controller.page;
      if (!_controller.hasClients || page == null) return;

      if (page >= images.length - 2) {
        Future.microtask(() => _controller.jumpToPage(2));
      } else if (page <= 1) {
        Future.microtask(() => _controller.jumpToPage(images.length - 3));
      }
    });

    WidgetsBinding.instance.addPostFrameCallback((_) {
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return PageView.builder(
      physics: const ClampingScrollPhysics(),
      controller: _controller,
      itemCount: images.length,
      itemBuilder: (context, index) {
        return SizedBox(
          child: AnimatedBuilder(
            animation: _controller,
            builder: (context, child) {
              double value = 1.0;
              bool isSelected = false;

              try {
                final page = _controller.hasClients
                    ? (_controller.page ?? _controller.initialPage.toDouble())
                    : _controller.initialPage.toDouble();
                value = (page - index).abs();
                value = (1 - (value * 0.3)).clamp(0.7, 1.0);
                isSelected = page.round() == index;
              } catch (_) {
                value = 1.0;
              }
              return Center(
                child: Transform.scale(
                  scale: value,
                  child: ColorFiltered(
                    colorFilter: isSelected
                        ? const ColorFilter.mode(
                            Colors.transparent,
                            BlendMode.multiply,
                          )
                        : const ColorFilter.matrix(<double>[
                            0.2126,
                            0.7152,
                            0.0722,
                            0,
                            0,
                            0.2126,
                            0.7152,
                            0.0722,
                            0,
                            0,
                            0.2126,
                            0.7152,
                            0.0722,
                            0,
                            0,
                            0,
                            0,
                            0,
                            1,
                            0,
                          ]),
                    child: Opacity(
                      opacity: value,
                      child: Container(
                        margin: const EdgeInsets.symmetric(horizontal: 10),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(20),
                        ),
                        child: Image.asset(images[index]),
                      ),
                    ),
                  ),
                ),
              );
            },
          ),
        );
      },
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Image
Image

Device with this issue:
Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output

Not the device with this issue.

[✓] Flutter (Channel stable, 3.24.4, on macOS
    15.1 24B83 darwin-arm64, locale en-US)
    • Flutter version 3.24.4 on channel stable
      at /Users/mikaqq/Developer/flutter
    • Upstream repository
      https://github.com/flutter/flutter.git
    • Framework revision 603104015d (12 months
      ago), 2024-10-24 08:01:25 -0700
    • Engine revision db49896cf2
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✗] Android toolchain - develop for Android
    devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from:
      https://developer.android.com/studio/ind
      ex.html
      On first launch it will assist you in
      installing the Android SDK components.
      (or visit
      https://flutter.dev/to/macos-android-set
      up for detailed instructions).
      If the Android SDK has been installed to
      a custom location, please use
      `flutter config --android-sdk` to update
      to that location.


[✓] Xcode - develop for iOS and macOS (Xcode
    16.1)
    • Xcode at
      /Applications/Xcode.app/Contents/Develop
      er
    • Build 16B40
    • CocoaPods version 1.16.2

[✗] Chrome - develop for the web (Cannot find
    Chrome executable at /Applications/Google
    Chrome.app/Contents/MacOS/Google Chrome)
    ! Cannot find Chrome. Try setting
      CHROME_EXECUTABLE to a Chrome
      executable.

[!] Android Studio (not installed)
    • Android Studio not found; download from
      https://developer.android.com/studio/ind
      ex.html
      (or visit
      https://flutter.dev/to/macos-android-set
      up for detailed instructions).

[✓] IntelliJ IDEA Ultimate Edition (version
    2025.2.3)
    • IntelliJ at /Applications/IntelliJ
      IDEA.app
    • Flutter plugin can be installed from:
      🔨
      https://plugins.jetbrains.com/plugin/921
      2-flutter
    • Dart plugin version 252.25557.23

[✓] VS Code (version 1.105.1)
    • VS Code at /Applications/Visual Studio
      Code.app/Contents
    • Flutter extension version 3.120.0

[✓] Connected device (3 available)
    • iPhone 16 Pro (mobile)          •
      E4996DD3-BEF4-4E77-858C-2DE9F9659955 •
      ios          •
      com.apple.CoreSimulator.SimRuntime.iOS-1
      8-1 (simulator)
    • macOS (desktop)                 • macos
      • darwin-arm64 • macOS 15.1 24B83
      darwin-arm64
    • Mac Designed for iPad (desktop) •
      mac-designed-for-ipad                •
      darwin       • macOS 15.1 24B83
      darwin-arm64
    ! Error: Browsing on the local area
      network for Mika’s iPhone. Ensure the
      device is unlocked and attached with a
      cable or associated with the same local
      area network as this Mac.
      The device must be opted into Developer
      Mode to connect wirelessly. (code -27)

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

! Doctor found issues in 3 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority issues at the top of the work lista: imagesLoading, displaying, rendering imagese: device-specificOnly manifests on certain devicese: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.platform-androidAndroid applications specificallyr: duplicateIssue is closed as a duplicate of an existing issueteam-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