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

App crashes on re-launching after some time in background in release builds, but doesnt in debug (java.lang.ClassCastException: android.view.View$BaseSavedState cannot be cast to b.a.b.a.i$d) #47635

Closed
kriticalflare opened this issue Dec 23, 2019 · 56 comments
Assignees
Labels
c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. dependency: android Android team may need to help us framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically

Comments

@kriticalflare
Copy link

kriticalflare commented Dec 23, 2019

Steps to Reproduce

  1. Create a release build of the app from https://github.com/kriticalflare/SIES-Library
  2. Launch the app
  3. Launch multiple other apps inorder to trigger OOM
  4. Make sure android has killed the app in background
  5. Try to launch the app again

Target Platform: Android
Target OS version/browser: Running on Android 10

Logs

ADB Logs

2019-12-23 06:20:43.628 18825-18825/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.kriticalflare.sies_library, PID: 18825
    java.lang.ClassCastException: android.view.View$BaseSavedState cannot be cast to b.a.b.a.i$d
        at b.a.b.a.i.onRestoreInstanceState(Unknown Source:0)
        at android.view.View.dispatchRestoreInstanceState(View.java:20369)
        at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3902)
        at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3908)
        at android.view.View.restoreHierarchyState(View.java:20347)
        at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2158)
        at android.app.Activity.onRestoreInstanceState(Activity.java:1570)
        at android.app.Activity.performRestoreInstanceState(Activity.java:1523)
        at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1353)
        at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3310)
        at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
        at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Expected result: The app to start from scratch as it was killed by the system and i am not saving native state

Actual result: The app tries to open and then crashes within a second . It works fine on subsequent launches until this issue occurs again.
This only occurs on release builds and not debug builds . Debug builds give the expected result

Attached: Link to the release apk https://github.com/kriticalflare/SIES-Library/blob/master/demo/app-release.apk

C:\Users\AM\Documents\FlutterProjects\sies_library>flutter run --verbose --release
[  +34 ms] executing: [C:\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +95 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] 27321ebbad34b0a3fafe99fac037102196d655ff
[   +1 ms] executing: [C:\flutter\] git describe --match v*.*.* --first-parent --long --tags
[  +70 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] v1.12.13+hotfix.5-0-g27321ebba
[  +15 ms] executing: [C:\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[  +65 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] origin/stable
[   +1 ms] executing: [C:\flutter\] git ls-remote --get-url origin
[  +62 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +129 ms] executing: [C:\flutter\] git rev-parse --abbrev-ref HEAD
[  +61 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[ +158 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[  +34 ms] Exit code 0 from: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe devices -l
[        ] List of devices attached
           J5AMO630K12343M        device product:WW_x01bD model:ASUS_x01bD device:ASUS_x01b_2 transport_id:2
[  +32 ms] C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell getprop
[ +216 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[  +12 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +7 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[   +1 ms] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +211 ms] Generating C:\Users\AM\Documents\FlutterProjects\sies_library\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[  +39 ms] ro.hardware = qcom
[  +73 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\build-tools\29.0.2\aapt dump xmltree C:\Users\AM\Documents\FlutterProjects\sies_library\build\app\outputs\apk\app.apk AndroidManifest.xml
[  +33 ms] Exit code 0 from: C:\Users\AM\AppData\Local\Android\sdk\build-tools\29.0.2\aapt dump xmltree C:\Users\AM\Documents\FlutterProjects\sies_library\build\app\outputs\apk\app.apk
AndroidManifest.xml
[   +5 ms] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.kriticalflare.sies_library" (Raw: "com.kriticalflare.sies_library")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=17)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=19)
                 A: android:label(0x01010001)="SIES Library Catalog" (Raw: "SIES Library Catalog")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=24)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.kriticalflare.sies_library.MainActivity" (Raw: "com.kriticalflare.sies_library.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: intent-filter (line=31)
                     E: action (line=32)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=34)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=41)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +7 ms] Launching lib\main.dart on ASUS x01bD in release mode...
[   +2 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell -x logcat -v time -s flutter
[   +8 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe version
[  +79 ms] Android Debug Bridge version 1.0.41
           Version 29.0.5-5949299
           Installed as C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe
[   +4 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[  +39 ms] Building APK
[  +22 ms] Running Gradle task 'assembleRelease'...
[   +3 ms] gradle.properties already sets `android.enableR8`
[   +5 ms] Using gradle from C:\Users\AM\Documents\FlutterProjects\sies_library\android\gradlew.bat.
[   +9 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[ +117 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java -version
[   +1 ms] openjdk version "1.8.0_202-release"
           OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
           OpenJDK 64-Bit Server VM (build 25.202-b03, mixed mode)
[   +3 ms] executing: C:\Program Files\Android\Android_Studio4.0\jre\bin\java -version
[ +111 ms] Exit code 0 from: C:\Program Files\Android\Android_Studio4.0\jre\bin\java -version
[   +1 ms] openjdk version "1.8.0_212-release"
           OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
           OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
[   +7 ms] executing: [C:\Users\AM\Documents\FlutterProjects\sies_library\android\] C:\Users\AM\Documents\FlutterProjects\sies_library\android\gradlew.bat -Pverbose=true
-Ptarget=C:\Users\AM\Documents\FlutterProjects\sies_library\lib\main.dart -Ptrack-widget-creation=true -Pfilesystem-scheme=org-dartlang-root -Ptarget-platform=android-arm64 assembleRelease
[+4099 ms] > Task :app:compileFlutterBuildRelease
[   +1 ms] [  +34 ms] executing: [C:\flutter\] git -c log.showSignature=false log -n 1 --pretty=format:%H
[   +1 ms] [  +88 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [        ] 27321ebbad34b0a3fafe99fac037102196d655ff
[   +1 ms] [        ] executing: [C:\flutter\] git describe --match v*.*.* --first-parent --long --tags
[        ] [  +63 ms] Exit code 0 from: git describe --match v*.*.* --first-parent --long --tags
[        ] [        ] v1.12.13+hotfix.5-0-g27321ebba
[   +1 ms] [  +11 ms] executing: [C:\flutter\] git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] [  +48 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[   +1 ms] [        ] origin/stable
[   +1 ms] [        ] executing: [C:\flutter\] git ls-remote --get-url origin
[        ] [  +44 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] [        ] https://github.com/flutter/flutter.git
[   +1 ms] [ +121 ms] executing: [C:\flutter\] git rev-parse --abbrev-ref HEAD
[   +1 ms] [  +63 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] [        ] stable
[   +1 ms] [  +47 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[   +1 ms] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [  +11 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[   +1 ms] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [ +205 ms] Initializing file store
[   +1 ms] [  +64 ms] kernel_snapshot: Starting due to {}
[   +1 ms] [  +25 ms] C:\flutter\bin\cache\dart-sdk\bin\dart.exe C:\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk_product/ --target=flutter -Ddart.developer.causal_async_stacks=true -Ddart.vm.profile=false -Ddart.vm.product=true
--bytecode-options=source-positions --aot --tfa --packages C:\Users\AM\Documents\FlutterProjects\sies_library\.packages --output-dill
C:\Users\AM\Documents\FlutterProjects\sies_library\.dart_tool\flutter_build\c8b68fb40e467a30469042566a0e5369\app.dill --depfile
C:\Users\AM\Documents\FlutterProjects\sies_library\.dart_tool\flutter_build\c8b68fb40e467a30469042566a0e5369\kernel_snapshot.d package:sies_library/main.dart
[+19452 ms] [+19576 ms] kernel_snapshot: Complete
[+1398 ms] [+1391 ms] invalidated build due to missing files: C:\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot
[        ] [   +2 ms] aot_android_asset_bundle: Starting due to {}
[ +299 ms] [ +235 ms] aot_android_asset_bundle: Complete
[ +300 ms] [ +366 ms] android_aot_release_android-arm64: Starting due to {InvalidatedReason.inputChanged, InvalidatedReason.inputMissing}
[   +1 ms] [  +10 ms] executing: C:\flutter\bin\cache\artifacts\engine\android-arm64-release\windows-x64\gen_snapshot --causal_async_stacks --deterministic --snapshot_kind=app-aot-elf
--elf=C:\Users\AM\Documents\FlutterProjects\sies_library\.dart_tool\flutter_build\c8b68fb40e467a30469042566a0e5369\arm64-v8a\app.so --strip
C:\Users\AM\Documents\FlutterProjects\sies_library\.dart_tool\flutter_build\c8b68fb40e467a30469042566a0e5369\app.dill
[+10799 ms] [+10731 ms] android_aot_release_android-arm64: Complete
[ +100 ms] [ +136 ms] android_aot_bundle_release_android-arm64: Starting due to {InvalidatedReason.inputChanged}
[   +1 ms] [  +11 ms] android_aot_bundle_release_android-arm64: Complete
[  +96 ms] [  +93 ms] Persisting file store
[        ] [  +34 ms] Done persisting file store
[        ] [   +8 ms] build succeeded.
[ +100 ms] [  +38 ms] "flutter assemble" took 33,048ms.
[ +101 ms] > Task :app:packLibsflutterBuildRelease UP-TO-DATE
[        ] > Task :app:preBuild UP-TO-DATE
[        ] > Task :app:preReleaseBuild UP-TO-DATE
[        ] > Task :app:compileReleaseAidl NO-SOURCE
[        ] > Task :app:checkReleaseManifest UP-TO-DATE
[        ] > Task :app:compileReleaseRenderscript NO-SOURCE
[        ] > Task :app:generateReleaseBuildConfig UP-TO-DATE
[  +94 ms] > Task :app:cleanMergeReleaseAssets
[   +1 ms] > Task :app:mergeReleaseShaders UP-TO-DATE
[   +1 ms] > Task :app:compileReleaseShaders UP-TO-DATE
[        ] > Task :app:generateReleaseAssets UP-TO-DATE
[        ] > Task :app:mergeReleaseAssets
[  +95 ms] > Task :app:copyFlutterAssetsRelease
[   +1 ms] > Task :app:mainApkListPersistenceRelease UP-TO-DATE
[        ] > Task :app:generateReleaseResValues UP-TO-DATE
[        ] > Task :app:generateReleaseResources UP-TO-DATE
[+1203 ms] > Task :app:createReleaseCompatibleScreenManifests UP-TO-DATE
[   +2 ms] > Task :app:processReleaseManifest UP-TO-DATE
[ +110 ms] > Task :app:prepareLintJar UP-TO-DATE
[ +100 ms] > Task :app:checkReleaseDuplicateClasses
[ +779 ms] > Task :app:mergeReleaseResources
[ +798 ms] > Task :app:processReleaseResources
[   +3 ms] > Task :app:compileReleaseKotlin UP-TO-DATE
[   +1 ms] > Task :app:javaPreCompileRelease UP-TO-DATE
[        ] > Task :app:compileReleaseJavaWithJavac UP-TO-DATE
[        ] > Task :app:compileReleaseSources UP-TO-DATE
[+1495 ms] > Task :app:lintVitalRelease
[+3609 ms] > Task :app:transformClassesWithDexBuilderForRelease
[   +4 ms] > Task :app:desugarReleaseFileDependencies
[   +1 ms] > Task :app:processReleaseJavaRes NO-SOURCE
[   +1 ms] > Task :app:validateSigningRelease UP-TO-DATE
[  +79 ms] > Task :app:mergeReleaseJavaResource UP-TO-DATE
[   +1 ms] > Task :app:signingConfigWriterRelease UP-TO-DATE
[        ] > Task :app:mergeReleaseJniLibFolders UP-TO-DATE
[        ] > Task :app:mergeReleaseNativeLibs UP-TO-DATE
[        ] > Task :app:stripReleaseDebugSymbols UP-TO-DATE
[        ] Compatible side by side NDK version was not found.
[+3396 ms] > Task :app:mergeExtDexRelease
[ +597 ms] > Task :app:mergeDexRelease
[+3802 ms] > Task :app:packageRelease
[   +1 ms] > Task :app:assembleRelease
[   +1 ms] Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
[   +1 ms] Use '--warning-mode all' to show the individual deprecation warnings.
[   +1 ms] See https://docs.gradle.org/5.6.2/userguide/command_line_interface.html#sec:command_line_warnings
[   +2 ms] BUILD SUCCESSFUL in 52s
[        ] 32 actionable tasks: 13 executed, 19 up-to-date
[ +478 ms] Running Gradle task 'assembleRelease'... (completed in 53.7s)
[  +24 ms] calculateSha: LocalDirectory: 'C:\Users\AM\Documents\FlutterProjects\sies_library\build\app\outputs\apk'/app.apk
[  +24 ms] calculateSha: reading file took 21us
[ +167 ms] calculateSha: computing sha took 166us
[  +26 ms] √ Built build\app\outputs\apk\release\app-release.apk (8.7MB).
[  +10 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\build-tools\29.0.2\aapt dump xmltree C:\Users\AM\Documents\FlutterProjects\sies_library\build\app\outputs\apk\app.apk AndroidManifest.xml
[  +39 ms] Exit code 0 from: C:\Users\AM\AppData\Local\Android\sdk\build-tools\29.0.2\aapt dump xmltree C:\Users\AM\Documents\FlutterProjects\sies_library\build\app\outputs\apk\app.apk
AndroidManifest.xml
[   +2 ms] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1c
               A: android:compileSdkVersionCodename(0x01010573)="9" (Raw: "9")
               A: package="com.kriticalflare.sies_library" (Raw: "com.kriticalflare.sies_library")
               A: platformBuildVersionCode=(type 0x10)0x1c
               A: platformBuildVersionName=(type 0x10)0x9
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1c
               E: uses-permission (line=17)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=19)
                 A: android:label(0x01010001)="SIES Library Catalog" (Raw: "SIES Library Catalog")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=24)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.kriticalflare.sies_library.MainActivity" (Raw: "com.kriticalflare.sies_library.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: intent-filter (line=31)
                     E: action (line=32)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=34)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=41)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +3 ms] Stopping app 'app.apk' on ASUS x01bD.
[   +4 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell am force-stop com.kriticalflare.sies_library
[ +119 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell pm list packages com.kriticalflare.sies_library
[ +134 ms] package:com.kriticalflare.sies_library
[   +5 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell cat /data/local/tmp/sky.com.kriticalflare.sies_library.sha1
[  +75 ms] 95a76f714211abfabd6f7be3eb5be61ea860f275
[   +2 ms] Installing APK.
[   +3 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe version
[  +48 ms] Android Debug Bridge version 1.0.41
           Version 29.0.5-5949299
           Installed as C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe
[   +2 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe start-server
[  +47 ms] Installing build\app\outputs\apk\app.apk...
[   +2 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M install -t -r C:\Users\AM\Documents\FlutterProjects\sies_library\build\app\outputs\apk\app.apk
[+2625 ms] Performing Streamed Install
                    Success
[   +2 ms] Installing build\app\outputs\apk\app.apk... (completed in 2.6s)
[   +4 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell echo -n 6745cc1b49be27e588ef90050662d526be055d74 >
/data/local/tmp/sky.com.kriticalflare.sies_library.sha1
[ +132 ms] ASUS x01bD startApp
[   +3 ms] executing: C:\Users\AM\AppData\Local\Android\sdk\platform-tools\adb.exe -s J5AMO630K12343M shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez
enable-dart-profiling true com.kriticalflare.sies_library/com.kriticalflare.sies_library.MainActivity
[ +243 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.kriticalflare.sies_library/.MainActivity (has extras) }
[   +4 ms] Application running.
[   +3 ms] To quit, press "q".

flutter doctor -v

[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.18362.535], locale en-IN)
    • Flutter version 1.12.13+hotfix.5 at C:\flutter
    • Framework revision 27321ebbad (12 days ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\AM\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android_Studio4.0\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[√] VS Code (version 1.41.0)
    • VS Code at C:\Users\AM\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.7.1

[√] Connected device (1 available)
    • ASUS X01BD • J5AMO630K12343M • android-arm64 • Android 10 (API 29)
@janmoppel janmoppel changed the title App crashes on re-launching after some time in background in release builds, but doesnt in debug App crashes on re-launching after some time in background in release builds, but doesnt in debug (java.lang.ClassCastException: android.view.View$BaseSavedState cannot be cast to b.a.b.a.i$d) Dec 23, 2019
@janmoppel janmoppel added c: crash Stack traces logged to the console platform-android Android applications specifically labels Dec 23, 2019
@ercadev
Copy link

ercadev commented Dec 28, 2019

I have the same issue. Are you sure it has to do with out of memory? I have not digged too deep in the problem yet and thought it had to do with my pageview where i keep the state alive on page change

@kriticalflare
Copy link
Author

@ercadev I verified that it was due to OOM by going through logcat and finding that crash occurred only when the system killed the app in background. You can also try and verify this. The system does log which app is being killed

@ercadev
Copy link

ercadev commented Dec 28, 2019

@ercadev I verified that it was due to OOM by going through logcat and finding that crash occurred only when the system killed the app in background. You can also try and verify this. The system does log which app is being killed

But is that expected? That app gets killed if for example you have to many apps open? Have you solved the provlem yet?

@kriticalflare
Copy link
Author

@ercadev I verified that it was due to OOM by going through logcat and finding that crash occurred only when the system killed the app in background. You can also try and verify this. The system does log which app is being killed

But is that expected? That app gets killed if for example you have to many apps open? Have you solved the provlem yet?

Its expected for the app to get killed in oom conditions. And since flutter doesn't provide the same native state restoration as native platforms , you expect the app to start from scratch after getting killed. But in this case its crashing.

Open App > Killed by OOM > Crashed when opening from recents/Multi tasking > Opens fine now

Have you solved the problem yet?

Nope. Maybe its some proguard/r8 like issue caused due to minification in release builds but I don't have the skill to debug this

@ercadev
Copy link

ercadev commented Dec 28, 2019

Okay I understand. I don't have the skill either. Hope someone with knowledge can answer. I'm going to try some things and will come back to you if I find something.

My Error from Crashlytics:

Fatal Exception: java.lang.ClassCastException: android.view.View$BaseSavedState cannot be cast to d.b.b.a.i$d
       at io.flutter.embedding.android.FlutterSplashView.onRestoreInstanceState(FlutterSplashView.java)
       at android.view.View.dispatchRestoreInstanceState(View.java:20254)
       at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4032)
       at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:4038)
       at android.view.View.restoreHierarchyState(View.java:20232)
       at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2184)
       at android.app.Activity.onRestoreInstanceState(Activity.java:1194)
       at android.app.Activity.performRestoreInstanceState(Activity.java:1149)
       at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1317)
       at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3132)
       at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
       at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:214)
       at android.app.ActivityThread.main(ActivityThread.java:6986)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)

@ercadev
Copy link

ercadev commented Dec 29, 2019

So my problem seems to been gone now. I don't get these crashes anymore and the only thing i did was to follow the step "Enabling Proguard" here

@kazume
Copy link

kazume commented Dec 29, 2019

I have proguard configured but am also experiencing those crashes :-/

@kriticalflare
Copy link
Author

@ercadev My suspicion about this being a proguard issue turned out to be right . I too enabled proguard and i can confirm that the crash is fixed now.

@kazume maybe you have proguard not configured properly or you dont have the correct rules for any plugin that you maybe using.

@kazume
Copy link

kazume commented Dec 29, 2019

So my problem seems to been gone now. I don't get these crashes anymore and the only thing i did was to follow the step "Enabling Proguard" here

I followed exactly these steps to enable proguard (admittedly the first time I've set it up).

@kriticalflare
Copy link
Author

@kazume can't say much without see what you did exactly. Share the repo if you can

@kazume
Copy link

kazume commented Dec 29, 2019

@kazume can't say much without see what you did exactly. Share the repo if you can

https://bitbucket.org/kazume/frosty

@kriticalflare
Copy link
Author

@kazume you seem to be missing a proguard rules file. Also you seem to be using a lot of plugins that might need extra proguard rules maybe

@kazume
Copy link

kazume commented Dec 29, 2019

puh ok, thx for the review ... I'll look into that :)

@kazume
Copy link

kazume commented Dec 31, 2019

@kazume you seem to be missing a proguard rules file. Also you seem to be using a lot of plugins that might need extra proguard rules maybe

Thx again for the hint. I created the proguard-rules file but it was at the wrong location :) now the crash is history for me as well.

@kriticalflare kriticalflare reopened this Jan 16, 2020
@kriticalflare
Copy link
Author

Flutter docs now recommend using R8 alone , and all references of proguard have been removed. But the crash still occurs in release when proguard isnt used.
https://flutter.dev/docs/deployment/android#r8

kriticalflare added a commit to kriticalflare/Spective_SIH_app that referenced this issue Jan 16, 2020
@iapicca iapicca added framework flutter/packages/flutter repository. See also f: labels. dependency: android Android team may need to help us labels Jan 17, 2020
@themisir
Copy link

Is there any solution for latest stable version of flutter? I did not enabled proguard or disabled R8.

@kriticalflare
Copy link
Author

@themisir for now you will need to enable proguard on release builds. You can see the commit i referenced this issue for reference

@Cphilo
Copy link

Cphilo commented Jan 21, 2020

This issue help me a lot.

@armadilov
Copy link

I still see this issue using Stable Channel - v1.12.13+hotfix.5.

Hint: To easily test/reproduce - allow only 1 background process on your android device (via developer options), so when you switch between apps, it needs to recreate from scratch.

Fix: Enable proguard on your release builds. I used these instructions:
https://medium.com/@swav.kulinski/flutter-and-android-obfuscation-8768ac544421

@Ajmal-Jalal
Copy link

This happens for me as well, couldn't fix it yet.

@bedryck
Copy link

bedryck commented Feb 1, 2020

I have the same issue when clearing ram and resume the app.

@pascalw
Copy link

pascalw commented Mar 3, 2020

@matthew-carroll thanks that would be great!

Easiest way to reproduce seems to be this:

  1. Generate a new empty app on Flutter stable (Flutter 1.12.13+hotfix.8) (flutter create flutter_crash_on_resume)
  2. Build a release apk (flutter build apk --release --target-platform android-arm64) and install it
  3. Open the app and put it in the background
  4. Kill the app using ADB adb shell am kill com.example.flutter_crash_on_resume
  5. Try to launch it -> crash. Launch it again and it will start properly.

If you instead build the app with flutter build apk --release --target-platform android-arm64 --no-shrink and repeat the same steps, the app will not crash after kill.

Edit: Updated with ADB command to simulate OOM kill.

@orestesgaolin
Copy link
Contributor

I can confirm that @pascalw's steps reproduce the issue on my side. I can privately share access to the project that has this exact issue @matthew-carroll.

@matthew-carroll
Copy link
Contributor

Thanks @pascalw and @orestesgaolin

With @pascalw's reproduction steps I have repro'd the crash. I'm investigating now.

--------- beginning of crash
03-03 13:33:40.152 12826 12826 E AndroidRuntime: FATAL EXCEPTION: main
03-03 13:33:40.152 12826 12826 E AndroidRuntime: Process: com.example.repro_47635_android_splash_crash, PID: 12826
03-03 13:33:40.152 12826 12826 E AndroidRuntime: java.lang.ClassCastException: android.view.View$BaseSavedState cannot be cast to b.a.b.a.i$d
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at b.a.b.a.i.onRestoreInstanceState(Unknown Source:0)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.view.View.dispatchRestoreInstanceState(View.java:20369)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3902)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3908)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.view.View.restoreHierarchyState(View.java:20347)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at com.android.internal.policy.PhoneWindow.restoreHierarchyState(PhoneWindow.java:2158)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.Activity.onRestoreInstanceState(Activity.java:1570)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.Activity.performRestoreInstanceState(Activity.java:1523)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1353)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3310)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:221)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:201)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:173)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:107)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:214)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7356)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
03-03 13:33:40.152 12826 12826 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

@matthew-carroll matthew-carroll self-assigned this Mar 3, 2020
@matthew-carroll
Copy link
Contributor

I added a @Keep annotation on the custom state object and that appears to have resolved the issue on my end. I have a PR up here:
flutter/engine#16916

It would be great if someone who is comfortable with local engine compilation could give that PR a try to verify what I found locally.

@pascalw
Copy link

pascalw commented Mar 4, 2020

@matthew-carroll thanks for the fix! I tried compiling the engine locally but my computer doesn't have enough resources 🙈

Now that your PR is merged, is there a way to verify it via the master channel?

@matthew-carroll
Copy link
Contributor

The only option to verify it is still to compile the engine locally. You'll need to wait for an engine roll into the framework to be able to verify this on the master framework branch.

@goderbauer
Copy link
Member

Closing since we believe this got fixed with flutter/engine#16916. Please re-open if this is not correct.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Mar 4, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this issue Mar 5, 2020
@huextrat
Copy link

huextrat commented Mar 5, 2020

Will the engine update be effective on Flutter Stable branch too?

@tvolkert
Copy link
Contributor

tvolkert commented Mar 5, 2020

This fix is on master and in the dev channel at versions v1.15.8 and above. It's not going to be cherrypicked onto stable, but it will be part of the next stable release.

@pascalw
Copy link

pascalw commented Mar 5, 2020

Thanks! I can confirm it's fixed if I build my APK using master 👍

@canewsin
Copy link

canewsin commented Mar 7, 2020

@tvolkert when can we expect next stable release ? Because I do face that issue on my new app, which is already has crashes on Android 9.0.
Edit : it's happening on all versions 😢

@tvolkert
Copy link
Contributor

tvolkert commented Mar 8, 2020

@canewsin we're working to push this to beta next week (in the next few days). The next stable is 4-6 weeks away.

@canewsin
Copy link

canewsin commented Mar 8, 2020

@matthew-carroll instead of switching to master or dev repo of flutter, can we put a proguard rule in our project, to keep class ?

Could you give me the proguard rule !

@canewsin
Copy link

canewsin commented Mar 8, 2020

Currently I was using --no-shrink option hope it will solve the error.

@ercadev
Copy link

ercadev commented Mar 8, 2020

@canewsin Here is the old documentation how to enable proguard. Works perfectly for me.
https://web.archive.org/web/20191016174553/https://flutter.dev/docs/deployment/android#enabling-proguard

@canewsin
Copy link

canewsin commented Mar 8, 2020

@ercadev I know how to use proguard, but my issue is, I use many libraries, so if I forgot to add any rule to it, which is required by library, then it will break another part of app. So, instead I opt for --no-shrink option.

@AmruthPillai
Copy link

I released my app today, which was built on the stable build, but few users are getting this issue. Don't know what the cause of the problem is, it's a very specific and small subset of users facing this problem, but it has caused users to rate the app with 1 star :(

What can I do to build the app without this error?

@matthew-carroll
Copy link
Contributor

@blasten we're on R8 now, right? Do you know if there is a rule that devs can add to solve this problem locally until the next stable Flutter release?

@blasten
Copy link

blasten commented Mar 9, 2020

While waiting for the next stable release, it's possible to add a proguard rule. Check this article.

In <your-app-directory>/android/app/proguard-rules.pro, add this line:

-keep public class io.flutter.embedding.android.FlutterSplashView.$SavedState { *; }

insin added a commit to insin/remote_control_for_vlc that referenced this issue Mar 23, 2020
@oom-
Copy link

oom- commented Apr 2, 2020

Any news regarding this point ? I have exactly same situation with the last verstion:

Flutter 1.12.13+hotfix.9 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f139b11009 (3 days ago) • 2020-03-30 13:57:30 -0700
Engine • revision af51afceb8
Tools • Dart 2.7.2

I will setup proguard waiting for stable.

@lock
Copy link

lock bot commented Apr 5, 2020

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.

@lock lock bot locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console customer: crowd Affects or could affect many people, though not necessarily a specific customer. dependency: android Android team may need to help us framework flutter/packages/flutter repository. See also f: labels. platform-android Android applications specifically
Projects
None yet
Development

No branches or pull requests