Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images become corrupted when using CanvasKit #97103

Closed
doppio opened this issue Jan 23, 2022 · 37 comments · Fixed by flutter/engine#31240
Closed

Images become corrupted when using CanvasKit #97103

doppio opened this issue Jan 23, 2022 · 37 comments · Fixed by flutter/engine#31240
Labels
a: images Loading, displaying, rendering images dependency: skia Skia team may need to help us e: web_canvaskit CanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web found in release: 2.10 Found to occur in 2.10 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically r: fixed Issue is closed as already fixed in a newer version

Comments

@doppio
Copy link

doppio commented Jan 23, 2022

Images are inconsistently, but frequently, becoming corrupted on web when using CanvasKit. It seems to happen when the content is scrolled or the window is resized. Below, you'll see an example of 3 images loaded in from assets in a Stack. The results usually appear correctly at first, but scrolling through the interface causes the images to "randomly" change their content. The incorrect contents always seem to be a stretched or highly-zoomed version of other images in memory.

I've only been able to reproduce this when using CanvasKit, but using the HTML renderer is not a viable workaround for us due to several other Flutter bugs.

I've been unable to reproduce this on the beta channel but I see it often on master.

Expected results:
Screen Shot 2022-01-23 at 11 34 01 AM

Actual results:
Screen Shot 2022-01-23 at 11 34 10 AM
Screen Shot 2022-01-23 at 11 34 22 AM

I'm having some difficulty putting together a minimal repro case, but I'm working on it and hope to post one soon. I'm filing this issue in the meantime, in case this is a known issue or someone has some insight about what's going on here.

Logs No warnings or exceptions are displayed at runtime.
flutter analyze
Analyzing app...                                                        
No issues found! (ran in 4.5s)
flutter doctor -v
[✓] Flutter (Channel master, 2.9.0-1.0.pre.463, on macOS 11.6.2 20G314 darwin-x64, locale en-US)
    • Flutter version 2.9.0-1.0.pre.463 at /Users/bryson/flutter
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision e92d8ef2b1 (2 hours ago), 2022-01-23 13:20:17 -0500
    • Engine revision 4f58a01268
    • Dart version 2.17.0 (build 2.17.0-48.0.dev)
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at /Users/bryson/Library/Android/sdk
    • Platform android-31, build-tools 29.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

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

[✓] Android Studio (version 4.1)
    • 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 1.8.0_242-release-1644-b3-6915495)

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

[✓] Connected device (3 available)
    • iPhone X (mobile) • 8ca2a91e9a7b3818f0cd37d0aa1c08b65921f2a9 • ios            • iOS 15.2.1 19C63
    • macOS (desktop)   • macos                                    • darwin-x64     • macOS 11.6.2 20G314 darwin-x64
    • Chrome (web)      • chrome                                   • web-javascript • Google Chrome 97.0.4692.71

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
@cedvdb
Copy link
Contributor

cedvdb commented Jan 23, 2022

This happens to me too, and it's not consistent, it only happens sometimes,

It happens when multiple images with a circular progress indicator are displayed (being upoloaded images).

Here is the widget in question, it's hit or miss when it happens:

import 'package:flutter/material.dart';
import 'package:cross_file/cross_file.dart';
import 'package:octo_image/octo_image.dart';
import 'package:cross_file_image/cross_file_image.dart';

class PendingImage extends StatelessWidget {
  final Function()? onTap;
  final XFile file;
  final double height;
  final double width;

  const PendingImage({
    Key? key,
    required this.file,
    this.height = 100,
    this.width = 100,
    this.onTap,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Stack(
      alignment: Alignment.center,
      children: [
        OctoImage(
          image: XFileImage(file),
          fit: BoxFit.cover,
          width: width,
          height: height,
        ),
        Container(
          color: Colors.white.withAlpha(100),
          width: width,
          height: height,
        ),
        const CircularProgressIndicator()
      ],
    );
  }
}

@doppio
Copy link
Author

doppio commented Jan 23, 2022

After some exploration, I've come up with a simple repro case. From what I can tell, the "corruption" usually (but not always) affects the top image in a Stack. It seems that there must be at least two different images in the stack for the issue to occur. Placing only one image in the Stack, or using two copies of the same image will not reproduce the issue.

Repro steps:

  1. Run the following example on Chrome using the CanvasKit renderer. The attached .zip contains a runnable project with the image assets.
  2. Open the developer tools (Ctrl+Alt+I).
  3. Click on the "Toggle device toolbar" icon.
  4. Notice that the top image has been replaced with some sort of gradient.

Again, this is pretty inconsistent and a bit tricky to repro. The specific window size seems to matter, so it may require some fiddling to get the problem to occur on your machine. See the video below for results.

Example project: image_corruption_example.zip

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Image Corruption Demo',
      home: Stack(
        children: [
          Image.asset('assets/dash.png'),
          Image.asset('assets/logo.png'),
        ],
      ),
    );
  }
}

Video:

imageCorruption.mov

@doppio
Copy link
Author

doppio commented Jan 23, 2022

I've tracked down the commit where the sample case starts breaking: 12271f8, which rolls the Flutter engine from flutter/engine@a6ce607b13f8 to flutter/engine@849877954bb4.

@yjbanov, I notice that some changes for flutter/engine#30680 fall in this range. Is it possible this is related?

EDIT: It looks like it may be more complicated than this. I'm not 100% confident about this commit being the breaking change.

@maheshj01 maheshj01 added the in triage Presently being triaged by the triage team label Jan 24, 2022
@maheshj01
Copy link
Member

Hi @doppio, Thanks for filing the issue. I am not able to reproduce the issue on the latest master or the stable channel and it seems to work fine as expected. I even tried with the same screen dimensions as yours under developer tools and also by running with html and canvaskit renderer but could not reproduce it.

Screen.Recording.2022-01-24.at.7.29.19.PM.mov

Let me know if I am missing anything.

flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-GB)
    • Flutter version 2.8.1 at /Users/mahesh/Documents/flutter
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (3 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (4 available)
    • Redmi K20 Pro (mobile) • 192.168.1.3:5555                     • android-arm64  • Android 11 (API 30)
    • iPhone 13 Pro (mobile) • 0FA2FB93-2A89-4FDB-8293-DF66188F1E54 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0
      (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 96.0.4664.110

• No issues found!
[✓] Flutter (Channel master, 2.9.0-1.0.pre.466, on macOS 12.1 21C52 darwin-arm, locale en-GB)
    • Flutter version 2.9.0-1.0.pre.466 at /Users/mahesh/Documents/flutter_master
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision 5e2542f609 (3 hours ago), 2022-01-24 06:15:18 -0500
    • Engine revision e920762d70
    • Dart version 2.17.0 (build 2.17.0-50.0.dev)
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (4 available)
    • Redmi K20 Pro (mobile) • 192.168.1.3:5555                     • android-arm64  • Android 11 (API 30)
    • iPhone 13 (mobile)     • 3746CA8F-F1FE-475B-96BB-F021E6AF9D3E • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-15-0 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 97.0.4692.99

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Thanks

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 24, 2022
@doppio
Copy link
Author

doppio commented Jan 24, 2022

Thanks for taking a look, @maheshmnj.



I just pushed a local build of the example (flutter build web —web-renderer=canvaskit) to Firebase Hosting to demonstrate the issue, but I cannot reproduce it. That would lead me to think there was an issue with running builds on my machine, but my real project hosted on Firebase does have the issue. This is definitely a slippery bug that seems to involve multiple factors…







I wonder if you are able to reproduce the issue on the dev build of my real project? The problem should appear after scrolling around a bit, resizing the window, etc.







@cedvdb Could you try running the provided example project to check if you see the problem locally?

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 24, 2022
@cedvdb
Copy link
Contributor

cedvdb commented Jan 24, 2022

I've tried to make a reproducible dartpad without success today.

I confirm I do not have the issue with your repro with channels master, beta and stable channels. Versions I tried:

Flutter 2.9.0-1.0.pre.479 • channel master • /~https://github.com/flutter/flutter.git
Framework • revision 6b6cea65e2 (6 minutes ago) • 2022-01-24 17:51:46 -0600
Engine • revision 83cfdcc8f1
Tools • Dart 2.17.0 (build 2.17.0-51.0.dev) • DevTools 2.9.2
Flutter 2.10.0-0.2.pre • channel beta • /~https://github.com/flutter/flutter.git
Framework • revision 73adb1406a (5 days ago) • 2022-01-19 17:02:56 -0600
Engine • revision 74b74b10ea
Tools • Dart 2.16.0 (build 2.16.0-134.1.beta) • DevTools 2.9.2
Flutter 2.8.1 • channel stable • /~https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (6 weeks ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
Flutter 2.2.3 • channel stable • /~https://github.com/flutter/flutter.git
Framework • revision f4abaa0735 (7 months ago) • 2021-07-01 12:46:11 -0700
Engine • revision 241c87ad80
Tools • Dart 2.13.4

I'm running low on time so I won't put anymore time into this.

@maheshj01
Copy link
Member

@doppio I can reproduce it with your example in the production but not when running locally with the example shared above

Screen.Recording.2022-01-25.at.11.08.00.AM.mov
flutter doctor -v
✓] Flutter (Channel master, 2.9.0-1.0.pre.466, on macOS 12.1 21C52 darwin-arm, locale en-GB)
    • Flutter version 2.9.0-1.0.pre.466 at /Users/mahesh/Documents/flutter_master
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision 5e2542f609 (19 hours ago), 2022-01-24 06:15:18 -0500
    • Engine revision e920762d70
    • Dart version 2.17.0 (build 2.17.0-50.0.dev)
    • DevTools version 2.9.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.99

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@maheshj01
Copy link
Member

@doppio, Would it be possible for you to try to recreate a reproducible case? Without an easily reproducible case, I am not sure if this issue can be actionable.

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 25, 2022
@cedvdb
Copy link
Contributor

cedvdb commented Jan 25, 2022

@maheshmnj I personally did not try scrolling his repro, you did not either in the video you posted. It seems that in his last video it happens when he scrolls.

In my case it also contains a SingleChildScrollView but the view was not scrolled, the issue was triggered with a circular progres indicator but I could not make a simple reproduction (I tried, and it might also be version dependent).

I hope some reproduction is going to be found as this glitch is verry odd in UI

@doppio
Copy link
Author

doppio commented Jan 25, 2022

I spent a few more hours on this today -- unfortunately, I'm still unable to come up with a simple case that reproduces the issue after building. I'm able to reproduce it quite easily locally (flutter run, not flutter build), but I'm stumped as to why others aren't seeing the issue in my example project.

It's also strange that I don't see the issue after building the example. Our real project does exhibit the issue after building, as demonstrated above. Maybe it has something to do with the quantity of content/image assets?

I'm currently running:

  • MacBook Pro 2019
  • macOS 12.1
  • Chrome 97.0.4692.99
  • Flutter 2.9.0-1.0.pre.469 • channel master

The end result is a very poor user experience - we can't go to prod with this. 😞 It's starting to look like our solution will be to cobble together a private Flutter repo prior to 12271f8, along with a few other recent fixes we need from master.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 25, 2022
@zambetpentru
Copy link

zambetpentru commented Jan 25, 2022

It sounds like the same issue I came across a few days ago, image corruption with Canvaskit in a recent Flutter master starting a few weeks back and it shows as different red and black patterns.

I haven't had a chance to come up with a repo for it yet outside of my main app, tricky as you say to isolate it.

@tp
Copy link

tp commented Jan 25, 2022

We also had a similar issue where images on resizes become black and red, though not in a "nice" gradient as shown above here, but rather crumbled: AgoraIO-Extensions/Agora-Flutter-SDK#521

Probably related, but sadly also just appearing occasionally and not strictly reproducible (but I would say 30-50% on resize with a video on top; likely this native view / stacking has something to do with it).

@doppio
Copy link
Author

doppio commented Jan 25, 2022

@tp This looks like the same issue. In addition to the black/red gradient, we're seeing image artifacts that are very similar to the screenshots on that issue.

We usually see one of three things:

  • Red font/icon symbols "randomly" packed onto a black background
  • A red-black linear gradient
  • A stretched/zoomed copy of another image that appears elsewhere on the same page

It's interesting that the AgoraIO issue predates 12271f8, the commit that I had identified as the breaking change.

@cedvdb
Copy link
Contributor

cedvdb commented Jan 25, 2022

in my case the red and black was looking like a moving sinuosidal. Which makes sens when you know my images all had a circular progress indicator on top of them.

@tp did the glitch appear at all time or only once something was moving ? It seems like doppio needs the scroll to trigger the glitch too so it seems to indicate something.

@doppio
Copy link
Author

doppio commented Jan 25, 2022

Scrolling does seem to help replicate the issue, but resizing the web browser can trigger it too.

@cedvdb
Copy link
Contributor

cedvdb commented Jan 25, 2022

So I gather there needs to be something moving on top of the image. In my case it was the progress indicator, in yours it's another image. In @tp case, I'll take a wild guess and say he might have had a text transition.

@maheshj01
Copy link
Member

Scrolling does seem to help replicate the issue, but resizing the web browser can trigger it too.

@doppio would it be possible for you to create a reproducible case? Since you are able to reproduce the issue.
Because without a proper reproduction this issue won't be actionable further.

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 26, 2022
@doppio
Copy link
Author

doppio commented Jan 26, 2022

Working on it, as mentioned above. This is extremely difficult to pinpoint, and it's not clear why others aren't seeing the issue in the repro case I provided.

But there's clearly a bug here that's affecting other developers, and it's affecting our thousands of daily users in production. It's a show-stopper for us, so we'll continue to investigate.

Please don't just close this. It seems like the triage team is encouraged to close as many issues as possible, but others are still contributing useful information in identifying a more solid repro case.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 26, 2022
@maheshj01
Copy link
Member

Working on it, as mentioned above. This is extremely difficult to pinpoint, and it's not clear why others aren't seeing the issue in the repro case I provided.

Sure please write back with a reproduction code

Please don't just close this. It seems like the triage team is encouraged to close as many issues as possible, but others are still contributing useful information in identifying a more solid repro case.

The issue is only closed when there isn't enough info to make the issue actionable and it gets auto closed if there is no response from the author for 21 days.

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 26, 2022
@zambetpentru
Copy link

zambetpentru commented Jan 26, 2022

To confirm we are talking about the same thing, this is what I can produce in my app upon resizing the Window:

image

Okay up until: 2.6.0.11.0.pre.784
Issue first appears in 2.6.0-12.0.pre.785 (924336f) and it is still present in the latest master from today 2.9.0-1.0.pre.505.

This seems to be the Commit:
image

flutter doctor
[√] Flutter (Channel master, 2.9.0-1.0.pre.505, on Microsoft Windows [Version 10.0.17763.2452], locale en-IE)
    • Flutter version 2.9.0-1.0.pre.505 at C:\Code\flutter
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision 1065826686 (4 hours ago), 2022-01-25 23:46:14 -0800
    • Engine revision 54e1f3f4bb
    • Dart version 2.17.0 (build 2.17.0-54.0.dev)
    • DevTools version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\Omega\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • CHROME_EXECUTABLE = C:\Code\FlutterTesting\ChromeCORS.bat

[√] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\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 11.0.8+10-b944.6842174)

[√] VS Code (version 1.63.2)
    • VS Code at C:\Users\Omega\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.32.0

[√] Connected device (2 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.99
    • Edge (web)   • edge   • web-javascript • Microsoft Edge 96.0.1054.62

[√] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

@tp
Copy link

tp commented Jan 26, 2022

@tp did the glitch appear at all time or only once something was moving ? It seems like doppio needs the scroll to trigger the glitch too so it seems to indicate something.

This seems triggered when "platform views" become active (the video streams), and when the browser is resized (sometimes resizing again also makes the issue go away, but that's 50/50).

@doppio
Copy link
Author

doppio commented Jan 28, 2022

EDIT: I originally posted a repro case that was using a third-party package. Since then, I posted a simpler repro case without any plugins: #97103 (comment)

Original repro case (with 3rd party package):

I've put together a simpler repro case that is still reproducing after `flutter build`. It still requires some fiddling with the window size and/or scrolling for it to occur.

Unfortunately, I've been unable to isolate this case from the third-party package figma_squircle. I tried swapping out the squircle shape for several other built-in ones (ContinuousRectangleBorder, StadiumBorder, etc.) but then the issue does not reproduce. However, we started seeing this issue in our full project before we ever added this dependency. I'll continue fiddling with this example to see if I can get it to reproduce without any third-party packages.

Repro case

Hosted here: https://flutterimagecorruptiondemo.web.app
Download project: image_corruption.zip

main.dart

import 'package:figma_squircle/figma_squircle.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  runApp(const MyApp());
}


class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SingleChildScrollView(
        child: Column(
          children: [
            Stack(
              children: [
                Positioned.fill(child: SomeShape()),
                Image.asset('assets/1.jpg'),
              ],
            ),
            Image.asset('assets/2.jpg'),
            Image.asset('assets/3.jpg'),
            Image.asset('assets/4.jpg'),
          ],
        ),
      ),
    );
  }
}

class SomeShape extends StatelessWidget {
  const SomeShape({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: ShapeDecoration(
        color: Colors.blue,
        shape: SmoothRectangleBorder(
          borderRadius: SmoothBorderRadius(
            cornerRadius: 75,
            cornerSmoothing: 0.8,
          ),
        ),
      ),
    );
  }
}

Video

repro_case.mov

Notes

  • Only the first of the 4 images is stacked on top of a shape, but any of the images can become "corrupted"
  • If you remove the color parameter from the shape, the issue does not reproduce

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jan 28, 2022
@maheshj01
Copy link
Member

maheshj01 commented Jan 28, 2022

Thanks for the sample project @doppio, I am able to reproduce the issue on the latest master channel. But this issue does not reproduce without the third party plugin, So I suspect if this could be due to the plugin figma_squircle. However when I run the sample on stable channel this issue is not reproducible, so I am not really sue if this issue is due to the plugin or due some change in the framework. Labeling this issue for further investigation

Reproducible sample code can be found in the above comment.

Logs

mahesh@Maheshs-MacBook-Air-M1 image_corruption % flutter run -d chrome --web-renderer canvaskit
Running "flutter pub get" in image_corruption...                    3.6s
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...             28.8s
This app is linked to the debug service: ws://127.0.0.1:57666/aHhd2MYv9MA=/ws
Debug service listening on ws://127.0.0.1:57666/aHhd2MYv9MA=/ws

