cph-cachet / flutter-plugins

A collection of Flutter plugins developed by CACHET
550 stars 678 forks source link

[health 11.1.0] Totally crashing production app on Android #1059

Open rafaellop opened 1 month ago

rafaellop commented 1 month ago

Device / Emulator and OS

Android 13 (SDK 33)

Describe the bug

Users suffer of crashing my production app. Google Play reports crash as java.lang.RuntimeException. Callstack below. The health plugin is about to blame. This started when I upgrade from 10.x to 11.x. No changes in the app except the health plugin update and fixing breaking changes introduced in 11.x.

Flutter doctor

[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.22000.2538], locale pl-PL)

Additional information

Exception java.lang.RuntimeException:
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5994)
  at android.app.ActivityThread.handleSendResult (ActivityThread.java:6033)
  at android.app.servertransaction.ActivityResultItem.execute (ActivityResultItem.java:67)
  at android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
  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:2574)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8762)
  at java.lang.reflect.Method.invoke
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
**Caused by java.lang.IllegalStateException: Reply already submitted
  at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply (DartMessenger.java)
  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success (MethodChannel.java)
  at cachet.plugins.health.HealthPlugin.onHealthConnectPermissionCallback (HealthPlugin.java)
  at cachet.plugins.health.HealthPlugin.onAttachedToActivity$lambda$33 (HealthPlugin.java)**
  at androidx.activity.result.ActivityResultRegistry.doDispatch (ActivityResultRegistry.java)
  at androidx.activity.result.ActivityResultRegistry.dispatchResult (ActivityResultRegistry.java)
  at androidx.activity.ComponentActivity.onActivityResult (ComponentActivity.java)
  at androidx.fragment.app.FragmentActivity.onActivityResult (FragmentActivity.java)
  at io.flutter.embedding.android.FlutterFragmentActivity.onActivityResult (FlutterFragmentActivity.java)
  at android.app.Activity.dispatchActivityResult (Activity.java:8951)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5987)
anasboyka commented 1 month ago

i also facing the same problem with certain devices using android 13 and below

image
iarata commented 3 weeks ago

@anasboyka @rafaellop Do you perhaps have more information? I wasn't able to reproduce the crash.

Based on the logs from @rafaellop the crash happens when multiple permission requests are sent before the initial one is denied or accepted.

rafaellop commented 3 weeks ago

No more information except that it happens mostly on Samsung devices and Android 13 or higher. I can provide full log/information from Google Play Console.

rafaellop commented 3 days ago

The #1069 PR fixes the issue. Please pull to the main repo.