Skip to content

[Android] Running an app with debug scene when the device is locked cause a black screen on Android #94921

@AlexV525

Description

@AlexV525

Flutter runs with a black screen when the device is locked and the screen is off on Android. It's reproducible almost 100% on some OnePlus devices.
Searched for relevant issues showing that some apps do have the same behavior when the app is left in the background for a while. All these might be related.

Steps to Reproduce

  1. flutter create test_example.
  2. flutter run --verbose and make sure your device is locked and the screen is off.
  3. Wait until you see the Syncing files to device... appeared, and hang it for a couple of seconds.
  4. Unlock your devices.
  5. App is a completely black screen.

To recover the normal behavior

  1. Push the app to the background.
  2. Pull it back from the background.

Verbose logs

I'll explain the behavior along with the log.

[  +10 ms] executing: /Volumes/T5/android-sdk/platform-tools/adb -s f8e67ce3 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true --ez start-paused true com.example.flutter_test_app/com.example.flutter_test_app.MainActivity
[ +128 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.flutter_test_app/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[+1160 ms] Observatory URL on device: http://127.0.0.1:38541/F76tt4cIexk=/
[   +1 ms] executing: /Volumes/T5/android-sdk/platform-tools/adb -s f8e67ce3 forward tcp:0 tcp:38541
[  +18 ms] 64028
[        ] Forwarded host port 64028 to device port 38541 for Observatory
[  +10 ms] Caching compiled dill
[ +116 ms] Connecting to service protocol: http://127.0.0.1:64028/F76tt4cIexk=/
[  +32 ms] W/FlutterActivityAndFragmentDelegate( 9430): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
[ +499 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:64028/F76tt4cIexk=/.
[ +369 ms] DDS is listening at http://127.0.0.1:64031/5vM-8dHEa5Q=/.
[  +76 ms] Successfully connected to service protocol: http://127.0.0.1:64028/F76tt4cIexk=/
[ +204 ms] DevFS: Creating new filesystem on the device (null)
[  +83 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.flutter_test_app/code_cache/flutter_test_appITIYOQ/flutter_test_app/)
[   +2 ms] Updating assets
Debug service listening on ws://127.0.0.1:64031/5vM-8dHEa5Q=/ws
[  +67 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for more information see #56466.
Syncing files to device ONEPLUS A6010...
[   +8 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[        ] Processing bundle.
[        ] <- recompile package:testapp/main.dart 6d8be2ea-8af1-4012-9eb2-0d789c346a04
[        ] <- 6d8be2ea-8af1-4012-9eb2-0d789c346a04
[   +2 ms] Bundle processing done.
[  +90 ms] Updating files.
[        ] DevFS: Sync finished
[   +1 ms] Synced 0.0MB.
[   +2 ms] <- accept
[  +13 ms] Connected to _flutterView/0x70e0a65a70.

The phone is still locked, now let's unlock it.

[+43519 ms] D/PhoneWindow( 9430): setNavigationBarColor: 0
[  +15 ms] D/DecorView( 9430): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@960c24b[MainActivity]
[   +2 ms] D/ViewRootImpl[MainActivity]( 9430): windowFocusChanged hasFocus=true inTouchMode=true

The device is now unlocked and presented with a black screen.

[+11249 ms] D/ViewRootImpl[MainActivity]( 9430): windowFocusChanged hasFocus=false inTouchMode=true
[+2006 ms] D/PhoneWindow( 9430): setNavigationBarColor: 0
[   +4 ms] D/ActivityThread( 9430): pid:9430 tid:9430 doframe Callback
[  +14 ms] E/lutter_test_ap( 9430): Invalid ID 0x00000001.
[  +17 ms] D/DecorView( 9430): onWindowFocusChangedFromViewRoot hasFocus: true, DecorView@960c24b[MainActivity]
[   +1 ms] D/ViewRootImpl[MainActivity]( 9430): windowFocusChanged hasFocus=true inTouchMode=true

After pushing it into the background and pulling it back, a doframe Callback method seems to be called, then the app displayed correctly.

Environment

Device: OnePlus A6010 (OnePlus 6T)
System version: Android 11

[✓] Flutter (Channel master, 2.6.0-12.0.pre.976, on macOS 12.0.1 21A559 darwin-x64, locale zh-Hans-CN)
    • Flutter version 2.6.0-12.0.pre.976 at /Users/alex/Documents/flutter-master
    • Upstream repository https://github.com/AlexV525/flutter
    • Framework revision ca7b823d93 (66 minutes ago), 2021-12-09 02:54:08 -0500
    • Engine revision 716d1b0998
    • Dart version 2.16.0 (build 2.16.0-85.0.dev)
    • DevTools version 2.9.1
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Volumes/T5/android-sdk
    • Platform android-31, build-tools 31.0.0
    • ANDROID_HOME = /Volumes/T5/android-sdk
    • ANDROID_SDK_ROOT = /Volumes/T5/android-sdk
    • Java binary at: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
    • All Android licenses accepted.

[✓] Connected device (1 available)
    • ONEPLUS A6010 (mobile) • f8e67ce3                  • android-arm64  • Android 11 (API 30)

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: renderingUI glitches reported at the engine/skia or impeller rendering levelengineflutter/engine related. See also e: labels.perf: startupPerformance issues related to app startup timeplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions