FlutterToast icon indicating copy to clipboard operation
FlutterToast copied to clipboard

io.github.ponnamkarthik.toast.fluttertoast.MethodCallHandlerImpl.onMethodCall

Open BunnyBuddy opened this issue 10 months ago • 1 comments

We sometimes see this ANR popup in Google Play Console only on Android 12 devices,

#00  pc 0x00000000000dc058  /apex/com.android.runtime/lib64/bionic/libc.so (__ioctl+8)
  #01  pc 0x0000000000095cc8  /apex/com.android.runtime/lib64/bionic/libc.so (ioctl+156)
  #02  pc 0x00000000000530b4  /system/lib64/libbinder.so (android::IPCThreadState::talkWithDriver+292)
  #03  pc 0x00000000000542f0  /system/lib64/libbinder.so (android::IPCThreadState::waitForResponse+64)
  #04  pc 0x0000000000054034  /system/lib64/libbinder.so (android::IPCThreadState::transact+224)
  #05  pc 0x000000000004bb28  /system/lib64/libbinder.so (android::BpBinder::transact+240)
  #06  pc 0x000000000016aa94  /system/lib64/libandroid_runtime.so (android_os_BinderProxy_transact+156)
  at android.os.BinderProxy.transactNative (Native method)
This binder call may be taking too long, causing the main thread to wait and triggering the ANR. [Learn more](https://developer.android.com/topic/performance/anrs/find-unresponsive-thread#slow-binder)

  at android.os.BinderProxy.transact (BinderProxy.java:629)
  at android.app.INotificationManager$Stub$Proxy.enqueueToast (INotificationManager.java:3390)
  at android.widget.Toast.show (Toast.java:215)
  at io.github.ponnamkarthik.toast.fluttertoast.MethodCallHandlerImpl.onMethodCall (MethodCallHandlerImpl.kt:114)
  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage (MethodChannel.java:267)
  at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler (DartMessenger.java:292)
  at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0 (DartMessenger.java:319)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:210)
  at android.os.Looper.loop (Looper.java:299)
  at android.app.ActivityThread.main (ActivityThread.java:8319)
  at java.lang.reflect.Method.invoke (Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:556)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1038)

I am using it under popscope to show the user a toast before exiting the app.

 if (isFirstRouteInCurrentTab) {
          if (navController.currentPage.value != "DashboardKey") {
            navController.selectTab(tabItem: "DashboardKey", index: 0);
          } else {
            debugPrint('Exit');
            DateTime now = DateTime.now();
            if (currentBackPressTime == null || now.difference(currentBackPressTime!) > const Duration(seconds: 2)) {
              currentBackPressTime = now;
              Fluttertoast.showToast(
                msg: 'Click again to exit',
                toastLength: Toast.LENGTH_SHORT,
                gravity: ToastGravity.CENTER,
                timeInSecForIosWeb: 1,
                backgroundColor: Colors.black54,
                textColor: Colors.white,
                fontSize: 16.sp,
              );
            } else {
              SystemNavigator.pop();
              exit(0);
            }
          }
        }

Flutter Doctor:

[✓] Flutter (Channel stable, 3.27.4, on macOS 15.2 24C101 darwin-arm64, locale en-PK)
    • Flutter version 3.27.4 on channel stable at /Users/X/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision d8a9f9a52e (2 weeks ago), 2025-01-31 16:07:18 -0500
    • Engine revision 82bd5b7209
    • Dart version 3.6.2
    • DevTools version 2.40.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/X/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java
    • Java version Java(TM) SE Runtime Environment (build 17.0.12+8-LTS-286)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • 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 21.0.5+-12932927-b750.29)

[✓] Connected device (5 available)
    • Android SDK built for arm64 (mobile) • emulator-5554             • android-arm64  • Android 10 (API 29) (emulator)
    • X iPhone (mobile)      • 00008020-001D0D0 • ios            • iOS 18.2.1 22C161
    • macOS (desktop)                      • macos                     • darwin-arm64   • macOS 15.2 24C101 darwin-arm64
    • Mac Designed for iPad (desktop)      • mac-designed-for-ipad     • darwin         • macOS 15.2 24C101 darwin-arm64
    • Chrome (web)                         • chrome                    • web-javascript • Google Chrome 133.0.6943.55

[✓] Network resources
    • All expected network resources are available.

• No issues found!

BunnyBuddy avatar Feb 17 '25 07:02 BunnyBuddy

Hi @BunnyBuddy, did you find a solution?

waqadArshad avatar Oct 28 '25 17:10 waqadArshad