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 application got crash on notification receive in killed state using Ably notifications #437

Open
Asharulislam opened this issue Jul 20, 2022 · 9 comments
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@Asharulislam
Copy link

Asharulislam commented Jul 20, 2022

Now I am using latest package of Ably 1.2.15.
Flutter version 2.5.3

Reference to ISSUE : #429

QuintinWillison ikbalkaya

If I send notifications then in Android (in terminated state) Application got crash.

Steps to reproduce:

  1. Fire 6 to 8 notifications when the app is killed.
  2. Received 2 or 4 notifications and some are still pending.
  3. Just open the App (not from tapping the notification) from apps menu.
  4. App just got crashed.

Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: io.ably.flutter.plugin. Response ID: 0
W/FlutterJNI(13840): Tried to send a platform message to Flutter, but FlutterJNI was detached from native C++. Could not send. Channel: io.ably.flutter.plugin. Response ID: 0
E/AndroidRuntime(13840): FATAL EXCEPTION: main
E/AndroidRuntime(13840): Process: com.appiskey.dang.dev, PID: 13840
E/AndroidRuntime(13840): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(13840): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:164)
E/AndroidRuntime(13840): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238)
E/AndroidRuntime(13840): at io.ably.flutter.plugin.AblyMethodCallHandler$MethodResultWrapper.lambda$success$0$AblyMethodCallHandler$MethodResultWrapper(AblyMethodCallHandler.java:133)
E/AndroidRuntime(13840): at io.ably.flutter.plugin.-$$Lambda$AblyMethodCallHandler$MethodResultWrapper$mM2gyGmNB_FxOxEa-tdyQn04YRo.run(Unknown Source:4)
E/AndroidRuntime(13840): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(13840): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(13840): at android.os.Looper.loop(Looper.java:246)
E/AndroidRuntime(13840): at android.app.ActivityThread.main(ActivityThread.java:8506)
E/AndroidRuntime(13840): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(13840): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/AndroidRuntime(13840): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

h3. Some Time this error occured:
FATAL EXCEPTION: main
E/AndroidRuntime(18800): Process: com.appiskey.dang.dev, PID: 18800
E/AndroidRuntime(18800): java.lang.IllegalStateException: Reply already submitted
E/AndroidRuntime(18800): at io.flutter.embedding.engine.o.e.a(Unknown Source:35)
E/AndroidRuntime(18800): at g.b.d.a.v.b(Unknown Source:14)
E/AndroidRuntime(18800): at g.a.a.a.k1.e(:1)
E/AndroidRuntime(18800): at g.a.a.a.p0.run(Unknown Source:4)
E/AndroidRuntime(18800): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(18800): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(18800): at android.os.Looper.loop(Looper.java:246)
E/AndroidRuntime(18800): at android.app.ActivityThread.main(ActivityThread.java:8506)
E/AndroidRuntime(18800): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18800): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
E/AndroidRuntime(18800): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

┆Issue is synchronized with this Jira Bug by Unito

@ikbalkaya
Copy link
Contributor

Thanks for reporting this @Asharulislam. Can you please confirm that you had this issue since v1.2.15?

@Asharulislam
Copy link
Author

@ikbalkaya Yes the above issue is occurred when I am using v1.2.15.

@ikbalkaya
Copy link
Contributor

Thank you. I will investigate

@ikbalkaya ikbalkaya self-assigned this Jul 20, 2022
@ikbalkaya ikbalkaya added the bug Something isn't working. It's clear that this does need to be fixed. label Jul 20, 2022
@JakubJankowski
Copy link
Contributor

A small update from me - I've looked into it today for a bit, but couldn't find a way to reproduce this crash (tried using the example app with various emulators and a physical device, hasn't crashed once).

I'm leaving Ably, so for whomever looks at it in the future - since it seems like this started happening since v. 1.2.15, it might be connected to the ably-java version bump (unlikely): #435
Or more likely - to using the main thread to send messages to Flutter plugin, which might cause ANRs again: https://github.com/ably/ably-flutter/pull/431/files

Please keep in mind that all those issues might become irrelevant once we switch to the federated plugin approach, but that will probably take a while.

@deanna-lad
Copy link

The corresponding Jira issue is https://ably.atlassian.net/browse/SDK-2480

@ikbalkaya
Copy link
Contributor

ikbalkaya commented Apr 4, 2023

@Asharulislam Could you provide Android version that causes this issue please? For the note I tested this on Android 11 and 13. It turns out that

  • Android 11 does not receive notification after termination, but no crash happens on app start (or re-start)
  • Android 13 does receive notification and there is also no issue with push messages

@Asharulislam
Copy link
Author

@ikbalkaya My android version was 12.

Ably version 1.2.15.
Flutter version 2.5.3

@ikbalkaya
Copy link
Contributor

ikbalkaya commented Apr 5, 2023

Thanks @Asharulislam. I just did another test with

  • ably-flutter 1.2.15
  • Flutter 2.5.3 and
  • Android 12

The behaviour was similar to the one as Android 11. Notifications aren't received but I did not experience a crash on app startup. When I was doing initial testing I realized the Flutter version was 2.8.0 - Would it be possible for you to increase your Flutter version and give it another go and see whether you are having a similar issue. In the meantime I realize that not receiving push messages when the app is terminated is another issue and I'm going to look into addressing it.

Also please could you try using a release build of your app when testing push notifications on terminated state?

@ikbalkaya ikbalkaya removed their assignment Apr 6, 2023
@YumengNevix
Copy link

if you open "Auto start" setting, you will receive message even if app is closed. Howerer, ably will start a new flutter engine to transport message to flutter. I think it's useless.
To fix this problem , you can remove default FIrebaseMessageReceiver and remove ManuFlutterXXXX invoke.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

5 participants