You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is an ANR problem that is raised from broadcast receiver implemented to interact push notifications in order to communicate to Dart side. This issue is happening when our library is used with Firebase messaging library. However the issue might be there already and Firebase messaging library might just be aggravating it.
Investigate following
Understand the impact of using multiple broadcast receivers that are accepting that has same intent filters. Will they both receive the intent? Will there be a priority? Is there a scheduling, priority etc that is designed for this case? Official documentation may not be enough to understand these, so might be a good idea to delve into Android source code.
Compare implementation of broadcast receiver with the official one.
Try to identify execution block that causes ANR. This issue might be hard to replicate but hopefully adding the firebase library will make it easier. Then try to move this block to a background thread with minimal impact (without losing or changing any functionality) and see if that could quickly solve the issue (As recommended by @QuintinWillison thanks!)
If above solutions do not work, try to adopt approach from [Firebase's official package |https://github.com/FirebaseExtended/flutterfire/tree/master/packages/firebase_messaging/firebase_messaging]
The text was updated successfully, but these errors were encountered:
Some initial thoughts after comparing Firebase's official plugin with our Plugin.
Our plugin tries to do something quite similar to what Firebase's official plugin does. Also architecturally looks like Ben B. tried to create something similar to Firebase team did.
Firebase's implementation has a store to store / read /write messages, a job service for proper enqueue and dequeue and a background executor. We try to immediately execute incoming messages by trying to manually starting the app. I think we should follow the Firebase plugin implementation path.
We may not be able to directly use Firebase's Flutter library for now however I think our eventual aim to be using their library directly and customising the behaviour in Flutter side. That's a more pragmatic approach as we do not want to reinvent the wheel.
We can temporarily use Firebase library's Android plugin code, customising some behaviour on our side and making sure the dart-native channels are set up properly so that we don't have to change code in the dart side. I will also create the same package as what official plugin does in order to avoiding any clash for users who additionaly installs Firebase's official library.
I tried to use components from Firebase messaging library and it ended up being very convoluted. It wasn't easy to migrate background channels used in the library to ours so I gave up.
However. I confirmed that broadcast receivers with same intent filters will indeed block each other and they run in turn. So moving long running bit in our broadcast receiver should solve the ANR problem.
QuintinWillison
changed the title
Investigate and possibly fix broadcast receiver issue that causes ANR
Our PN broadcast receiver issue causes ANR on Android
Jan 14, 2022
Issue spotted at #226 (comment)
There is an ANR problem that is raised from broadcast receiver implemented to interact push notifications in order to communicate to Dart side. This issue is happening when our library is used with Firebase messaging library. However the issue might be there already and Firebase messaging library might just be aggravating it.
Investigate following
The text was updated successfully, but these errors were encountered: