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 sometimes crash on closing InAppWebView #1675

Open
bohowu opened this issue May 31, 2023 · 19 comments
Open

android sometimes crash on closing InAppWebView #1675

bohowu opened this issue May 31, 2023 · 19 comments
Labels
bug Something isn't working

Comments

@bohowu
Copy link

bohowu commented May 31, 2023

  • ☑ I have read the Getting Started section
  • ☑ I have already searched for the same problem

Environment

Technology Version
Flutter version 3.7.12
Plugin version 5.7.2+3
Android version OS 9 ~ 13

Device information: Xiaomi, Samsung...

Description

We got crash on Firebase crashlytics.
The last message shows on Logs is calling Navigator.pop of the InAppWebView.

Version 5.4.3+8 not occurs this issue, after I update version to 5.7.2+3, issue happens.

We can not reproduce issue on local device.

Expected behavior:

Should not crash.

Current behavior:

There are crashes on Firebase crashlytics.

Steps to reproduce

Open InAppWebView and close it.

I put the InAppWebView in WillPopScope and call Navigator.pop to close page.
截圖 2023-05-31 上午11 05 07

But the stack not readable.

Crashed: Thread: SIGABRT 0x0000000000000000
#00 pc 0x89bcc libc.so (BuildId: 4ba2121e6580a7f88bce586ed966851c)
#1 pc 0x89b9c libc.so (BuildId: 4ba2121e6580a7f88bce586ed966851c)
#2 pc 0x34bf18 libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#3 pc 0x33a134 libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#4 pc 0x33a138 libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#5 pc 0x99bffc libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#6 pc 0x8ae704 libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#7 pc 0x8cc9dc libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#8 pc 0x9a1d3c libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#9 pc 0x8ae72c libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#10 pc 0x9a1d3c libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#11 pc 0x10eef0 libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)
#12 pc 0x7b9dfc libflutter.so (BuildId: e2cee5df08eb06fb5b2583dee4f7ebc789c88cd1)

@bohowu bohowu added the bug Something isn't working label May 31, 2023
@github-actions
Copy link

👋 @bohowu

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

@bohowu bohowu changed the title android android sometimes crash on closing InAppWebView May 31, 2023
@anusreepalangadan
Copy link

I too face the same problem

@dodatw
Copy link

dodatw commented Jun 5, 2023

same here

@juriejan
Copy link

We're also experiencing the issue on a device we have on hand. Will be looking into it further and post my findings here.

@juriejan
Copy link

This seems to be the error coming from the Android device. Only getting it intermittently.

E/flutter (27572): [ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.
E/flutter (27572): 	at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:1045)
E/flutter (27572): 	at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:1115)
E/flutter (27572): 	at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:1398)
E/flutter (27572): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (27572): 	at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (27572): 	at android.os.Looper.loop(Looper.java:183)
E/flutter (27572): 	at android.app.ActivityThread.main(ActivityThread.java:7815)
E/flutter (27572): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter (27572): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:593)
E/flutter (27572): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1094)
E/flutter (27572):
F/flutter (27572): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1486)] Check failed: fml::jni::CheckException(env).
4
E/IMGSRV  (27572): :981: HWPerfSetSurfaceInfo: Cannot write HWPerf Surface Parameters. Max RTS IDs (8) reached.

@juriejan
Copy link

@bohowu can you send a full example of the screen/dialog that contains the InAppWebView?

@myoungsc
Copy link

myoungsc commented Jul 20, 2023

Same problem.. It doesn't reproduce well in debugging mode. In release mode, it reproduces intermittently.
When calling a webview and doing pop(), it comes out intermittently or differently depending on the device

When I followed this solution
https://stackoverflow.com/questions/74834201/flutter-app-is-crash-when-adding-youtubeplayer-in-some-cases

Changed useHybridComposition from true -> false in AndroidInAppWebViewOptions.

It felt like the errors in the experience were reduced.
But I don't think it's a perfect solution.

test device - galaxy a8(sm-a530n)
android version - 9

@YogeshLegendkiller
Copy link

YogeshLegendkiller commented Jul 25, 2023



[ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.

                                                                                                        at io.flutter.plugin.platform.q.Q(Unknown Source:96)

                                                                                                        at io.flutter.plugin.platform.q.Z(Unknown Source:3)

                                                                                                        at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(Unknown Source:19)

                                                                                                        at android.os.MessageQueue.nativePollOnce(Native Method)

                                                                                                        at android.os.MessageQueue.next(MessageQueue.java:335)

                                                                                                        at android.os.Looper.loop(Looper.java:193)

                                                                                                        at android.app.ActivityThread.main(ActivityThread.java:8131)

                                                                                                        at java.lang.reflect.Method.invoke(Native Method)

                                                                                                        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)

                                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)

2023-07-24 18:38:40.598  6758-6758  flutter      [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1486)] Check failed: fml::jni::CheckException(env).

Same Issue Happening getting frequent crash while exiting the application.

Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.5, on macOS 13.3.1 22E261 darwin-arm64, locale en-IN) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.2) ✗ 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. Runflutter 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 14.3.1)
! CocoaPods 1.10.2 out of date (1.11.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 2022.2)
[✓] VS Code (version 1.77.3)
[✓] Connected device (2 available)
[✓] Network resources

`

@whichname
Copy link

any update?

@song011794
Copy link

same Problem too.

@pichillilorenzo
Copy link
Owner

Are you able to share a minimal code example with steps to reproduce the issue?
Have you tried to update your Flutter and plugin version?

@whichname
Copy link

whichname commented Jan 9, 2024

After reading the flutter code, I found out that it was a problem with flutter.
After modified the following flutter code,the problem solved:

packages/flutter/lib/src/services/platform_views.dart

  @override
  Future<void> _sendDisposeMessage() {
    // return _internals.sendDisposeMessage(viewId: viewId);
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
      _internals.sendDisposeMessage(viewId: viewId);
    });
    return Future.value();
  }

@pichillilorenzo
Copy link
Owner

You shouldn’t modify flutter internal code.
Is there any issue opened on Flutter official repo about it?

@whichname
Copy link

Yes it has:

flutter/flutter#112542

@whichname
Copy link

After reading the source code, I found that it might be a concurrency problem with platformViews within flutter, so I directly modified the code of flutter, and the problem did not reoccur.

@mutant0113
Copy link

Hi,
I encountered the same problem.

Thanks to our QA team, I can finally reproduce the issue with a simple example.
I would like to provide the information, hoping it will help you identify the root cause.

Steps to reproduce

Use the sample code. The issue can be reproduced reliably with a release build (flutter run --release), while it does not occur in debug mode. (It only happened once in our app.)

Here are the steps:
When tap Show WebView in BottomSheet button
Then a bottom sheet with a WebView should pop up
When tap grey area
Then the bottom sheet should disappear
When repeat the above steps 10~30 times (it depends, sometimes it happens quickly)
Then the app crashes

Device & Information

  1. It can be easily reproduced on the Samsung M12, while it never happens on the Samsung S22 Ultra.
  2. Need to use WebView with useHybridComposition: true

Code sample

Please import plugin flutter_inappwebview: ^6.0.0.

Code sample
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';

void main() => runApp(const MaterialApp(home: HomePage()));

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) => Scaffold(
        body: Center(
          child: ElevatedButton(
            child: const Text("Show WebView in BottomSheet"),
            onPressed: () {
              showModalBottomSheet<void>(
                context: context,
                isScrollControlled: true,
                builder: (context) => const SizedBox(height: 600, child: InAppWebViewPage()),
              );
            },
          ),
        ),
      );
}

class InAppWebViewPage extends StatefulWidget {
  const InAppWebViewPage({super.key});

  @override
  State<InAppWebViewPage> createState() => _InAppWebViewPageState();
}

class _InAppWebViewPageState extends State<InAppWebViewPage> {
  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(title: const Text("InAppWebView")),
        body: InAppWebView(
          initialUrlRequest: URLRequest(url: WebUri("https://buy.line.me/")),
          initialSettings: InAppWebViewSettings(useHybridComposition: true),
        ),
      );
}

Screenshots or Video

Demo video
check_exception_crash_demo.mp4

Logs

Release build
[ERROR:flutter/fml/platform/android/jni_util.cc(206)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.
    at io.flutter.plugin.platform.y.X(Unknown Source:96)
    at io.flutter.plugin.platform.y.k0(Unknown Source:3)
    at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(Unknown Source:19)
    at android.os.MessageQueue.nativePollOnce(Native Method)
    at android.os.MessageQueue.next(MessageQueue.java:335)
    at android.os.Looper.loopOnce(Looper.java:186)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1696)] Check failed: fml::jni::CheckException(env). 
Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 32732 (ppwebview_crash), pid 32732 (ppwebview_crash)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/m12nsxx/m12:12/SP1A.210812.016/M127FXXU3BVI3:user/release-keys'
Revision: '2'
ABI: 'arm64'
Processor: '0'
Timestamp: 2024-05-09 14:53:56.842393302+0800
Process uptime: 36s
Cmdline: com.example.inappwebview_crash
pid: 32732, tid: 32732, name: ppwebview_crash  >>> com.example.inappwebview_crash <<<
uid: 10373
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1696)] Check failed: fml::jni::CheckException(env). 
    '
x0  0000000000000000  x1  0000000000007fdc  x2  0000000000000006  x3  0000007fe5383ba0
x4  0000007149114000  x5  0000007149114000  x6  0000007149114000  x7  000000000d1a00b0
x8  00000000000000f0  x9  e2cf4cd68e151c0e  x10 0000000000000000  x11 ffffff80fffffbdf
x12 0000000000000001  x13 0000000027a0d7c8  x14 0000000000000000  x15 00005acbd7129a4e
x16 00000071421b6d20  x17 0000007142190c50  x18 0000007148358000  x19 0000000000007fdc
x20 0000000000007fdc  x21 00000000ffffffff  x22 b40000709fe20900  x23 000000701e563000
x24 000000701e563000  x25 b40000700c0d2c48  x26 0000000000000024  x27 0000007147f4901d
x28 0000007147f49021  x29 0000007fe5383c20
lr  00000071421436fc  sp  0000007fe5383b80  pc  0000007142143728  pst 0000000000000000
backtrace:
#00 pc 0000000000089728  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ddfcb9d4fd7d4d5ecb9d226c1e8e24dd)
#01 pc 0000000000438784  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#02 pc 0000000000465400  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#03 pc 0000000000451ee4  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#04 pc 00000000009097dc  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#05 pc 000000000078fbe0  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#06 pc 000000000078f5e8  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#07 pc 00000000007908d0  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#08 pc 00000000007903d4  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#09 pc 0000000000465ff8  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#10 pc 0000000000469d4c  /data/app/~~ZCvYvttpLWMHE9GRnjTipg==/com.example.inappwebview_crash-uElkmaCR3O0ehHdbFMHtRA==/lib/arm64/libflutter.so (BuildId: e263a16aaa8bf3e0d2b45e1cc4e6207615829b32)
#11 pc 0000000000016918  /system/lib64/libutils.so (android::Looper::pollInner(int)+912) (BuildId: a8e5883b039c6d018dc9ced53f79b1d0)
#12 pc 0000000000016520  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: a8e5883b039c6d018dc9ced53f79b1d0)
#13 pc 000000000015249c  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: a24d70944d634a7167f6da4fcd647074)
#14 pc 000000000046b514  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (art_jni_trampoline+116)
Debug build
E/flutter (13317): [ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.
E/flutter (13317): 	at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:1062)
E/flutter (13317): 	at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:1132)
E/flutter (13317): 	at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:1414)
E/flutter (13317): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (13317): 	at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (13317): 	at android.os.Looper.loopOnce(Looper.java:186)
E/flutter (13317): 	at android.os.Looper.loop(Looper.java:313)
E/flutter (13317): 	at android.app.ActivityThread.main(ActivityThread.java:8669)
E/flutter (13317): 	at java.lang.reflect.Method.invoke(Native Method)
E/flutter (13317): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
E/flutter (13317): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
E/flutter (13317): 
F/flutter (13317): [FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1498)] Check failed: fml::jni::CheckException(env). 
D/TrackingService.EventDelivery(13317): >>>>>>>> start wait [0] <<<<<<<<
F/libc    (13317): Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 13317 (package.name), pid 13317 (package.name)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/m12nsxx/m12:12/SP1A.210812.016/M127FXXU3BVI3:user/release-keys'
Revision: '2'
ABI: 'arm64'
Processor: '1'
Timestamp: 2024-05-07 15:00:40.258647312+0800
Process uptime: 259s
Cmdline: package.name
pid: 13317, tid: 13317, name: package.name  >>> package.name <<<
uid: 10372
signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
Abort message: '[FATAL:flutter/shell/platform/android/platform_view_android_jni_impl.cc(1498)] Check failed: fml::jni::CheckException(env). 
'
    x0  0000000000000000  x1  0000000000003405  x2  0000000000000006  x3  0000007fe53826b0
    x4  0000007149114000  x5  0000007149114000  x6  0000007149114000  x7  000000000c87c7b6
    x8  00000000000000f0  x9  e2cf4cd68e151c0e  x10 0000000000000000  x11 ffffff80fffffbdf
    x12 0000000000000001  x13 000000003c2f8cc0  x14 0000000000000000  x15 0000164806c4a7dc
    x16 00000071421b6d20  x17 0000007142190c50  x18 0000007148358000  x19 0000000000003405
    x20 0000000000003405  x21 00000000ffffffff  x22 b400006fa81745c8  x23 0000000000000412
    x24 b40000709fe20900  x25 0000000000000000  x26 000000000000000f  x27 0000007147f49039
    x28 0000007fe53829b8  x29 0000007fe5382730
    lr  00000071421436fc  sp  0000007fe5382690  pc  0000007142143728  pst 0000000000000000
backtrace:
      #00 pc 0000000000089728  /apex/com.android.runtime/lib64/bionic/libc.so (abort+164) (BuildId: ddfcb9d4fd7d4d5ecb9d226c1e8e24dd)
      #01 pc 000000000167ef8c  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #02 pc 00000000016a6670  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #03 pc 000000000168ca20  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #04 pc 0000000001e05650  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #05 pc 0000000001a43b28  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #06 pc 0000000001a428a4  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #07 pc 0000000001a430bc  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #08 pc 0000000001a441c4  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #09 pc 0000000001a42c94  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #10 pc 0000000001a42a08  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #11 pc 0000000001a444c0  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #12 pc 00000000016a722c  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #13 pc 00000000016ac8d8  /data/app/~~5R2Xo6gsPmLtVTVRHF4rEA==/package.name/base.apk!libflutter.so (BuildId: 59e80130e559b84528a7f4adadcde9e10efeac15)
      #14 pc 0000000000016918  /system/lib64/libutils.so (android::Looper::pollInner(int)+912) (BuildId: a8e5883b039c6d018dc9ced53f79b1d0)
      #15 pc 0000000000016520  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: a8e5883b039c6d018dc9ced53f79b1d0)
      #16 pc 000000000015249c  /system/lib64/libandroid_runtime.so (android::android_os_MessageQueue_nativePollOnce(_JNIEnv*, _jobject*, long, int)+44) (BuildId: a24d70944d634a7167f6da4fcd647074)
      #17 pc 0000000000355830  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #18 pc 000000000033eda4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #19 pc 0000000000511050  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+1976) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #20 pc 0000000000497814  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+2040) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #21 pc 0000000000357fd8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #22 pc 00000000004cb924  /system/framework/framework.jar (android.os.MessageQueue.next+0)
      #23 pc 0000000000374120  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114)+232) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #24 pc 0000000000511d1c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #25 pc 00000000004973dc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+960) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #26 pc 0000000000357fd8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #27 pc 00000000004ca8a8  /system/framework/framework.jar (android.os.Looper.loopOnce+0)
      #28 pc 0000000000374120  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114)+232) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #29 pc 0000000000511d1c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #30 pc 000000000049774c  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1840) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #31 pc 0000000000357fd8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #32 pc 00000000004cb054  /system/framework/framework.jar (android.os.Looper.loop+0)
      #33 pc 0000000000374120  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114)+232) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #34 pc 0000000000511d1c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #35 pc 000000000049774c  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1840) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #36 pc 0000000000357fd8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #37 pc 00000000001bc4f0  /system/framework/framework.jar (android.app.ActivityThread.main+0)
      #38 pc 0000000000374120  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114)+232) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #39 pc 0000000000373a18  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+964) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #40 pc 0000000000355968  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #41 pc 000000000033f080  /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+640) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #42 pc 00000000003884dc  /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1588) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #43 pc 0000000000387e98  /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*) (.__uniq.165753521025965369065708152063621506277)+32) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #44 pc 0000000000355830  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #45 pc 000000000033eda4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #46 pc 0000000000511050  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+1976) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #47 pc 00000000004973dc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+960) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #48 pc 0000000000357fd8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #49 pc 000000000045a0f8  /system/framework/framework.jar (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+0)
      #50 pc 0000000000374120  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114)+232) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #51 pc 0000000000373a18  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+964) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #52 pc 0000000000355968  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 735f12f804f88d62a2cb437261076ff7)
      #53 pc 0000000001208ce4  /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot.oat (com.android.internal.os.ZygoteInit.main+3508)

Flutter Doctor output

Flutter Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.6, on macOS 13.4 22F66 darwin-arm64, locale zh-Hant-TW)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.6)
[✓] IntelliJ IDEA Community Edition (version 2023.3.5)
[✓] VS Code (version 1.79.2)
[✓] Connected device (3 available)
[✓] Network resources

@njuptzwt
Copy link

After reading the source code, I found that it might be a concurrency problem with platformViews within flutter, so I directly modified the code of flutter, and the problem did not reoccur.

你好,你是怎么发现是这个代码问题的?我用的百度地图的Flutter版本,应该也是PlatformView引起的在一些手机中崩溃,这样修改之后好像确实不会崩了,我看flutter官网这个issue还是开着的 ,那边作者似乎认为不是flutter的问题@whichname

@whichname
Copy link

After reading the source code, I found that it might be a concurrency problem with platformViews within flutter, so I directly modified the code of flutter, and the problem did not reoccur.

你好,你是怎么发现是这个代码问题的?我用的百度地图的Flutter版本,应该也是PlatformView引起的在一些手机中崩溃,这样修改之后好像确实不会崩了,我看flutter官网这个issue还是开着的 ,那边作者似乎认为不是flutter的问题@whichname

当时记了一下:
堆栈是

2023-08-21 17:38:09.472 21137-21137/? E/flutter: [ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.
        at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:1045)
        at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:1115)
        at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:1380)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:336)
        at android.os.Looper.loop(Looper.java:181)
        at android.app.ActivityThread.main(ActivityThread.java:7551)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)

查看 PlatformViewsController.java 源码:

final PlatformView platformView = platformViews.get(viewId);
if (platformView == null) {
  throw new IllegalStateException(
      "Platform view hasn't been initialized from the platform view channel.");
}

由于是退出时 crash,所以是由于 platformViews 已经 remove 掉了该 viewId,而 remove 操作只在 PlatformViewsController::dispose 中调用,在 dart 层就是 _internals.sendDisposeMessage(viewId: viewId),所以猜测是由于 PlatformView::dispose 和渲染帧的异步问题。

现在是否还有这个问题我也不知道了,后来没关注了

@njuptzwt
Copy link

After reading the source code, I found that it might be a concurrency problem with platformViews within flutter, so I directly modified the code of flutter, and the problem did not reoccur.

你好,你是怎么发现是这个代码问题的?我用的百度地图的Flutter版本,应该也是PlatformView引起的在一些手机中崩溃,这样修改之后好像确实不会崩了,我看flutter官网这个issue还是开着的 ,那边作者似乎认为不是flutter的问题@whichname

当时记了一下: 堆栈是

2023-08-21 17:38:09.472 21137-21137/? E/flutter: [ERROR:flutter/fml/platform/android/jni_util.cc(204)] java.lang.IllegalStateException: Platform view hasn't been initialized from the platform view channel.
        at io.flutter.plugin.platform.PlatformViewsController.initializePlatformViewIfNeeded(PlatformViewsController.java:1045)
        at io.flutter.plugin.platform.PlatformViewsController.onDisplayPlatformView(PlatformViewsController.java:1115)
        at io.flutter.embedding.engine.FlutterJNI.onDisplayPlatformView(FlutterJNI.java:1380)
        at android.os.MessageQueue.nativePollOnce(Native Method)
        at android.os.MessageQueue.next(MessageQueue.java:336)
        at android.os.Looper.loop(Looper.java:181)
        at android.app.ActivityThread.main(ActivityThread.java:7551)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:995)

查看 PlatformViewsController.java 源码:

final PlatformView platformView = platformViews.get(viewId);
if (platformView == null) {
  throw new IllegalStateException(
      "Platform view hasn't been initialized from the platform view channel.");
}

由于是退出时 crash,所以是由于 platformViews 已经 remove 掉了该 viewId,而 remove 操作只在 PlatformViewsController::dispose 中调用,在 dart 层就是 _internals.sendDisposeMessage(viewId: viewId),所以猜测是由于 PlatformView::dispose 和渲染帧的异步问题。

现在是否还有这个问题我也不知道了,后来没关注了

我的错误日志和你一样。我现在试下来不会崩溃了,我看你前面说有可能是高并发引起的,咨询一下,谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests