flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.4k stars 27.29k forks source link

Slight flicker on the screen when loading from app overview on Android #34864

Open nvbln opened 5 years ago

nvbln commented 5 years ago

When switching between apps to an app created by flutter on an Android 9.0 device, there might be a short shadowy (so the screen is not completely black) flicker of the screen that the app shows.

This can be reproduced by any app as far as I am aware.

  1. Create a basic app by using flutter create app followed by cd app and flutter run on an Android 9.0 device (it might also affect other versions, I have not tested it on any other devices, but I heard that other people are able to reproduce it on their device).
  2. Launch the application and go back into the running app overview.
  3. Select another app that is open.
  4. Wait a little bit (this seems to make the bug more likely to happen).
  5. Go back into the overview and select the flutter app.
  6. A quick slight flicker will appear on the screen.
BondarenkoStas commented 5 years ago

@nvbln Do you still experience it? Please provide your flutter doctor -v output.

AleksMx commented 4 years ago

@nvbln Do you still experience it? Please provide your flutter doctor -v output.

Met with this bug. My application have Timer.periodic with duration 70 ms, after I hide application to the background and open it again I see 1-2 black flicker. In the thread I update StatefulWidget widget by call setState ({}); method. But when I delete thread - all right.

In the debug version I see flickers every time when I hide and open application again (through the icon on the home screen).

In the release and debug versions I see 1-2 flickers in the recent applications overview screen (after I hide application). In the relase version I see flickers only in 10% of cases (quite rarely).

In the debug version flicker average duration is 400-700 ms. In the release version average duration - from 100 ms to 300 ms.

The code that causes the error: timerClock = Timer.periodic(new Duration(milliseconds: 70), (timer) { setState(() { }); });

[✓] Flutter (Channel stable, v1.9.1+hotfix.5, on Linux, locale en_US.UTF-8) • Flutter version 1.9.1+hotfix.5 at /home/XXXX/app/flutter • Framework revision 1aedbb1835 (3 weeks ago), 2019-10-17 08:37:27 -0700 • Engine revision b863200c37 • Dart version 2.5.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /home/XXXX/Android/Sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-28, build-tools 28.0.3 • Java binary at: /home/XXXX/app/android-studio/jre/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Android Studio (version 3.5) • Android Studio at /home/XXXX/app/android-studio • Flutter plugin version 40.2.2 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available) • XXXXX • XXXXXXX • android-arm64 • Android 9 (API 28)

• No issues found! Process finished with exit code 0

Goopher commented 4 years ago

Hi @BondarenkoStas , I do still experience this issue. The launch_screen.xml flickers for a tiny tiny fraction of a second when I return to the app from a different app.

iapicca commented 4 years ago

Hi @Goopher could you please provide your updated flutter doctor -v and your flutter run --verbose and a reproducible minimal code sample or the steps to reproduce the problem. Thank you

Goopher commented 4 years ago

@iapicca

The issue happens on my personal device (OnePlus 6T), I don't experience it in the emulator. I have the issue both in release and debug mode.

I have setup an Android launch screen in the following way:

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap
            android:gravity="fill_vertical"
            android:src="@drawable/image" />
    </item>
</layer-list>

And everytime I reload the app after switching this happens. The flickering image that pops up is the drawable from the launch screen by the way.

See attached gif:

http://i.imgur.com/3QP8kT6.gif

flutter doctor -v:

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-NL) • Flutter version 1.12.13+hotfix.5 at /Users/XXXXX/Development/flutter • Framework revision 27321ebbad (5 weeks ago), 2019-12-10 18:15:01 -0800 • Engine revision 2994f7e1e6 • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/XXXXX/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • Java binary at: /Users/XXXXX/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.6010548/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3.1, Build version 11C504 • CocoaPods version 1.8.4

[✓] Android Studio (version 3.5) • Android Studio at /Users/XXXXX/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.6010548/Android Studio.app/Contents • Flutter plugin version 42.1.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Android Studio • Android Studio at /Users/XXXXX/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/193.6085562/Android Studio 4.0 Preview.app/Contents • Flutter plugin version 39.0.5 • Dart plugin version 193.2956.37 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

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

[✓] Connected device (2 available) • ONEPLUS 6T • XXXXX • android-arm64 • Android 10 (API 29) • Android SDK built for x86 • XXXXX • android-x86 • Android 10 (API 29) (emulator)

• No issues found!

pishguy commented 4 years ago

+1

i have this problem on android 8

doc-rj-celltrak commented 4 years ago

I'm seeing an obvious blink after foregrounding a Flutter app on Android 7, 8, and 9 emulators. The blink doesn't appear on Android 10 afaik... I haven't tried yet on physical devices or on Android versions below 7.1.1 (Nougat).

I'm just backgrounding the app with the home button and then opening again through the app's icon in the app tray.

flutter doctor -v:

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.3 19D76, locale en-US) • Flutter version 1.12.13+hotfix.8 at /Users/ryanjones/Development/Flutter/flutter • Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2) • Android SDK at /Users/ryanjones/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.2 • ANDROID_HOME = /Users/ryanjones/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3.1, Build version 11C504 • CocoaPods version 1.8.0

[✓] Android Studio (version 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 43.0.1 • Dart plugin version 191.8593 • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

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

[✓] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)

• No issues found!

MazEbeid commented 4 years ago

+1 I was facing this issue but it goes away if you run in release mode flutter run --release

nioncode commented 4 years ago

Cross-posting from #27449:

I just reproduced this on latest master, happening in debug, profile, and release, tested on a Pixel 2 and the emulator. The screen briefly flashes when selecting the app from the multi tasking window. It does not seem to happen when switching apps via 'double-click-on-recents', at least it is not visible then.

Also, this does not seem to be the launch screen, since I set the launch screen to be opaque red and the flash is dark-ish, so it looks to me like it might be just one or two black frames maybe?

Sample:

output1

flutter-doctor:

[✓] Flutter (Channel master, v1.17.1-pre.23, on Linux, locale en_US)
    • Flutter version 1.17.1-pre.23 at /opt/flutter
    • Framework revision a2e6c30b44 (17 hours ago), 2020-04-03 20:26:01 -0700
    • Engine revision 09bc1fc45e
    • Dart version 2.8.0 (build 2.8.0-dev.20.0 e736495eb7)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/developer/android-sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /home/developer/android-sdk
    • ANDROID_SDK_ROOT = /home/developer/android-sdk
    • Java binary at: /opt/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Android Studio (version 3.5)
    • Android Studio at /opt/android-studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (1 available)
    • Pixel 2 • 192.168.1.31:5555 • android-arm64 • Android 10 (API 29)

/cc @matthew-carroll since you looked into this in #47903 and solved part of the issue already (which made the flash take even longer or there was an additional flash).

howieweiner commented 4 years ago

Hi

I'm not sure if this is a separate issue or part of this one. I have just updated my app and it has been released for test (production build). I am seeing an issue on Android 9 (Moto G6) when the app is minimised. There is a very noticeable flicker. I have recorded it and slowed it down and it is a black bar scanning down the screen. It happens consistently, and only on minimising.

flitter-flutter-scan

I have a video of this issue.

I have upgraded to Flutter v1.17 and added a background image in this release. I can't think of anything else that might have caused this change.

I don't see this issue on Android 10 in a virtual device, nor on a physical device running (cough) Android 6, nor on an iOS device. I can't recreate it on Android 9 using a virtual device.

rs5173 commented 4 years ago

To be sure, this problem is caused by SurfaceView's caching mechanism

alex-min commented 4 years ago

I can also confirm the issue with Flutter 1.17.3 and Android 9 (real device).

This seems to happen for every flutter app, even the demo counter app, release mode does not change anything.

I hope a workaround will be found because it looks bad.

pishguy commented 4 years ago

and this video

https://imgur.com/a/U9le08x

valtlfelipe commented 4 years ago

Having same issue here with Moto G6 plus and android 9. Also, on multitasking it flashes multiple times, and screen is black (without the preview, I don't no if this is related to this or other bug). App is using latest flutter version and in release mode.

See video https://drive.google.com/file/d/1lX83DgrUEohZFmesWisRK878CQYA5MsG/view?usp=sharing

PS: Just installed Flutter Gallery from play store, and I have the exact same behavior as in the video I linked.

truyenjc commented 3 years ago

I still facing this issue with Flutter 1.22.0

pishguy commented 3 years ago

I still facing this issue with Flutter 1.22.0

and me too

valtlfelipe commented 3 years ago

I still facing this issue with Flutter 1.22.0

same here

iapicca commented 3 years ago

@truyenjc @MahdiPishguy @valtlfelipe

I was facing this issue but it goes away if you run in release mode flutter run --release

does it occur in release mode? can you provide you flutter doctor -v tagging @TahaTesser for visibility

alex-min commented 3 years ago

@iapicca It does occur on release mode, on every app (even the demo counter app). I still confirm the issue on Flutter 1.22.1.

[✓] Flutter (Channel stable, 1.22.1, on Linux, locale fr_FR.UTF-8)
    • Flutter version 1.22.1 at /usr/share/flutter
    • Framework revision f30b7f4db9 (il y a 8 jours), 2020-10-08 10:06:30 -0700
    • Engine revision 75bef9f6c8
    • Dart version 2.10.1

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /home/alex/Android/Sdk
    • Platform android-30, build-tools 29.0.2
    • ANDROID_HOME = /home/alex/Android/Sdk
    • Java binary at: /home/alex/android/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Android Studio (version 4.0)
    • Android Studio at /home/alex/android/android-studio
    • Flutter plugin version 46.0.2
    • Dart plugin version 193.7361
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[!] VS Code (version 1.50.0)
    • VS Code at /usr/share/code
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[!] Connected device
    ! No devices available

! Doctor found issues in 2 categories.
pishguy commented 3 years ago

@iapicca

@alex-min yes you right, i have this problem with all of application which built with Flutter and with all of versions which released til now :(

@iapicca It does occur on release mode, on every app (even the demo counter app). I still confirm the issue on Flutter 1.22.1.

hardmen commented 3 years ago

I still facing this issue with Flutter 1.22.3, event at Flutter Demo Project. Anyone has solutions or ideas?

Dusickaa commented 3 years ago

I'm facing same issue, any solution?

hardmen commented 3 years ago

I still facing this issue with Flutter 1.22.3, event at Flutter Demo Project. Anyone has solutions or ideas?

https://github.com/flutter/flutter/issues/59552 This link solve the flicker issue!!! 🎉 🎉 🎉

darshankawar commented 3 years ago

I am able to replicate this on Android emulator Pixel 3XL (although not consistently, but yes I did see flickering of flutter app while switching between app overviews).

34864.mov.zip

flutter doctor -v ``` [✓] Flutter (Channel stable, 1.22.4, on Mac OS X 10.15.4 19E2269 darwin-x64, locale en-IN) • Flutter version 1.22.4 at /Users/dhs/documents/Fluttersdk/flutter • Framework revision 1aafb3a8b9 (3 weeks ago), 2020-11-13 09:59:28 -0800 • Engine revision 2c956a31c0 • Dart version 2.10.4 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0) • Android SDK at /Users/dhs/Library/Android/sdk • Platform android-30, build-tools 30.0.0 • 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-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.0.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.0.1, Build version 12A7300 • CocoaPods version 1.9.3 [✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 46.0.2 • Dart plugin version 193.7361 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [✓] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.16.0 [✓] Connected device (2 available) • sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • iPhone SE (2nd generation) (mobile) • 6C85835D-FBFD-4AB3-8DE8-B4FAD35E5367 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator) • No issues found! ```
pishguy commented 3 years ago

@darshankawar

did you try this solution? https://github.com/flutter/flutter/issues/59552#issuecomment-713374392

Andrewcpu commented 3 years ago

Definitely related to 57541

maheshwaran-p commented 3 years ago

I think this problem will be only for debug run and can solve it by profile run .

pishguy commented 3 years ago

I think this problem will be only for debug run and can solve it by profile run .

it doesn't correct, we have this problem in all of release types

alex-min commented 3 years ago

Profile run does not solve the issue as mentioned already multiple times in this thread.

This issue happens for every app (even the default demo counter app), in every profile mode (including release) and is still there on Flutter latest stable (2.2.3) as I write those lines. Tested using a Galaxy J3 Pro with Android 9.

gvoscar commented 2 years ago

Slight screen flickering when I implement a showSearch

Device: Redmi 9T Android 10

sunny026 commented 2 years ago

Yes

AsogunJoel commented 2 years ago

I'm still experiencing this issue as of today. If anyone has found a valid workaround for this issue please leave a link or explain the workaround for this.

mohyghb commented 1 year ago

same here

maheshwaran-p commented 1 year ago

This maybe a performance issue using svg can affect the performance . I faced the same issue so here I come with the solution . I have developed a tool called svg2flutter . this tool will convert the svg file as flutter code . by using this we can overcome this kind of performance issue . I am just planning to change this project as open source feel free to reach me if you want to join with my project .

try it out the tool: https://svg2widget.web.app/ performance metrics : https://github.com/maheshwaran-p/samplesvg/

darshankawar commented 1 year ago

I verified a similar issue yesterday https://github.com/flutter/flutter/issues/59552 which is replicable on latest stable and master versions.

Andrewcpu commented 1 year ago

This happens regardless of build type (release, debug, profile), it happens with the standard hello world application, and has been happening for years.

JackieLovesProgramming commented 1 year ago

any solution to this?

ebelevics commented 1 year ago

Have visited all my known Flutter apps that are in PlayStore right now, all have this flickering issue. I personally noticed that today during development. Would like to hear from Flutter team what is the status, as it seems this issue is 4 years old.

Hixie commented 1 year ago

The status as I understand it is that we haven't been able to reproduce it in a development environment. If you are able to reproduce it reliably we would greatly appreciate your help in tracking it down. What device do you see it on, what version of the OS, can you give us a precise main.dart file that shows the problem, what steps do you use to reproduce it reliably, etc?

ebelevics commented 1 year ago

Google Pixel 6a Android 13 Flutter 3.13.5 As you can see in video, when switching to native Android apps there is no flicker, when switching to flutter apps it has slight black flicker. It happens in release apps also

As for main.dart it doesn't matter, I just tried creating new Flutter counter project, it happens there also (tried on Android Studio Emulator)

https://github.com/flutter/flutter/assets/25333580/12ed0c2b-c755-407f-8f63-993ff392cf48

gloomie commented 8 months ago

Any solution for this issue?

corepuncher commented 6 months ago

If I send app to background, then bring to foreground after a few minutes, the screen stays black. But, upon seeing the black screen, if I immediately send back to background and bring to foreground, it is normal again. Very reproducible. Also, if I do not delay too long, the app comes back up normally after sending to background. It may have to do with my timers, IDK.

I even tried adding the whole "WidgetsBinding.instance.addObserver(this)" and attempted to stop and restart my timers in didChangeDependencies, but the problem persists. Although, my timers do start and stop nicely :-)

Colman commented 4 months ago

It looks like asset images flicker as well. It doesn't seem to happen for built-in icons or text.

Lime-blur commented 2 months ago

When will there be a normal solution to this problem? This problem is still reproducible! 😠 If there is no solution in flutter engine, please provide at least a temporary solution. Solutions with setting View on top of SurfaceView do not give anything, since SurfaceView overlaps them + this is a very big crutch that creates ugly UI jumps during the resume of the application.

Hixie commented 2 months ago

@Lime-blur Please see https://github.com/flutter/flutter/blob/master/docs/contributing/issue_hygiene/README.md#when-will-my-bug-be-fixed