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

[Android] App shows black screen after being in the background. #93276

Closed
thomasaldershof opened this issue Nov 8, 2021 · 87 comments · Fixed by flutter/engine#30897
Closed
Labels
e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-android Android applications specifically r: fixed Issue is closed as already fixed in a newer version

Comments

@thomasaldershof
Copy link

thomasaldershof commented Nov 8, 2021

Steps to Reproduce

It seems to happen on different Flutter apps. Open a Flutter app, go to your home screen and open some other apps. Wait for some time and open the Flutter app again. There is now a chance that the app shows a black screen. No Appbar, BottomBar or any widget. It happens pretty frequently if you know how to trigger it.

The app seems to respond to user interaction, just had it on the debugger but there is no useful information, no errors, no exceptions thrown. Moving to the android recents screen and returning to the app fixes this. I haven't tried to do this with iOS.

Was able to reproduce this on some older installed apps, app created with Flutter stable 2.5.3 and the latest beta build (2.7.0 iirc).

I can't really create an app sample because it is pretty hard to know when it exactly happens because it is not guaranteed to happen. It does occur on multiple devices and some users have noticed it too. No data on crashlytics or runguarded zone.

[✓] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.22000.282], locale en-NL)
    • Flutter version 2.5.3 at C:\src\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700
    • Engine revision d3ea636dc5
    • Dart version 2.14.4

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at C:\Users\dxzds\AppData\Local\Android\sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[✓] 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.10+0-b96-7249189)

[✓] VS Code (version 1.61.2)
    • VS Code at C:\Users\dxzds\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • IN2023 (mobile) • 192.168.0.165:40423 • android-arm64  • Android 11 (API 30)
    • Chrome (web)    • chrome              • web-javascript • Google Chrome 95.0.4638.69
    • Edge (web)      • edge                • web-javascript • Microsoft Edge 95.0.1020.44
@maheshj01 maheshj01 added the in triage Presently being triaged by the triage team label Nov 9, 2021
@maheshj01
Copy link
Member

Hi @vanth0me, Thanks for filing the issue.

I can't really create an app sample because it is pretty hard to know when it exactly happens because it is not guaranteed to happen. It does occur on multiple devices and some users have noticed it too. No data on crashlytics or runguarded zone.

Can you please share some more details

  • How long have you put the app in the background?
  • which Android devices reproduce the issue?
  • Does this reproduce on an emulator too or only on a real device?
  • Can you please also check if this happens with a specific flutter project or a newly created flutter project too?

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 9, 2021
@thomasaldershof
Copy link
Author

Thank you for your response!
I think usually happens after 5+min, but I've had it sooner. From the devices I know it is my OnePlus 8 Pro, Samsung S10 and the emulator too. I recreated the project and moved the code and the same thing happened. As I have said older self made apps also show this. I don't know if I can trigger it with the base app. I will have to try that later today.

@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 Nov 9, 2021
@maheshj01
Copy link
Member

I don't know if I can trigger it with the base app. I will have to try that later today.

Sure please verify and let us know and also please check the android version of the devices to make sure if this is/ is not related to the OS version.

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 9, 2021
@maheshj01 maheshj01 changed the title App shows black screen after being in the background. [Android] App shows black screen after being in the background. Nov 9, 2021
@thomasaldershof
Copy link
Author

Yes will do. My emulator is running Android 12 and the devices are running Android 11.

@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 Nov 9, 2021
@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 9, 2021
@thomasaldershof
Copy link
Author

I am, for now, at least unable to trigger a black screen in the New Flutter Project app. I wonder if it has something to do with more memory usage.

@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 Nov 10, 2021
@maheshj01
Copy link
Member

@vanth0me without any code sample or logs its not possible to find the cause of the issue.

I am, for now, at least unable to trigger a black screen in the New Flutter Project app. I wonder if it has something to do with more memory usage.

Are there any logs that you can share?
Is it possible for you to share a repository containing the reproducible code?

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 10, 2021
@thomasaldershof
Copy link
Author

thomasaldershof commented Nov 10, 2021

I can't share the app I'm currently working on, but I can share a private project where it just happend. I think it is on BitBucket, is there an easy way to share this with you?

Edit: checked my logcat but didn't really find anything with flutter or the app name. There is so much spam in there and knowing the time it happend is basically impossible.

@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 Nov 10, 2021
@liwangyong

This comment has been minimized.

@zhangruiyu
Copy link

Huawei Mate30 Pro, I have encountered this problem many times

@maheshj01
Copy link
Member

@liwangyong @zhangruiyu can you guys please share a reproducible steps along with the output of flutter doctor -v and the related logs?

@maheshj01
Copy link
Member

maheshj01 commented Nov 11, 2021

@vanth0me I tried running your project and it fails to build it, looks like there are some compile-time errors could you please recheck and also provide the steps to reproduce the issue?

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 Nov 11, 2021
@thomasaldershof
Copy link
Author

@maheshmnj I fixed it, looked like it was a really early version for some reason. The steps are open the app, I don't know if logging in helps but then just switch to another app, wait some time and hope it gives a black screen. The difficulty is finding the balance between opening too soon and the app being killed. There is sadly no guarantee it will happen.

@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 Nov 11, 2021
@maheshj01
Copy link
Member

@vanth0me there is a build time error now the bezier_chart doesn't seem to support null safety. Alternatively, you may also try upgrading to latest master by running

flutter channel master 
flutter upgrade

From the devices I know it is my OnePlus 8 Pro, Samsung S10 and the emulator too

And if you still face the issue please provide the emulator details on which the issue reproduces as the above devices are not available for me to test.

build failure logs
mahesh@Maheshs-MacBook-Air-M1 black-screen-test % git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Updating 1b0523f..331937e
error: The following untracked working tree files would be overwritten by merge:
        .flutter-plugins
        .flutter-plugins-dependencies
        .packages
        pubspec.lock
Please move or remove them before you merge.
Aborting
mahesh@Maheshs-MacBook-Air-M1 black-screen-test % git pull
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Updating 1b0523f..331937e
Fast-forward
 .flutter-plugins                       |  17 ++++
 .flutter-plugins-dependencies          |   1 +
 .gitignore                             |  74 ++++++++++++++
 .metadata                              |  10 ++
 .packages                              |  80 +++++++++++++++
 analysis_options.yaml                  |  29 ++++++
 lease_log.iml                          |  33 ++++++
 lib/extensions/date.dart               |  11 ++
 lib/generated_plugin_registrant.dart   |  21 ----
 lib/main.dart                          |  56 ++++++-----
 lib/models/log.dart                    |  43 ++++++++
 lib/models/ride.dart                   |   4 -
 lib/models/tank.dart                   |  25 +++++
 lib/models/user.dart                   |  35 +++++++
 lib/providers/circularData.dart        |  43 ++++++++
 lib/providers/data.dart                | 190 ++++++++++++++++++++++++++++++++++
 lib/providers/fuel.dart                | 115 +++++++++++++++++++++
 lib/providers/initialSetup.dart        |  90 +++++++++++++++++
 lib/providers/lease.dart               |  38 +++++++
 lib/providers/login.dart               |  69 ++++++++-----
 lib/providers/monthlyChart.dart        |  40 ++++++++
 lib/providers/theme.dart               |   3 +
 lib/providers/totalChartB.dart         |  65 ++++++++++++
 lib/providers/user.dart                |  40 ++++++++
 lib/screens/data.dart                  |  26 +++++
 lib/screens/homescreen.dart            | 105 +++++++++++++++++--
 lib/screens/initialSetup.dart          | 214 +++++++++++++++++++++++++++++++++++++++
 lib/screens/loginScreen.dart           |  88 ++++++++++++++--
 lib/theme/dark.dart                    |  43 ++++++++
 lib/theme/light.dart                   |  40 ++++++++
 lib/todos                              |   1 +
 lib/widgets/addRide.dart               |  53 +++++++++-
 lib/widgets/circularProgress.dart      | 120 ++++++++++++++++++++++
 lib/widgets/distanceGraph.dart         |   8 --
 lib/widgets/formFieldWrapper.dart      |  39 +++++++
 lib/widgets/fuel/addFuel.dart          | 126 +++++++++++++++++++++++
 lib/widgets/fuel/fuelTable.dart        |  59 +++++++++++
 lib/widgets/fuel/lastFuel.dart         |  52 ++++++++++
 lib/widgets/history.dart               |  80 +++++++++++++++
 lib/widgets/monthlyGraph.dart          |  74 ++++++++++++++
 lib/widgets/parts/fuel.dart            |  37 +++++++
 lib/widgets/parts/lease.dart           | 118 ++++++++++++++++++++++
 lib/widgets/privacy/orDivider.dart     |  24 +++++
 lib/widgets/privacy/privacyDialog.dart |  73 ++++++++++++++
 lib/widgets/privacy/termsOfUse.dart    |  58 +++++++++++
 lib/widgets/settings.dart              |  37 +++++++
 lib/widgets/textField.dart             |  42 ++++++++
 lib/widgets/totalGraphBezier.dart      |  87 ++++++++++++++++
 pubspec.lock                           | 509 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 pubspec.yaml                           |  31 ++++--
 50 files changed, 3170 insertions(+), 106 deletions(-)
 create mode 100644 .flutter-plugins
 create mode 100644 .flutter-plugins-dependencies
 create mode 100644 .gitignore
 create mode 100644 .metadata
 create mode 100644 .packages
 create mode 100644 analysis_options.yaml
 create mode 100644 lease_log.iml
 create mode 100644 lib/extensions/date.dart
 delete mode 100644 lib/generated_plugin_registrant.dart
 create mode 100644 lib/models/log.dart
 delete mode 100644 lib/models/ride.dart
 create mode 100644 lib/models/tank.dart
 create mode 100644 lib/models/user.dart
 create mode 100644 lib/providers/circularData.dart
 create mode 100644 lib/providers/data.dart
 create mode 100644 lib/providers/fuel.dart
 create mode 100644 lib/providers/initialSetup.dart
 create mode 100644 lib/providers/lease.dart
 create mode 100644 lib/providers/monthlyChart.dart
 create mode 100644 lib/providers/theme.dart
 create mode 100644 lib/providers/totalChartB.dart
 create mode 100644 lib/providers/user.dart
 create mode 100644 lib/screens/data.dart
 create mode 100644 lib/screens/initialSetup.dart
 create mode 100644 lib/theme/dark.dart
 create mode 100644 lib/theme/light.dart
 create mode 100644 lib/todos
 create mode 100644 lib/widgets/circularProgress.dart
mahesh@Maheshs-MacBook-Air-M1 black-screen-test % flutter build apk 

💪 Building with sound null safety 💪

Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:bezier_chart

For solutions, see https://dart.dev/go/unsound-null-safety


FAILURE: Build failed with an exception.

* Where:
Script '/Users/mahesh/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1005

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command '/Users/mahesh/Documents/flutter/bin/flutter'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 52s
Running Gradle task 'assembleRelease'...                           53.8s
Gradle task assembleRelease failed with exit code 1
mahesh@Maheshs-MacBook-Air-M1 black-screen-test % 

Please make the final changes and make sure the app runs.

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 Nov 11, 2021
@thomasaldershof
Copy link
Author

I'm sorry, should have mentioned that building is with the no null sound safety option, because of the package. I'm pretty sure the last time it happend on an emulator it was an Android 12 x86_64 (Google APIs) based on a Pixel 5.

@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 Nov 11, 2021
@maheshj01
Copy link
Member

maheshj01 commented Nov 11, 2021

@vanth0me I ran your app and it did not go past the login screen because of the Google sign-in error (probably due to missing app signature) I kept it in the background for around 15-20 mins did not see the black screen when switching back to app.

@maheshj01 maheshj01 added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 11, 2021
@thomasaldershof
Copy link
Author

thomasaldershof commented Jan 12, 2022

@ColdPaleLight This does not fix it for me.

According to your description, what you encountered looks like should be the same as #94921

You may be right. I believe this issue and #94921 are identical and that there is no direct connection to waiting any amount of time like people are suggesting here.

People in this issue are connecting the black screen to waiting an amount of time but I think this is just because they only start noticing the black screen once their phone goes to sleep mode while they work on code meanwhile and then eventually wake their phones and see black screens.

The problem is that OP #94921 is linking this issue to debug scene, which is probably also not a correct observation.

Hmm interesting, maybe the app does something self to mimic this behavior. I can also reproduce this issue with launching a release app on my phone, locking the screen and unlocking it. Guaranteed black screen. Nice find from #94921 OP

Edit: Forgot your last alinea. It is indeed not just in the debugger.

@dnfield
Copy link
Contributor

dnfield commented Jan 12, 2022

I added some comments about what I think is going on here: https://github.com/flutter/engine/pull/30590/files#r783307849

I unfortunately have not been able to reproduce this locally but it should be fixable.

@RaymondBakker
Copy link

@dnfield Have you tried to reproduce this with the steps I posted at #93276 (comment)? Judging by other responses, it seems easy to reproduce this way.

@thomasaldershof
Copy link
Author

@dnfield Have you tried to reproduce this with the steps I posted at #93276 (comment)? Judging by other responses, it seems easy to reproduce this way.

Trying your method with an installed app didn't create any black screens if the app is idle. It is however very ease to do during boot if the app is changing screens.

@dnfield
Copy link
Contributor

dnfield commented Jan 13, 2022

flutter/engine#30590 has landed as fab1982.

Once that's finished on CI, you might be able to just update your bin/internal/engine.version and test this.

I found a OnePlus phone but still can't seem to reproduce this myself.

@dnfield
Copy link
Contributor

dnfield commented Jan 13, 2022

(It's still building on CI but should be done within the next hour)

@RaymondBakker
Copy link

Flutter 2.9.0-1.0.pre.351 • channel master • https://github.com/flutter/flutter.git
Framework • revision 4fda08efa9 (19 minutes ago) • 2022-01-13 14:15:18 -0500
Engine • revision fab1982994
Tools • Dart 2.17.0 (build 2.17.0-10.0.dev) • DevTools 2.9.2

The black screen is still occurring for me.

@dnfield
Copy link
Contributor

dnfield commented Jan 13, 2022

What would help at this point is a reproduction that happens consistently, or at least that happens with higher frequency on a greater number of devices.

@thomasaldershof
Copy link
Author

@dnfield one easy way to do this is have an app where the launch takes a few seconds, for example with auto login. Quickly open that app, lock your screen and unlock it. Had more luck yesterday with a 80% success ratio, now it's about 30%. At least it's pretty fast to do.

@blasten blasten added the e: device-specific Only manifests on certain devices label Jan 13, 2022
@ColdPaleLight
Copy link
Member

ColdPaleLight commented Jan 14, 2022

I was able to reproduce this Issue and I did some investigation on it.

Normally, after we open the flutter app and turn off the screen, FlutterSurfaceView.surfaceCallback.surfaceDestroyed will be called. And when we turn on the screen, FlutterSurfaceView.surfaceCallback.surfaceCreated and FlutterSurfaceView.surfaceCallback.surfaceChanged will be called.

But on my OnePlus phone, when I turn off the screen, first FlutterSurfaceView.surfaceCallback.surfaceDestroyed is called, and then FlutterSurfaceView.surfaceCallback.surfaceCreated and FlutterSurfaceView.surfaceCallback.surfaceChanged are also called. And when I turn on the screen, only FlutterSurfaceView.surfaceCallback.surfaceChanged is called or nothing is called.

The following are some logs, the operation of them are the same. Turn off the screen after the App is running, and then turn on the screen.

Other Phones

// 1. app start
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged() 
// 2. turn off the screen
SurfaceHolder.Callback.stopRenderingToSurface()
// 3. turn on the screen
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged()

OnePlus display correctly

// 1. app start
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged()  size: 1440 x 3052
// 2. turn off the screen
SurfaceHolder.Callback.stopRenderingToSurface()
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged() size: 1440 x 3052
SurfaceHolder.Callback.surfaceChanged() size: 1440 x 3120
// 3. turn on the screen
SurfaceHolder.Callback.surfaceChanged() size: 1440 x 3052

[ +102 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.text_displayed_outside/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[ +362 ms] V/FlutterActivityAndFragmentDelegate(10988): Setting up FlutterEngine.
[        ] V/FlutterActivityAndFragmentDelegate(10988): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
[ +300 ms] V/FlutterEngine(10988): Attaching to JNI.
[  +35 ms] V/FlutterActivityAndFragmentDelegate(10988): Attaching FlutterEngine to the Activity that owns this delegate.
[        ] V/FlutterEngineCxnRegstry(10988): Attaching to an exclusive Activity: com.example.text_displayed_outside.MainActivity@3f1d2f8.
[        ] V/FlutterActivityAndFragmentDelegate(10988): onRestoreInstanceState. Giving framework and plugins an opportunity to restore state.
[        ] V/FlutterEngineCxnRegstry(10988): Forwarding onRestoreInstanceState() to plugins.
[        ] V/FlutterActivityAndFragmentDelegate(10988): Creating FlutterView.
[        ] V/FlutterView(10988): Initializing FlutterView
[        ] V/FlutterView(10988): Internally using a FlutterSurfaceView.
[        ] V/FlutterActivityAndFragmentDelegate(10988): Attaching FlutterEngine to FlutterView.
[        ] V/FlutterView(10988): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@be4ce36
[        ] V/FlutterSurfaceView(10988): Attaching to FlutterRenderer.
[  +28 ms] V/FlutterActivityAndFragmentDelegate(10988): onStart()
[        ] V/FlutterActivityAndFragmentDelegate(10988): Executing Dart entrypoint: main, and sending initial route: /
[        ] V/FlutterActivityAndFragmentDelegate(10988): onResume()
[        ] V/FlutterActivityAndFragmentDelegate(10988): onPostResume()
[  +22 ms] V/FlutterView(10988): Updating window insets (onApplyWindowInsets()):
[        ] V/FlutterView(10988): Status bar insets: Top: 156, Left: 0, Right: 0
[        ] V/FlutterView(10988): Keyboard insets: Bottom: 0, Left: 0, Right: 0System Gesture Insets - Left: 102, Top: 156, Right: 102, Bottom: 0
[  +12 ms] V/FlutterView(10988): Updating window insets (onApplyWindowInsets()):
[        ] V/FlutterView(10988): Status bar insets: Top: 156, Left: 0, Right: 0
[        ] V/FlutterView(10988): Keyboard insets: Bottom: 0, Left: 0, Right: 0System Gesture Insets - Left: 102, Top: 156, Right: 102, Bottom: 0
[   +1 ms] V/FlutterView(10988): Size changed. Sending Flutter new viewport metrics. FlutterView was 0 x 0, it is now 1440 x 3052
[        ] V/FlutterRenderer(10988): Setting viewport metrics
[        ] V/FlutterRenderer(10988): Size: 1440 x 3052
[        ] V/FlutterRenderer(10988): Padding - L: 0, T: 156, R: 0, B: 0
[        ] V/FlutterRenderer(10988): Insets - L: 0, T: 0, R: 0, B: 0
[        ] V/FlutterRenderer(10988): System Gesture Insets - L: 102, T: 156, R: 102, B: 0
[   +2 ms] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.startRenderingToSurface()
[ +102 ms] Observatory URL on device: http://127.0.0.1:40167/m7oIDBmzJoQ=/
[   +1 ms] executing: /Users/haoan/Library/Android/sdk/platform-tools/adb -s 638c42ed forward tcp:0 tcp:40167
[  +12 ms] 55719
[        ] Forwarded host port 55719 to device port 40167 for Observatory
[   +9 ms] Caching compiled dill
[ +137 ms] Connecting to service protocol: http://127.0.0.1:55719/m7oIDBmzJoQ=/
[  +27 ms] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.surfaceChanged()
[        ] V/FlutterSurfaceView(10988): Notifying FlutterRenderer that Android surface size has changed to 1440 x 3052
[ +205 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:55719/m7oIDBmzJoQ=/.
[ +163 ms] DDS is listening at http://127.0.0.1:55728/BUxL3cI0Io8=/.
[  +88 ms] Successfully connected to service protocol: http://127.0.0.1:55719/m7oIDBmzJoQ=/
[  +71 ms] DevFS: Creating new filesystem on the device (null)
[  +29 ms] DevFS: Created new filesystem on the device
(file:///data/user/0/com.example.text_displayed_outside/code_cache/text_displayed_outsideBAMXRJ/text_displayed_outside/)
[   +2 ms] Updating assets
[  +91 ms] Syncing files to device GM1910...
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +2 ms] <- recompile package:text_displayed_outside/main.dart 7695db29-6381-4328-9873-52be0fdd6fc0
[        ] <- 7695db29-6381-4328-9873-52be0fdd6fc0
[  +79 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Syncing files to device GM1910... (completed in 84ms)
[        ] Synced 0.0MB.
[   +1 ms] <- accept
[   +5 ms] Connected to _flutterView/0xb400007d0dfd6870.
[   +3 ms] Flutter run key commands.
[   +2 ms] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] 💪 Running with sound null safety 💪
[        ] An Observatory debugger and profiler on GM1910 is available at: http://127.0.0.1:55728/BUxL3cI0Io8=/
[ +176 ms] V/DartMessenger(10988): Received message from Dart over channel 'flutter/platform'
[        ] V/DartMessenger(10988): Deferring to registered handler to process message.
[        ] V/PlatformChannel(10988): Received 'SystemChrome.setSystemUIOverlayStyle' message.
[  +62 ms] V/FlutterSurfaceView(10988): onFlutterUiDisplayed()
[   +6 ms] D/OpScreenModeManager(10988): setRefreshRate parent io.flutter.embedding.android.FlutterView{9eca63c VFE...... ........ 0,0-1440,3052 #1} parent width 1440 parent
height 3052 mRatio 1.2
[   +1 ms] D/OpScreenModeManager(10988): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{cca502f V.E...... ........ 0,0-1440,3052} viewRate 1 width 1440
height 3052
[  +48 ms] D/DecorView(10988): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@2fbea28[MainActivity]
[        ] D/PhoneWindow(10988): notifyNavBarColor: ff000000, com.example.text_displayed_outside, topClass:com.example.text_displayed_outside.MainActivity
[   +1 ms] V/ViewRootImplInjector(10988): onlineConfig changed, sMultiTouchGameList=[com.tencent.tmgp.sgame, com.tencent.tmgp.speedmobile, com.tencent.tmgp.pubgmhd,
com.netease.onmyoji, com.zhangyangjing.starfish, com.tencent.ig, com.rekoo.pubgm, com.the511plus.MultiTouchTester, com.netease.mrzh.nearme.gamecenter, com.netease.mrzh,
com.antutu.ABenchMark]
[   +2 ms] D/ViewRootImpl[MainActivity](10988): windowFocusChanged hasFocus=true inTouchMode=true
[        ] D/ViewRootImplInjector(10988): [GESTURE_BUTTON] mGestureButtonHeight= 68 mSideGestureButtonEnabled=true mHomeGestureWidthPort=901 mHomeGestureWidthLand=1942
mAssistamtGestureWidthPort=204 mAssistamtGestureWidthLand=204
[   +1 ms] V/ImeFocusController(10988): checkFocus: view=null next=DecorView@2fbea28[MainActivity] force=true package=<none>
[        ] V/InputMethodManager(10988): Starting input:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true reason=WINDOW_FOCUS_GAIN
[        ] V/InputMethodManager(10988): Starting input: tba=android.view.inputmethod.EditorInfo@55b30e6 ic=null
[        ] V/InputMethodManager(10988): START INPUT:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true ic=null tba=android.view.inputmethod.EditorInfo@55b30e6 startInputFlags=VIEW_HAS_FOCUS|INITIAL_CONNECTION
[        ] V/InputMethodManager(10988): Starting input: Bind result=InputBindResult{result=SUCCESS_WAITING_IME_SESSION method=null id=com.baidu.input_yijia/.ImeService
sequence=1563 activityViewToScreenMatrix=null}
[        ] V/InputMethodManager(10988): Starting input:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true reason=BOUND_TO_IMMS
[        ] V/InputMethodManager(10988): Starting input: tba=android.view.inputmethod.EditorInfo@89e1627 ic=null
[        ] V/InputMethodManager(10988): Starting input: finished by someone else.
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true
servedView=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,
hasImeFocus=true mServedConnecting=false
[ +443 ms] DevTools activation throttled until 2022-01-15 03:03:02.116330.
[ +838 ms] The Flutter DevTools debugger and profiler on GM1910 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:55728/BUxL3cI0Io8=/

--------------------------------------- Turn off the screen --------------------------------------------------------------

[+21352 ms] V/ImeFocusController(10988): checkFocus: view=DecorView@2fbea28[MainActivity] next=DecorView@2fbea28[MainActivity] force=true
package=com.example.text_displayed_outside
[        ] V/InputMethodManager(10988): Starting input:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true reason=DEACTIVATED_BY_IMMS
[        ] V/InputMethodManager(10988): Starting input: tba=android.view.inputmethod.EditorInfo@e0576be ic=null
[   +1 ms] V/InputMethodManager(10988): START INPUT:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true ic=null tba=android.view.inputmethod.EditorInfo@e0576be startInputFlags=VIEW_HAS_FOCUS|INITIAL_CONNECTION
[        ] V/InputMethodManager(10988): Starting input: Bind result=InputBindResult{result=SUCCESS_WITH_IME_SESSION
method=com.android.internal.view.IInputMethodSession$Stub$Proxy@775a31f id=com.baidu.input_yijia/.ImeService sequence=1564 activityViewToScreenMatrix=null}
[ +146 ms] V/FlutterActivityAndFragmentDelegate(10988): onPause()
[        ] V/LifecycleChannel(10988): Sending AppLifecycleState.inactive message.
[        ] V/DartMessenger(10988): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 performPause in 0ms
[ +168 ms] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.stopRenderingToSurface()
[  +30 ms] V/FlutterActivityAndFragmentDelegate(10988): onStop()
[   +6 ms] V/LifecycleChannel(10988): Sending AppLifecycleState.paused message.
[        ] V/DartMessenger(10988): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 onStop in 2ms
[   +7 ms] V/FlutterActivityAndFragmentDelegate(10988): onSaveInstanceState. Giving framework and plugins an opportunity to save state.
[        ] V/FlutterEngineCxnRegstry(10988): Forwarding onSaveInstanceState() to plugins.
[        ] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 performSaveInstanceState in 1ms
[        ] D/ActivityThread(10988): override visible to true while stopped. name=
ComponentInfo{com.example.text_displayed_outside/com.example.text_displayed_outside.MainActivity}
[ +113 ms] V/ViewRootImplInjector(10988): onlineConfig changed, sMultiTouchGameList=[com.tencent.tmgp.sgame, com.tencent.tmgp.speedmobile, com.tencent.tmgp.pubgmhd,
com.netease.onmyoji, com.zhangyangjing.starfish, com.tencent.ig, com.rekoo.pubgm, com.the511plus.MultiTouchTester, com.netease.mrzh.nearme.gamecenter, com.netease.mrzh,
com.antutu.ABenchMark]
[        ] D/ViewRootImpl[MainActivity](10988): windowFocusChanged hasFocus=false inTouchMode=true
[   +9 ms] D/ViewRootImplInjector(10988): [GESTURE_BUTTON] mGestureButtonHeight= 68 mSideGestureButtonEnabled=true mHomeGestureWidthPort=901 mHomeGestureWidthLand=1942
mAssistamtGestureWidthPort=204 mAssistamtGestureWidthLand=204
[  +77 ms] D/DecorView(10988): callNavBarColor: color=ff000000, barColor=ff000000, flag=81810100, mSemiTransparentBarColor=66000000, sysuiVis=500, scrimTrans=false
[        ] V/FlutterView(10988): Updating window insets (onApplyWindowInsets()):
[        ] V/FlutterView(10988): Status bar insets: Top: 156, Left: 0, Right: 0
[        ] V/FlutterView(10988): Keyboard insets: Bottom: 0, Left: 0, Right: 0System Gesture Insets - Left: 102, Top: 156, Right: 102, Bottom: 0
[        ] V/FlutterRenderer(10988): Setting viewport metrics
[        ] V/FlutterRenderer(10988): Size: 1440 x 3052
[        ] V/FlutterRenderer(10988): Padding - L: 0, T: 156, R: 0, B: 0
[        ] V/FlutterRenderer(10988): Insets - L: 0, T: 0, R: 0, B: 0
[        ] V/FlutterRenderer(10988): System Gesture Insets - L: 102, T: 156, R: 102, B: 0
[   +6 ms] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.startRenderingToSurface()
[        ] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.surfaceChanged()
[        ] V/FlutterSurfaceView(10988): Notifying FlutterRenderer that Android surface size has changed to 1440 x 3052
[   +2 ms] D/OpScreenModeManager(10988): setRefreshRate parent io.flutter.embedding.android.FlutterView{9eca63c VFE...... ........ 0,0-1440,3052 #1} parent width 1440 parent
height 3052 mRatio 1.2
[        ] D/OpScreenModeManager(10988): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{cca502f V.E...... ........ 0,0-1440,3052} viewRate 1 width 1440
height 3052
[        ] V/FlutterView(10988): Size changed. Sending Flutter new viewport metrics. FlutterView was 1440 x 3052, it is now 1440 x 3120
[        ] V/FlutterRenderer(10988): Setting viewport metrics
[        ] V/FlutterRenderer(10988): Size: 1440 x 3120
[        ] V/FlutterRenderer(10988): Padding - L: 0, T: 156, R: 0, B: 0
[        ] V/FlutterRenderer(10988): Insets - L: 0, T: 0, R: 0, B: 0
[        ] V/FlutterRenderer(10988): System Gesture Insets - L: 102, T: 156, R: 102, B: 0
[        ] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.surfaceChanged()
[        ] V/FlutterSurfaceView(10988): Notifying FlutterRenderer that Android surface size has changed to 1440 x 3120
[   +1 ms] D/OpScreenModeManager(10988): setRefreshRate parent io.flutter.embedding.android.FlutterView{9eca63c VFE...... ......ID 0,0-1440,3120 #1} parent width 1440 parent
height 3120 mRatio 1.2
[   +5 ms] D/OpScreenModeManager(10988): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{cca502f V.E...... ......ID 0,0-1440,3120} viewRate 1 width 1440
height 3120
[        ] D/OpScreenModeManager(10988): setRefreshRate parent io.flutter.embedding.android.FlutterView{9eca63c VFE...... ........ 0,0-1440,3120 #1} parent width 1440 parent
height 3120 mRatio 1.2
[        ] D/OpScreenModeManager(10988): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{cca502f V.E...... ........ 0,0-1440,3120} viewRate 1 width 1440
height 3120

--------------------------------------- Turn on the screen --------------------------------------------------------------

[+27651 ms] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 onRestart in 0ms
[  +33 ms] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 onStart begin
[   +2 ms] V/FlutterActivityAndFragmentDelegate(10988): onStart()
[        ] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 onStart in 2ms
[        ] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 onResume begin
[        ] V/FlutterActivityAndFragmentDelegate(10988): onResume()
[        ] V/LifecycleChannel(10988): Sending AppLifecycleState.resumed message.
[        ] V/DartMessenger(10988): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(10988): com.example.text_displayed_outside.MainActivity@3f1d2f8 onResume in 2ms
[        ] V/FlutterActivityAndFragmentDelegate(10988): onPostResume()
[  +12 ms] D/DecorView(10988): callNavBarColor: color=ff000000, barColor=ff000000, flag=81810100, mSemiTransparentBarColor=66000000, sysuiVis=500, scrimTrans=false
[        ] V/FlutterView(10988): Updating window insets (onApplyWindowInsets()):
[        ] V/FlutterView(10988): Status bar insets: Top: 156, Left: 0, Right: 0
[        ] V/FlutterView(10988): Keyboard insets: Bottom: 0, Left: 0, Right: 0System Gesture Insets - Left: 102, Top: 156, Right: 102, Bottom: 0
[        ] V/FlutterRenderer(10988): Setting viewport metrics
[        ] V/FlutterRenderer(10988): Size: 1440 x 3120
[        ] V/FlutterRenderer(10988): Padding - L: 0, T: 156, R: 0, B: 0
[        ] V/FlutterRenderer(10988): Insets - L: 0, T: 0, R: 0, B: 0
[        ] V/FlutterRenderer(10988): System Gesture Insets - L: 102, T: 156, R: 102, B: 0
[        ] V/FlutterView(10988): Size changed. Sending Flutter new viewport metrics. FlutterView was 1440 x 3120, it is now 1440 x 3052
[        ] V/FlutterRenderer(10988): Setting viewport metrics
[        ] V/FlutterRenderer(10988): Size: 1440 x 3052
[        ] V/FlutterRenderer(10988): Padding - L: 0, T: 156, R: 0, B: 0
[        ] V/FlutterRenderer(10988): Insets - L: 0, T: 0, R: 0, B: 0
[        ] V/FlutterRenderer(10988): System Gesture Insets - L: 102, T: 156, R: 102, B: 0
[        ] V/FlutterSurfaceView(10988): SurfaceHolder.Callback.surfaceChanged()
[        ] V/FlutterSurfaceView(10988): Notifying FlutterRenderer that Android surface size has changed to 1440 x 3052
[        ] D/OpScreenModeManager(10988): setRefreshRate parent io.flutter.embedding.android.FlutterView{9eca63c VFE...... ......ID 0,0-1440,3052 #1} parent width 1440 parent
height 3052 mRatio 1.2
[        ] D/OpScreenModeManager(10988): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{cca502f V.E...... ......ID 0,0-1440,3052} viewRate 1 width 1440
height 3052
[   +9 ms] D/OpScreenModeManager(10988): setRefreshRate parent io.flutter.embedding.android.FlutterView{9eca63c VFE...... ........ 0,0-1440,3052 #1} parent width 1440 parent
height 3052 mRatio 1.2
[        ] D/OpScreenModeManager(10988): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{cca502f V.E...... ........ 0,0-1440,3052} viewRate 1 width 1440
height 3052
[  +92 ms] D/DecorView(10988): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@2fbea28[MainActivity]
[        ] D/PhoneWindow(10988): notifyNavBarColor: ff000000, com.example.text_displayed_outside, topClass:com.example.text_displayed_outside.MainActivity
[        ] V/ViewRootImplInjector(10988): onlineConfig changed, sMultiTouchGameList=[com.tencent.tmgp.sgame, com.tencent.tmgp.speedmobile, com.tencent.tmgp.pubgmhd,
com.netease.onmyoji, com.zhangyangjing.starfish, com.tencent.ig, com.rekoo.pubgm, com.the511plus.MultiTouchTester, com.netease.mrzh.nearme.gamecenter, com.netease.mrzh,
com.antutu.ABenchMark]
[        ] D/ViewRootImpl[MainActivity](10988): windowFocusChanged hasFocus=true inTouchMode=true
[        ] D/ViewRootImplInjector(10988): [GESTURE_BUTTON] mGestureButtonHeight= 68 mSideGestureButtonEnabled=true mHomeGestureWidthPort=901 mHomeGestureWidthLand=1942
mAssistamtGestureWidthPort=204 mAssistamtGestureWidthLand=204
[        ] V/ImeFocusController(10988): checkFocus: view=DecorView@2fbea28[MainActivity] next=DecorView@2fbea28[MainActivity] force=true
package=com.example.text_displayed_outside
[        ] V/InputMethodManager(10988): Starting input:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true reason=WINDOW_FOCUS_GAIN
[        ] V/InputMethodManager(10988): Starting input: tba=android.view.inputmethod.EditorInfo@2479f96 ic=null
[        ] V/InputMethodManager(10988): START INPUT:
view=DecorView@2fbea28[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@98b1341,displayId=0,temporaryDetach=false,hasIme
Focus=true ic=null tba=android.view.inputmethod.EditorInfo@2479f96 startInputFlags=VIEW_HAS_FOCUS|INITIAL_CONNECTION
[        ] V/InputMethodManager(10988): Starting input: Bind result=InputBindResult{result=SUCCESS_WITH_IME_SESSION
method=com.android.internal.view.IInputMethodSession$Stub$Proxy@f22d717 id=com.baidu.input_yijia/.ImeService sequence=1566 activityViewToScreenMatrix=null}

OnePlus display black screen

black screen case 1

// 1. app start
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged()  size: 1440 x 3052
// 2. turn off the screen
SurfaceHolder.Callback.stopRenderingToSurface()
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged() size: 1440 x 3052
// 3. turn on the screen
// do nothing


[  +69 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.text_displayed_outside/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[ +145 ms] V/FlutterActivityAndFragmentDelegate(12750): Setting up FlutterEngine.
[        ] V/FlutterActivityAndFragmentDelegate(12750): No preferred FlutterEngine was provided. Creating a new FlutterEngine for this FlutterFragment.
[  +16 ms] V/FlutterEngine(12750): Attaching to JNI.
[  +20 ms] V/FlutterActivityAndFragmentDelegate(12750): Attaching FlutterEngine to the Activity that owns this delegate.
[   +1 ms] V/FlutterEngineCxnRegstry(12750): Attaching to an exclusive Activity: com.example.text_displayed_outside.MainActivity@921f15e.
[   +1 ms] V/FlutterActivityAndFragmentDelegate(12750): onRestoreInstanceState. Giving framework and plugins an opportunity to restore state.
[        ] V/FlutterEngineCxnRegstry(12750): Forwarding onRestoreInstanceState() to plugins.
[        ] V/FlutterActivityAndFragmentDelegate(12750): Creating FlutterView.
[   +5 ms] V/FlutterView(12750): Initializing FlutterView
[        ] V/FlutterView(12750): Internally using a FlutterSurfaceView.
[        ] V/FlutterActivityAndFragmentDelegate(12750): Attaching FlutterEngine to FlutterView.
[        ] V/FlutterView(12750): Attaching to a FlutterEngine: io.flutter.embedding.engine.FlutterEngine@776a20c
[        ] V/FlutterSurfaceView(12750): Attaching to FlutterRenderer.
[  +22 ms] V/FlutterActivityAndFragmentDelegate(12750): onStart()
[   +2 ms] V/FlutterActivityAndFragmentDelegate(12750): Executing Dart entrypoint: main, and sending initial route: /
[        ] V/FlutterActivityAndFragmentDelegate(12750): onResume()
[        ] V/FlutterActivityAndFragmentDelegate(12750): onPostResume()
[  +25 ms] V/FlutterView(12750): Updating window insets (onApplyWindowInsets()):
[        ] V/FlutterView(12750): Status bar insets: Top: 156, Left: 0, Right: 0
[        ] V/FlutterView(12750): Keyboard insets: Bottom: 0, Left: 0, Right: 0System Gesture Insets - Left: 102, Top: 156, Right: 102, Bottom: 0
[  +16 ms] V/FlutterView(12750): Updating window insets (onApplyWindowInsets()):
[        ] V/FlutterView(12750): Status bar insets: Top: 156, Left: 0, Right: 0
[        ] V/FlutterView(12750): Keyboard insets: Bottom: 0, Left: 0, Right: 0System Gesture Insets - Left: 102, Top: 156, Right: 102, Bottom: 0
[        ] V/FlutterView(12750): Size changed. Sending Flutter new viewport metrics. FlutterView was 0 x 0, it is now 1440 x 3052
[        ] V/FlutterRenderer(12750): Setting viewport metrics
[        ] V/FlutterRenderer(12750): Size: 1440 x 3052
[        ] V/FlutterRenderer(12750): Padding - L: 0, T: 156, R: 0, B: 0
[        ] V/FlutterRenderer(12750): Insets - L: 0, T: 0, R: 0, B: 0
[        ] V/FlutterRenderer(12750): System Gesture Insets - L: 102, T: 156, R: 102, B: 0
[        ] V/FlutterSurfaceView(12750): SurfaceHolder.Callback.startRenderingToSurface()
[  +68 ms] Observatory URL on device: http://127.0.0.1:42835/FrgOtFmDKhI=/
[   +1 ms] executing: /Users/haoan/Library/Android/sdk/platform-tools/adb -s 638c42ed forward tcp:0 tcp:42835
[  +12 ms] 61641
[        ] Forwarded host port 61641 to device port 42835 for Observatory
[   +9 ms] Caching compiled dill
[  +71 ms] Connecting to service protocol: http://127.0.0.1:61641/FrgOtFmDKhI=/
[  +28 ms] V/FlutterSurfaceView(12750): SurfaceHolder.Callback.surfaceChanged()
[        ] V/FlutterSurfaceView(12750): Notifying FlutterRenderer that Android surface size has changed to 1440 x 3052
[ +215 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:61641/FrgOtFmDKhI=/.
[ +142 ms] DDS is listening at http://127.0.0.1:61646/GdUypoxTXvs=/.
[  +67 ms] Successfully connected to service protocol: http://127.0.0.1:61641/FrgOtFmDKhI=/
[  +82 ms] DevFS: Creating new filesystem on the device (null)
[  +21 ms] DevFS: Created new filesystem on the device
(file:///data/user/0/com.example.text_displayed_outside/code_cache/text_displayed_outsideSVEVPN/text_displayed_outside/)
[   +2 ms] Updating assets
[  +77 ms] Syncing files to device GM1910...
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +2 ms] <- recompile package:text_displayed_outside/main.dart a5fd8e53-262d-498d-a9f1-30362ed1d093
[        ] <- a5fd8e53-262d-498d-a9f1-30362ed1d093


--------------------------------------- Turn off the screen --------------------------------------------------------------

[   +3 ms] V/FlutterActivityAndFragmentDelegate(12750): onPause()
[        ] V/LifecycleChannel(12750): Sending AppLifecycleState.inactive message.
[        ] V/DartMessenger(12750): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e performPause in 0ms
[        ] V/FlutterSurfaceView(12750): SurfaceHolder.Callback.stopRenderingToSurface()
[ +137 ms] Updating files.
[        ] DevFS: Sync finished
[        ] Syncing files to device GM1910... (completed in 146ms)
[        ] Synced 0.0MB.
[   +1 ms] <- accept
[   +5 ms] Connected to _flutterView/0xb400007d0dfee6d0.
[   +3 ms] Flutter run key commands.
[   +1 ms] r Hot reload. 🔥🔥🔥
[        ] R Hot restart.
[        ] h List all available interactive commands.
[        ] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] 💪 Running with sound null safety 💪
[        ] An Observatory debugger and profiler on GM1910 is available at: http://127.0.0.1:61646/GdUypoxTXvs=/
[ +291 ms] DevTools activation throttled until 2022-01-15 03:03:02.116330.
[ +996 ms] V/FlutterActivityAndFragmentDelegate(12750): onStop()
[        ] V/LifecycleChannel(12750): Sending AppLifecycleState.paused message.
[        ] V/DartMessenger(12750): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onStop in 2ms
[        ] V/FlutterActivityAndFragmentDelegate(12750): onSaveInstanceState. Giving framework and plugins an opportunity to save state.
[        ] V/FlutterEngineCxnRegstry(12750): Forwarding onSaveInstanceState() to plugins.
[   +3 ms] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e performSaveInstanceState in 2ms
[        ] D/ActivityThread(12750): override visible to true while stopped. name=
ComponentInfo{com.example.text_displayed_outside/com.example.text_displayed_outside.MainActivity}
[   +2 ms] V/DartMessenger(12750): Received message from Dart over channel 'flutter/platform'
[        ] V/DartMessenger(12750): Deferring to registered handler to process message.
[        ] V/PlatformChannel(12750): Received 'SystemChrome.setSystemUIOverlayStyle' message.
[        ] V/FlutterSurfaceView(12750): onFlutterUiDisplayed()
[   +1 ms] I/Choreographer(12750): Skipped 130 frames!  The application may be doing too much work on its main thread.
[  +14 ms] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onRestart in 0ms
[   +8 ms] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onStart begin
[        ] V/FlutterActivityAndFragmentDelegate(12750): onStart()
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onStart in 0ms
[   +1 ms] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onResume begin
[        ] V/FlutterActivityAndFragmentDelegate(12750): onResume()
[        ] V/LifecycleChannel(12750): Sending AppLifecycleState.resumed message.
[        ] V/DartMessenger(12750): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onResume in 8ms
[        ] V/FlutterActivityAndFragmentDelegate(12750): onPostResume()
[  +10 ms] V/FlutterActivityAndFragmentDelegate(12750): onPause()
[        ] V/LifecycleChannel(12750): Sending AppLifecycleState.inactive message.
[        ] V/DartMessenger(12750): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e performPause in 1ms
[  +15 ms] V/FlutterActivityAndFragmentDelegate(12750): onStop()
[        ] V/LifecycleChannel(12750): Sending AppLifecycleState.paused message.
[        ] V/DartMessenger(12750): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onStop in 1ms
[   +3 ms] V/FlutterActivityAndFragmentDelegate(12750): onSaveInstanceState. Giving framework and plugins an opportunity to save state.
[        ] V/FlutterEngineCxnRegstry(12750): Forwarding onSaveInstanceState() to plugins.
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e performSaveInstanceState in 0ms
[        ] D/ActivityThread(12750): override visible to true while stopped. name=
ComponentInfo{com.example.text_displayed_outside/com.example.text_displayed_outside.MainActivity}
[  +31 ms] V/FlutterSurfaceView(12750): SurfaceHolder.Callback.startRenderingToSurface()
[  +56 ms] V/FlutterSurfaceView(12750): SurfaceHolder.Callback.surfaceChanged()
[        ] V/FlutterSurfaceView(12750): Notifying FlutterRenderer that Android surface size has changed to 1440 x 3052
[   +3 ms] The Flutter DevTools debugger and profiler on GM1910 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:61646/GdUypoxTXvs=/
[        ] D/OpScreenModeManager(12750): setRefreshRate parent io.flutter.embedding.android.FlutterView{c2797c2 VFE...... ......ID 0,0-1440,3052 #1} parent width 1440 parent
height 3052 mRatio 1.2
[        ] D/OpScreenModeManager(12750): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{7979c0d V.E...... ......ID 0,0-1440,3052} viewRate 1 width 1440
height 3052
[   +6 ms] D/OpScreenModeManager(12750): setRefreshRate parent io.flutter.embedding.android.FlutterView{c2797c2 VFE...... ........ 0,0-1440,3052 #1} parent width 1440 parent
height 3052 mRatio 1.2
[        ] D/OpScreenModeManager(12750): setRefreshRate view io.flutter.embedding.android.FlutterSurfaceView{7979c0d V.E...... ........ 0,0-1440,3052} viewRate 1 width 1440
height 3052

--------------------------------------- Turn on the screen --------------------------------------------------------------

[ +765 ms] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onRestart in 1ms
[  +18 ms] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onStart begin
[        ] V/FlutterActivityAndFragmentDelegate(12750): onStart()
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onStart in 0ms
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onResume begin
[        ] V/FlutterActivityAndFragmentDelegate(12750): onResume()
[        ] V/LifecycleChannel(12750): Sending AppLifecycleState.resumed message.
[        ] V/DartMessenger(12750): Sending message with callback over channel 'flutter/lifecycle'
[        ] I/Instrumentation(12750): com.example.text_displayed_outside.MainActivity@921f15e onResume in 2ms
[        ] V/FlutterActivityAndFragmentDelegate(12750): onPostResume()
[  +81 ms] D/DecorView(12750): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@3db6e0e[MainActivity]
[        ] D/PhoneWindow(12750): notifyNavBarColor: ff000000, com.example.text_displayed_outside, topClass:com.example.text_displayed_outside.MainActivity
[        ] V/ViewRootImplInjector(12750): onlineConfig changed, sMultiTouchGameList=[com.tencent.tmgp.sgame, com.tencent.tmgp.speedmobile, com.tencent.tmgp.pubgmhd,
com.netease.onmyoji, com.zhangyangjing.starfish, com.tencent.ig, com.rekoo.pubgm, com.the511plus.MultiTouchTester, com.netease.mrzh.nearme.gamecenter, com.netease.mrzh,
com.antutu.ABenchMark]
[        ] D/ViewRootImpl[MainActivity](12750): windowFocusChanged hasFocus=true inTouchMode=true
[   +1 ms] D/ViewRootImplInjector(12750): [GESTURE_BUTTON] mGestureButtonHeight= 68 mSideGestureButtonEnabled=true mHomeGestureWidthPort=901 mHomeGestureWidthLand=1942
mAssistamtGestureWidthPort=204 mAssistamtGestureWidthLand=204
[        ] V/ImeFocusController(12750): checkFocus: view=null next=DecorView@3db6e0e[MainActivity] force=true package=<none>
[        ] V/InputMethodManager(12750): Starting input:
view=DecorView@3db6e0e[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@cca502f,displayId=0,temporaryDetach=false,hasIme
Focus=true reason=WINDOW_FOCUS_GAIN
[        ] V/InputMethodManager(12750): Starting input: tba=android.view.inputmethod.EditorInfo@9eca63c ic=null
[        ] V/InputMethodManager(12750): START INPUT:
view=DecorView@3db6e0e[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@cca502f,displayId=0,temporaryDetach=false,hasIme
Focus=true ic=null tba=android.view.inputmethod.EditorInfo@9eca63c startInputFlags=VIEW_HAS_FOCUS|INITIAL_CONNECTION
[        ] V/InputMethodManager(12750): Starting input: Bind result=InputBindResult{result=SUCCESS_WAITING_IME_SESSION method=null id=com.baidu.input_yijia/.ImeService
sequence=1590 activityViewToScreenMatrix=null}
[   +9 ms] V/InputMethodManager(12750): Starting input:
view=DecorView@3db6e0e[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@cca502f,displayId=0,temporaryDetach=false,hasIme
Focus=true reason=BOUND_TO_IMMS
[        ] V/InputMethodManager(12750): Starting input: tba=android.view.inputmethod.EditorInfo@2d13fc5 ic=null
[        ] V/InputMethodManager(12750): Starting input: finished by someone else.
view=DecorView@3db6e0e[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@cca502f,displayId=0,temporaryDetach=false,hasIme
Focus=true
servedView=DecorView@3db6e0e[MainActivity],focus=false,windowFocus=true,autofillUiShowing=false,window=android.view.ViewRootImpl$W@cca502f,displayId=0,temporaryDetach=false,
hasImeFocus=true mServedConnecting=false

black screen case 2

// 1. app start
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged()  size: 1440 x 3052
// 2. turn off the screen
SurfaceHolder.Callback.stopRenderingToSurface()
SurfaceHolder.Callback.startRenderingToSurface()
SurfaceHolder.Callback.surfaceChanged() size: 1440 x 3052
// 3. turn on the screen
SurfaceHolder.Callback.surfaceChanged() size: 1440 x 3052

The detail log at the time was not recorded.

Since AndroidSurfaceGL::onscreen_surface_ will only be recreated when the SurfaceHolder.Callback.startRenderingToSurface() is called or SurfaceHolder.Callback.surfaceChanged() is called with different size. On the black screen case1 , no those methods are called. On the black screen case2 , SurfaceHolder.Callback.surfaceChanged() is called,but size is not different than before. So in these two cases, AndroidSurfaceGL::onscreen_surface_ is not recreated after screen turned on.

AFAICS, if AndroidSurfaceGL::onscreen_surface_ has not been recreated after the screen is turned on, it will show a black screen.

flutter doctor -v

``` [✓] Flutter (Channel stable/v2.5.3.xianyu, 2.5.4-0.0.pre.25, on macOS 11.5.2 20G95 darwin-x64, locale zh-Hans-CN) • Flutter version 2.5.4-0.0.pre.25 • Framework revision 59bd29558b (3 weeks ago), 2021-12-24 19:11:50 +0800 • Engine revision f16240bafd • Dart version 2.14.4

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at /Users/haoan/Library/Android/sdk
✗ cmdline-tools component is missing
Run path/to/sdkmanager --install "cmdline-tools;latest"
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run flutter doctor --android-licenses to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5, Build version 12E262
• CocoaPods version 1.11.2

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

[✓] Android Studio (version 2020.3)
• 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.10+0-b96-7281165)

[✓] IntelliJ IDEA Community Edition (version 2017.3.3)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• 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

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

[!] Proxy Configuration
• HTTP_PROXY is set
! NO_PROXY is not set

[✓] Connected device (3 available)
• GM1910 (mobile) • 638c42ed • android-arm64 • Android 11 (API 30)
• macOS (desktop) • macos • darwin-x64 • macOS 11.5.2 20G95 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 97.0.4692.71

</details>












@dnfield
Copy link
Contributor

dnfield commented Jan 14, 2022

Sounds like we need to check if surface changed got called without a surface created and if so, insert creation. This is almost certainly a vendor bug though.

@ColdPaleLight
Copy link
Member

ColdPaleLight commented Jan 14, 2022

Sounds like we need to check if surface changed got called without a surface created and if so, insert creation. This is almost certainly a vendor bug though.

Here I have encountered two situations. The first is that only surfaceChanged is called after the screen is turned on. The second is that even surfaceChanged is not called after the screen is turned on (no method is called). The first case be solved by the solution you mentioned, but the second case can not.

@dnfield
Copy link
Contributor

dnfield commented Jan 14, 2022

I see.

Is the FlutterSurfaceView.init getting called in the case where we never get any callbacks?

@dnfield
Copy link
Contributor

dnfield commented Jan 14, 2022

Another thing to look at: if we implemented https://developer.android.com/reference/android/view/SurfaceHolder.Callback2 instead, do we get surfaceRedrawNeeded calls even if there's no surfaceCreated call?

@ColdPaleLight
Copy link
Member

@dnfield @blasten

According to the log, surfaceCreated is actually called, but not when the screen is turned on, it's called when the screen is turned off.

Usually, when the Activity/Fragment enters onStop, the window will be in an invisible state, and the view tree will not be updated. In theory surfaceCreated should not be called when the screen is turned off. But the one plus mobile phone can update the view tree when screen turned off. When I turned off the screen, I saw such a line of log.

2022-01-15 00:22:29.102 29257-29257/com.example.text_displayed_outside D/ActivityThread: override visible to true while stopped. name= ComponentInfo{com.example.text_displayed_outside/com.example.text_displayed_outside.MainActivity}

It seemed that the OnePlus phone forced the window in visible state when the Activity/Fragment enters onStop , so the view tree could still be updated, and the surfaceCreated could also be called.

I found a way to fix this:
Set the visibility of FlutterSurfaceView to View.GONE when onStop, and set it to View.VISIBLE when onStart. It works well in my OnePlus phone. Here is the PR:
flutter/engine#30897

Please let me know if you guys have any thoughts on this?

@thomasaldershof
Copy link
Author

thomasaldershof commented Jan 16, 2022

Sounds like we need to check if surface changed got called without a surface created and if so, insert creation. This is almost certainly a vendor bug though.

I'd say not. Almost every major brand has issues with this. Xiaomi, Samsung, huawei, pixel, iPhones, and probably more.

@ColdPaleLight if I have the time I'll try it tomorrow.

@ColdPaleLight
Copy link
Member

@vanth0me @RaymondBakker @davidmartos96
Can you guys try this and see if this issue can be avoided?
#94921 (comment)

@RaymondBakker
Copy link

@ColdPaleLight The code that @AlexV525 posted at #94921 (comment) fixes the issue for me. It also gets rid of the occasional black flickering when turning the screen back on.

@thomasaldershof
Copy link
Author

@vanth0me @RaymondBakker @davidmartos96 Can you guys try this and see if this issue can be avoided? #94921 (comment)

Did not fix it for me for the black screen bug when the app has been in de background. Was unable to reproduce the blacksreen launching the app and locking/unlocking the phone. Could also be me being unlucky, but who knows.

@dnfield
Copy link
Contributor

dnfield commented Jan 18, 2022

Sounds like we need to check if surface changed got called without a surface created and if so, insert creation. This is almost certainly a vendor bug though.

I'd say not. Almost every major brand has issues with this. Xiaomi, Samsung, huawei, pixel, iPhones, and probably more.

I have not been able to reproduce this on a Pixel (including two or three different Pixel phones I've tried).

If this bug exists on iPhone it is definitely a different bug in different code. We'd need a reproduction for that as well.

@thomasaldershof
Copy link
Author

A lot of colleagues of mine use a Pixel and that's how know about the iPhone users as well. From what I have heard iPhone users usually get a black screen after a pop or push. I only had that a few times on Android. It's pretty random and requires the app was in the background for some time.

@dnfield
Copy link
Contributor

dnfield commented Jan 19, 2022

@vanth0me it would be helpful if you could provide a minimal reproduction that results in a black screen as you're discussing.

@thomasaldershof
Copy link
Author

@dnfield That's the hard part, it's random. It happens just the same as I have described earlier. Have an app with state (I also got it to work with the gallery example shine store app)(Having state makes it seem easier to trigger), put in in the background, wait some time and open the app. I really have not found anything else that creates it that has not been discussed here already.

@ColdPaleLight
Copy link
Member

ColdPaleLight commented Jan 21, 2022

Hi, @vanth0me
The patch has landed, you can try the latest master channel. If that still doesn't solve your problem, I suggest filing a new Issue :)

@maheshj01 maheshj01 added the r: fixed Issue is closed as already fixed in a newer version label Jan 21, 2022
@github-actions
Copy link

github-actions bot commented Feb 4, 2022

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 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. P2 Important issues not at the top of the work list platform-android Android 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.