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

Multipleflutters Android Failed to spawn new JNI connected shell from existing shell #78389

Closed
CarGuo opened this issue Mar 17, 2021 · 7 comments · Fixed by flutter/engine#25174
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console 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

@CarGuo
Copy link

CarGuo commented Mar 17, 2021

Steps to Reproduce

Multipleflutters Crash in Special Device Mi 11 (Android 11) case by spawnedJNI.nativeShellHolderId < 0

  1. Run multiple_flutters_android in official demo.
  2. click next until show DoubleFlutterActivity .
  3. app crash with spawnedJNI.nativeShellHolderId < 0

ps: Crash Device : Mi 11 (Android 11) ,workaround with Redmi 5 Plus(Android 8.1.0)HuaWei P30pro(Android 10Virtual Device(Android 11)

Debug Image nativeShellHolderId < 0

image

image

More Info

Log

2021-03-17 11:48:37.208 7788-7788/dev.flutter.multipleflutters E/AndroidRuntime: FATAL EXCEPTION: main
    Process: dev.flutter.multipleflutters, PID: 7788
    java.lang.RuntimeException: Unable to start activity ComponentInfo{dev.flutter.multipleflutters/dev.flutter.multipleflutters.DoubleFlutterActivity}: java.lang.IllegalStateException: Failed to spawn new JNI connected shell from existing shell.
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3492)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3652)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2099)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:233)
        at android.app.ActivityThread.main(ActivityThread.java:7892)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
     Caused by: java.lang.IllegalStateException: Failed to spawn new JNI connected shell from existing shell.
        at io.flutter.util.Preconditions.checkState(Preconditions.java:52)
        at io.flutter.embedding.engine.FlutterJNI.spawn(FlutterJNI.java:342)
        at io.flutter.embedding.engine.FlutterEngine.spawn(FlutterEngine.java:383)
        at io.flutter.embedding.engine.FlutterEngineGroup.createAndRunEngine(FlutterEngineGroup.java:101)
        at dev.flutter.multipleflutters.EngineBindings.<init>(EngineBindings.kt:45)
        at dev.flutter.multipleflutters.DoubleFlutterActivity$topBindings$2.invoke(DoubleFlutterActivity.kt:17)
        at dev.flutter.multipleflutters.DoubleFlutterActivity$topBindings$2.invoke(DoubleFlutterActivity.kt:15)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at dev.flutter.multipleflutters.DoubleFlutterActivity.getTopBindings(Unknown Source:2)
        at dev.flutter.multipleflutters.DoubleFlutterActivity.onCreate(DoubleFlutterActivity.kt:58)
        at android.app.Activity.performCreate(Activity.java:8093)
        at android.app.Activity.performCreate(Activity.java:8067)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3465)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3652) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2099) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:233) 
        at android.app.ActivityThread.main(ActivityThread.java:7892) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967) 
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 2.0.2, on macOS 11.2.3 20D91 darwin-x64, locale
    zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[!] Xcode - develop for iOS and macOS
    ! CocoaPods 1.9.3 out of date (1.10.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#installation for
      instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.3.5)
[!] Proxy Configuration
    ! NO_PROXY is not set
[✓] Connected device (3 available)
@pedromassangocode pedromassangocode added the in triage Presently being triaged by the triage team label Mar 17, 2021
@pedromassangocode
Copy link

flutter/samples#761
Hi @CarGuo
According to https://github.com/flutter/samples/blob/master/CONTRIBUTING.md#file-an-issue-first the place to file issues related to Flutter examples is in its repository.

Did a quick search and found out that this may be already filled by someone else #78338.
Thank you

@CarGuo
Copy link
Author

CarGuo commented Mar 18, 2021

@pedromassangocode I thinks this issue case by flutter/engine , flutter/samples#761 (comment) mean move flutter/flutter ?

@xster xster reopened this Mar 18, 2021
@xster xster added a: existing-apps Integration with existing apps via the add-to-app flow engine flutter/engine repository. See also e: labels. platform-android Android applications specifically c: crash Stack traces logged to the console P2 Important issues not at the top of the work list and removed r: invalid Issue is closed as not valid labels Mar 18, 2021
@xster xster added this to Awaiting triage in Mobile - Add-to-app review via automation Mar 18, 2021
@xster xster moved this from Awaiting triage to Engineer reviewed in Mobile - Add-to-app review Mar 18, 2021
@branjing
Copy link

@CarGuo
Copy link
Author

CarGuo commented Mar 18, 2021

https://source.android.com/devices/tech/debug/tagged-pointers

@branjing Does it mean that this issue may be due to ARM Top-byte Ignore (TBI) with Android 11 ?

It look like this problem could't not reappear with Virtual Device(Android 11) & Samsung (Android 11)

But ··· add android:allowNativeHeapPointerTagging="false" workaround with it .

@gaaclarke
Copy link
Member

@xster It just sounds like we should switch the check from > 0 to != 0, is there a reason we need > 0?

@xster
Copy link
Member

xster commented Mar 22, 2021

@gaaclarke, ya, empirically, it seems like we can since #78389 (comment) is showing that it's been <0 for those devices this whole time with attachToNative which doesn't have this check.

I'd prefer not adding this skip in flutter/samples#778 to not gloss over the issue. If needed, applications should add the manifest tag themselves in their app as needed. I think we can change the precondition to be !=0 rather than >0.

@github-actions
Copy link

github-actions bot commented Aug 4, 2021

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 Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: existing-apps Integration with existing apps via the add-to-app flow c: crash Stack traces logged to the console 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
Mobile - Add-to-app review
  
Engineer reviewed
Development

Successfully merging a pull request may close this issue.

5 participants