Repository: flutter
Issue: [Android] White screen freeze when restoring from background
Labels: e: device-specific,platform-android,c: rendering,P3,team-android,triaged-android

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. Create a new flutter application `flutter create .`
2. Run the app with Android Studio or with logcat enabled. (only needed to spot the moment the app is being killed in background)
3. Put the app in background.
4. Wait for the OS to clean memory space (open other apps to speed up the process)
In Logcat, the line '---------------------------- PROCESS ENDED (21442) for package com.example.test ----------------------------' is the signal the app is in the process of being killed.
5. Immediately after the line appears, wake the app from background.
6. The app is frozen on a white screen indefinitely.


We reproduced the issue on Oppo A72, Pixel 4A and Zebra TC51.
The issue was present on Flutter version 3.7.x and is still present on 3.10.1.

### Expected results

The app should restart normally.

### Actual results

The app is frozen on a white screen indefinitely. 

### Code sample

Issue is reproductible from the sample app.
`flutter create .`

### Screenshots or Video

<details>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

<details><summary>Logs</summary>

Those are the logs on an Oppo A72.
App goes in background on line 56 and is woken up after line 68.


```console
   2023-05-23 11:37:06.685  1778-2088  OppoThermalStats        pid-1778                             E  Error getting package info: com.example.test_freeze
    ---------------------------- PROCESS STARTED (14723) for package com.example.test_freeze ----------------------------
    2023-05-23 11:37:06.721 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:06.721 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:06.758  4858-4882  oiface                  pid-4858                             E  packageSwitch pkg com.example.test_freeze, enter
    2023-05-23 11:37:06.762  4858-4882  oiface                  pid-4858                             E  current package is com.example.test_freeze and pid is 14723
    2023-05-23 11:37:06.895 14723-14723 Perf                    com.example.test_freeze            I  Connecting to perf service.
    2023-05-23 11:37:06.899 14723-14723 Perf                    com.example.test_freeze            E   perftest packageName : com.example.test_freeze App is allowed to use Hide APIs
    2023-05-23 11:37:06.911 14723-14723 NetworkSecurityConfig   com.example.test_freeze            D  No Network Security Config specified, using platform default
    2023-05-23 11:37:06.911 14723-14723 NetworkSecurityConfig   com.example.test_freeze            D  No Network Security Config specified, using platform default
    2023-05-23 11:37:06.938 14723-14755 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:06.968 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusRedPacketManager
    2023-05-23 11:37:07.003 14723-14757 ResourceExtractor       com.example.test_freeze            I  Found extracted resources res_timestamp-1-1684830129596
    2023-05-23 11:37:07.089 14723-14723 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.089 14723-14723 AdrenoGLES-0            com.example.test_freeze            I  QUALCOMM build                   : 319c6d8, Ic907de5ed0
    Build Date                       : 09/21/20
    OpenGL ES Shader Compiler Version: EV031.32.02.01
    Local Branch                     :
    Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.9.11.R1.10.00.00.679.015
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
    2023-05-23 11:37:07.089 14723-14723 AdrenoGLES-0            com.example.test_freeze            I  Build Config                     : S P 10.0.5 AArch64
    2023-05-23 11:37:07.089 14723-14723 AdrenoGLES-0            com.example.test_freeze            I  Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
    2023-05-23 11:37:07.131 14723-14723 AdrenoGLES-0            com.example.test_freeze            I  PFP: 0x016ee190, ME: 0x00000000
    2023-05-23 11:37:07.157 14723-14761 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.161 14723-14761 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) 1.io identical 61 lines
    2023-05-23 11:37:07.162 14723-14761 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.213 14723-14723 OplusInputMethodUtil    com.example.test_freeze            D  init DEBUG to false, update DEBUG_IME to false
    2023-05-23 11:37:07.246 14723-14723 ork.test_freez          com.example.test_freeze            W  Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (greylist,test-api, reflection, allowed)
    2023-05-23 11:37:07.247 14723-14723 ork.test_freez          com.example.test_freeze            W  Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (greylist, reflection, allowed)
    2023-05-23 11:37:07.248 14723-14723 ork.test_freez          com.example.test_freeze            W  Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (greylist, reflection, allowed)
    2023-05-23 11:37:07.248 14723-14723 ork.test_freez          com.example.test_freeze            W  Accessing hidden method Landroid/util/LongArray;->get(I)J (greylist, reflection, allowed)
    2023-05-23 11:37:07.321 14723-14723 ColorViewRootUtil       com.example.test_freeze            D  initSwipState, isDisplayCompatApp false
    2023-05-23 11:37:07.321 14723-14723 ColorViewRootUtil       com.example.test_freeze            D  mScreenHeight 2400, mScreenWidth 1080
    2023-05-23 11:37:07.326 14723-14723 WindowManager           com.example.test_freeze            D  Add to mViews: DecorView@b724338[MainActivity],pkg= com.example.test_freeze
    2023-05-23 11:37:07.460 14723-14777 flutter                 com.example.test_freeze            I  The Dart VM service is listening on http://127.0.0.1:42193/LLbdSL9twxY=/
    2023-05-23 11:37:07.477 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:07.477 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:07.498 14723-14723 OplusZoomW...ViewHelper com.example.test_freeze            V  setLastReportedMergedConfiguration mZoomDisplayHeight: 2400 getDecorView.DecorView@b724338[MainActivity]
    2023-05-23 11:37:07.501 14723-14753 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.513 14723-14753 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) RenderThread identical 66 lines
    2023-05-23 11:37:07.513 14723-14753 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.516 14723-14760 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.517 14723-14760 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) 1.raster identical 4 lines
    2023-05-23 11:37:07.517 14723-14760 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.517 14723-14760 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.517 14723-14760 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.521 14723-14760 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) 1.raster identical 54 lines
    2023-05-23 11:37:07.521 14723-14760 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:07.523 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:07.523 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:07.636 14723-14723 OplusFeatureCache       com.example.test_freeze            I  Milliseconds spent on init(): 18
    2023-05-23 11:37:07.883 14723-14723 Choreographer           com.example.test_freeze            W  Frame time is 0.07417 ms in the future!  Check that graphics HAL is generating vsync timestamps using the correct timebase.
    2023-05-23 11:37:11.740 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:11.740 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:21.453  1101-1101  OppoExLayer             pid-1101                             E  using cid as pid, cid=14723, name=Background for -SurfaceView - com.example.test_freeze/com.example.test_freeze.MainActivity#0
    2023-05-23 11:37:22.342 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:22.342 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:22.343 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:22.343 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:22.349 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:22.349 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:22.357 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:22.357 14723-14723 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:51.031  1778-6165  OppoKiller...gerService pid-1778                             E  o-kill [0, 14723, com.example.test_freeze, reason: 392]
    ---------------------------- PROCESS ENDED (14723) for package com.example.test_freeze ----------------------------
    2023-05-23 11:37:59.574  1778-2088  OppoThermalStats        pid-1778                             E  Error getting package info: com.example.test_freeze
    ---------------------------- PROCESS STARTED (15803) for package com.example.test_freeze ----------------------------
    2023-05-23 11:37:59.580 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:37:59.580 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:37:59.609  4858-4882  oiface                  pid-4858                             E  packageSwitch pkg com.example.test_freeze, enter
    2023-05-23 11:37:59.610  4858-4882  oiface                  pid-4858                             E  current package is com.example.test_freeze and pid is 15803
    2023-05-23 11:37:59.747 15803-15803 Perf                    com.example.test_freeze            I  Connecting to perf service.
    2023-05-23 11:37:59.750 15803-15803 Perf                    com.example.test_freeze            E   perftest packageName : com.example.test_freeze App is allowed to use Hide APIs
    2023-05-23 11:37:59.765 15803-15803 NetworkSecurityConfig   com.example.test_freeze            D  No Network Security Config specified, using platform default
    2023-05-23 11:37:59.766 15803-15803 NetworkSecurityConfig   com.example.test_freeze            D  No Network Security Config specified, using platform default
    2023-05-23 11:37:59.786 15803-15828 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:59.818 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusRedPacketManager
    2023-05-23 11:37:59.845 15803-15830 ResourceExtractor       com.example.test_freeze            I  Found extracted resources res_timestamp-1-1684830129596
    2023-05-23 11:37:59.930 15803-15803 ork.test_freeze         com.example.test_freeze            W  type=1400 audit(0.0:20696): avc: denied { read } for name="max_map_count" dev="proc" ino=1689797 scontext=u:r:untrusted_app:s0:c95,c262,c512,c768 tcontext=u:object_r:proc_max_map_count:s0 tclass=file permissive=0 app=com.example.test_freeze
    2023-05-23 11:37:59.947 15803-15803 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:59.948 15803-15803 AdrenoGLES-0            com.example.test_freeze            I  QUALCOMM build                   : 319c6d8, Ic907de5ed0
    Build Date                       : 09/21/20
    OpenGL ES Shader Compiler Version: EV031.32.02.01
    Local Branch                     :
    Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.9.11.R1.10.00.00.679.015
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
    2023-05-23 11:37:59.948 15803-15803 AdrenoGLES-0            com.example.test_freeze            I  Build Config                     : S P 10.0.5 AArch64
    2023-05-23 11:37:59.948 15803-15803 AdrenoGLES-0            com.example.test_freeze            I  Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
    2023-05-23 11:37:59.955 15803-15803 AdrenoGLES-0            com.example.test_freeze            I  PFP: 0x016ee190, ME: 0x00000000
    2023-05-23 11:37:59.978 15803-15834 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:37:59.983 15803-15834 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) 1.io identical 61 lines
    2023-05-23 11:37:59.983 15803-15834 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:38:00.040 15803-15803 OplusInputMethodUtil    com.example.test_freeze            D  init DEBUG to false, update DEBUG_IME to false
    2023-05-23 11:38:00.076 15803-15803 ork.test_freez          com.example.test_freeze            W  Accessing hidden method Landroid/view/accessibility/AccessibilityNodeInfo;->getSourceNodeId()J (greylist,test-api, reflection, allowed)
    2023-05-23 11:38:00.084 15803-15803 ork.test_freez          com.example.test_freeze            W  Accessing hidden method Landroid/view/accessibility/AccessibilityRecord;->getSourceNodeId()J (greylist, reflection, allowed)
    2023-05-23 11:38:00.084 15803-15803 ork.test_freez          com.example.test_freeze            W  Accessing hidden field Landroid/view/accessibility/AccessibilityNodeInfo;->mChildNodeIds:Landroid/util/LongArray; (greylist, reflection, allowed)
    2023-05-23 11:38:00.084 15803-15803 ork.test_freez          com.example.test_freeze            W  Accessing hidden method Landroid/util/LongArray;->get(I)J (greylist, reflection, allowed)
    2023-05-23 11:38:00.149 15803-15803 ColorViewRootUtil       com.example.test_freeze            D  initSwipState, isDisplayCompatApp false
    2023-05-23 11:38:00.149 15803-15803 ColorViewRootUtil       com.example.test_freeze            D  mScreenHeight 2400, mScreenWidth 1080
    2023-05-23 11:38:00.153 15803-15803 WindowManager           com.example.test_freeze            D  Add to mViews: DecorView@43c80dd[MainActivity],pkg= com.example.test_freeze
    2023-05-23 11:38:00.303 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:38:00.303 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:38:00.329 15803-15803 OplusZoomW...ViewHelper com.example.test_freeze            V  setLastReportedMergedConfiguration mZoomDisplayHeight: 2400 getDecorView.DecorView@43c80dd[MainActivity]
    2023-05-23 11:38:00.332 15803-15826 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:38:00.347 15803-15826 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) RenderThread identical 66 lines
    2023-05-23 11:38:00.347 15803-15826 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:38:00.352 15803-15833 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:38:00.359 15803-15833 chatty                  com.example.test_freeze            I  uid=11631(com.example.test_freeze) 1.raster identical 61 lines
    2023-05-23 11:38:00.359 15803-15833 libEGL                  com.example.test_freeze            E  Invalid file path for libcolorx-loader.so
    2023-05-23 11:38:00.361 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  get feature:IOplusScreenModeFeature
    2023-05-23 11:38:00.361 15803-15803 oplus.andr...actoryImpl com.example.test_freeze            I  getOplusScreenModeFeature
    2023-05-23 11:38:00.364 15803-15849 flutter                 com.example.test_freeze            I  The Dart VM service is listening on http://127.0.0.1:38791/MPZxpSUXO04=/
    2023-05-23 11:38:00.468 15803-15803 OplusFeatureCache       com.example.test_freeze            I  Milliseconds spent on init(): 16
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[!] Flutter (Channel stable, 3.10.1, on macOS 13.0.1 22A400 darwin-arm64, locale en-FR)
• Flutter version 3.10.1 on channel stable at /Users/username/fvm/versions/stable
! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/2.16.2/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/username/fvm/versions/stable. Consider adding /Users/username/fvm/versions/stable/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d3d8effc68 (6 days ago), 2023-05-16 17:59:05 -0700
• Engine revision b4fb11214d
• Dart version 3.0.1
• DevTools version 2.23.1
• Pub download mirror https://adeo.jfrog.io/artifactory/api/pub/pub-adeo
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
• Android SDK at /Users/username/Library/Android/sdk
• Platform android-33, build-tools 33.0.0-rc1
• ANDROID_HOME = /Users/username/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E222b
• CocoaPods version 1.11.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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.13+0-b1751.21-8125866)

[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio 2.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] IntelliJ IDEA Community Edition (version 2022.1.2)
• 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

[✓] Connected device (5 available)
• Pixel 4a (mobile) • 09161JEC210296 • android-arm64  • Android 13 (API 33)
• TC51 (mobile)     • 18005522507113 • android-arm64  • Android 7.1.2 (API 25)
• CPH2067 (mobile)  • b02e9aaa       • android-arm64  • Android 11 (API 30)
• macOS (desktop)   • macos          • darwin-arm64   • macOS 13.0.1 22A400 darwin-arm64
• Chrome (web)      • chrome         • web-javascript • Google Chrome 113.0.5672.126

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>