💪 Running with sound null safety 💪

🔥  To hot restart changes while running, press "r" or "R".
For a more detailed help message, press "h". To quit, press "q".

An Observatory debugger and profiler on Chrome is available at: http://127.0.0.1:57666/aHhd2MYv9MA=
The Flutter DevTools debugger and profiler on Chrome is available at: http://127.0.0.1:9101?uri=http://127.0.0.1:57666/aHhd2MYv9MA=

Performing hot restart...                                           3.1s
Restarted application in 3,142ms.
Application finished.

image

flutter doctor -v
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.1 21C52 darwin-arm, locale en-GB)
    • Flutter version 2.8.1 at /Users/mahesh/Documents/flutter
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision 77d935af4d (3 weeks ago), 2021-12-16 08:37:33 -0800
    • Engine revision 890a5fca2e
    • Dart version 2.15.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (4 available)
    • Redmi K20 Pro (mobile) • 192.168.1.3:5555                     • android-arm64  • Android 11 (API 30)
    • iPhone 13 Pro (mobile) • 0FA2FB93-2A89-4FDB-8293-DF66188F1E54 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-0
      (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 96.0.4664.110

• No issues found!
[✓] Flutter (Channel master, 2.10.0-1.0.pre.307, on macOS 12.1 21C52 darwin-arm, locale en-GB)
    • Flutter version 2.10.0-1.0.pre.307 at /Users/mahesh/Documents/flutter_master
    • Upstream repository /~https://github.com/flutter/flutter.git
    • Framework revision b7424c619c (7 hours ago), 2022-01-26 17:25:45 -0800
    • Engine revision c248c6e38e
    • Dart version 2.17.0 (build 2.17.0-63.0.dev)
    • DevTools version 2.10.0-dev.1

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.2

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

[✓] Android Studio (version 4.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.8+10-b944.6916264)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 60.1.4
    • Dart plugin version 212.5080.8

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

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.1 21C52 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 97.0.4692.99

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

cc: @yjbanov

@maheshj01 maheshj01 added a: images Loading, displaying, rendering images e: web_canvaskit CanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web found in release: 2.10 Found to occur in 2.10 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically and removed in triage Presently being triaged by the triage team labels Jan 28, 2022
@doppio
Copy link
Author

doppio commented Jan 28, 2022

Thanks, @maheshmnj.

I was actually just able to modify the repro case to replicate the issue without any third-party packages. Thanks to @cedvdb for the nudge in the right direction regarding progress indicators.

main.dart

import 'package:flutter/material.dart';

Future<void> main() async {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SingleChildScrollView(
        child: Column(
          children: [
            Stack(
              children: [
                Image.asset('assets/1.jpg'),
                Positioned.fill(child: CircularProgressIndicator()),
              ],
            ),
            Image.asset('assets/2.jpg'),
            Image.asset('assets/3.jpg'),
            Image.asset('assets/4.jpg'),
          ],
        ),
      ),
    );
  }
}

Download project: image_corruption.zip
Hosted here: https://flutterimagecorruptiondemo.web.app

Video

imageCorruption.mov

@zambetpentru
Copy link

Hi @doppio great job on finding a simple repo! I confirm this on Windows, in particularly when rolling the mouse to zoom in and out.

@maheshmnj I can see again that this repo is fine on 2.6.0.11.0.pre.784 and first appears in 2.6.0-12.0.pre.785 (924336f)

image

@andreidiaconu tagging you as the committer, any advice on this issue?

@andreidiaconu
Copy link
Contributor

That commit doesn't touch any canvaskit or image processing code. It only pipes some data from Android to the Framework through the Engine, so I'm really not sure how it might affect this issue.

@zambetpentru
Copy link

Hi @andreidiaconu, I realise my question wasn't well formed. You are right on the Flutter framework release there's only the pieces you mention. Behind that I started to look and I can see there were quite a few Engine revisions between those two Flutter framework commits but I realise they are not connected with the work you released.

Framework Commits:
flutter/engine@d3dcd41...30eb4d6

My current line of sight is on this one:
image
flutter/engine#29419

It appears that in 2.6.0-12.0.pre.785 (924336f) when I edit the new image_web_codecs.dart file (for some reason I have two of them in nested folders - I edited both) and disable the new image decoder the issue appears to go away.

image

In more recent versions of the Engine Framework the approach was further modified and there is now a environment variable for disabling the new ImageDecoder and using the CanvasKit WASM one:

image

So when I run the following on the sample repo (with the kittens) using 2.10.0-1.0.pre.326 the issue disappears
flutter run -d chrome --dart-define=BROWSER_IMAGE_DECODING_ENABLED=false --release

Note: I found the code a little sticky changing back and forth, so I found --release and hitting F5 twice was very reliable. @doppio, @maheshmnj, @tp, @cedvdb does this flag work for you?

flutter doctor [√] Flutter (Channel master, 2.10.0-1.0.pre.326, on Microsoft Windows [Version 10.0.17763.2452], locale en-IE) • Flutter version 2.10.0-1.0.pre.326 at C:\Code\flutter • Upstream repository /~https://github.com/flutter/flutter.git • Framework revision e5f9d5b (15 minutes ago), 2022-01-29 00:10:14 +0200 • Engine revision c2b6e13 • Dart version 2.17.0 (build 2.17.0-67.0.dev) • DevTools version 2.10.0-dev.1

[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\Omega\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.

[√] Chrome - develop for the web
• CHROME_EXECUTABLE = C:\Code\FlutterTesting\ChromeCORS.bat

[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\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 11.0.8+10-b944.6842174)

[√] VS Code (version 1.63.2)
• VS Code at C:\Users\Omega\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.32.0

[√] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.99
• Edge (web) • edge • web-javascript • Microsoft Edge 96.0.1054.62

[√] HTTP Host Availability
• All required HTTP hosts are available

• No issues found!

@jason-simmons
Copy link
Member

Confirmed that this is reproducible with the example in #97103 (comment)

This started with the migration to the web ImageDecoder API (flutter/engine@9258e0c)

@yjbanov @kjlubick Possibly this could be an issue in MakeLazyImageFromTextureSource state management, similar to https://bugs.chromium.org/p/skia/issues/detail?id=12740?

@jason-simmons jason-simmons added the dependency: skia Skia team may need to help us label Jan 29, 2022
@doppio
Copy link
Author

doppio commented Jan 29, 2022

@zambetpentru That flag works on my end! Thanks so much for investigating -- you saved the day for us! 🎉

@doppio
Copy link
Author

doppio commented Jan 29, 2022

Screen Shot 2022-01-28 at 10 58 07 PM

Funny, I was just using Rive and encountered this bug in the wild!

cc @luigi-rosso in case you're interested in a fix for this 🙂

@tp
Copy link

tp commented Jan 29, 2022

does this flag work for you?

First off thanks for your investigation @zambetpentru!

I could still reproduce the issue for our app with a video showing on top:

image

(I ran with flutter run -d chrome --dart-define=BROWSER_IMAGE_DECODING_ENABLED=false --release (and also tried after reloading, though since the port is always random I wouldn't expect this to make a difference as nothing should be cached))

@zambetpentru
Copy link

zambetpentru commented Jan 29, 2022

@tp When I read the original linked ticket AgoraIO/Agora-Flutter-SDK#521 i and I see Videos / Platform Views I think of my other ticket that is currently open #95259 - do you have any errors in the Browser Console?

Have a go on 2.6.0.11.0.pre.784 (2ac39b9) and see if your issue disappears (this ticket) and if not drop back further to
2.6.0-11.0.pre211 (0b9027c) and if that works but 2.6.0-11.0.pre212 (0a62694) breaks then you are probably dealing with #95259

Interested to hear your update :-)

@tp
Copy link

tp commented Jan 31, 2022

@zambetpentru Would love to give this a try. What are the exact Git commits of the versions you mention though? I only see a single 2.6.0-11.0.pre tag in the repo (in order to switch locally).

In the screenshot above the images don't "disappear" fully though, they still show that black/red gradient (it's only a bit hard to see in our dark mode). But still happy to try out if it's related to the other issue :)

@cedvdb
Copy link
Contributor

cedvdb commented Jan 31, 2022

@maheshmnj I'd feel more comfortable if there was an integration test for this. I'm sure others too because the result is ugly

@kjlubick
Copy link
Contributor

kjlubick commented Jan 31, 2022

I fixed one more issue with textures in CanvasKit at ToT which may be the culprit: skbug.com/12797 One symptom I noticed was the wrong texture would be drawn at spurious times. That should be fixed now in CanvasKit; hopefully we can update Flutter to use it soon.

@jason-simmons
Copy link
Member

Confirmed that google/skia@c4b2fb3 fixes this

@kevmoo kevmoo added the cp: 2.10 label Feb 2, 2022
@maheshj01 maheshj01 added the r: fixed Issue is closed as already fixed in a newer version label Feb 4, 2022
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: images Loading, displaying, rendering images dependency: skia Skia team may need to help us e: web_canvaskit CanvasKit (a.k.a. Skia-on-WebGL) rendering backend for Web found in release: 2.10 Found to occur in 2.10 has reproducible steps The issue has been confirmed reproducible and is ready to work on platform-web Web applications specifically r: fixed Issue is closed as already fixed in a newer version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants