-
Notifications
You must be signed in to change notification settings - Fork 4k
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
🐛 Messaging - dev.14 build - Data message delayed when in Android doze #4718
Comments
I have also now also tested this with Dart SDK 2.10.4 and with the same outcome |
Reproducible on the latest master flutter doctor -v[√] Flutter (Channel master, 1.26.0-2.0.pre.402, on Microsoft Windows [Version 10.0.19041.746], locale et-EE)
• Flutter version 1.26.0-2.0.pre.402 at C:\Development\flutter_master
• Framework revision 2a188eeca3 (34 hours ago), 2021-01-17 19:27:00 -0800
• Engine revision 609036f2bf
• Dart version 2.12.0 (build 2.12.0-236.0.dev)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\marku\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.7.30621.155
• Windows 10 SDK version 10.0.18362.0
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.6953283
• 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 1.8.0_242-release-1644-b01)
[√] Connected device (4 available)
• SM G950F (mobile) • ce12171c51cc001c03 • android-arm64 • Android 9 (API 28)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19041.746]
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141
• Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.75
• No issues found! |
Hey @pete-cth, we're now on |
Hello, |
Hey @pete-cth. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically. If you have more information that will help us get to the bottom of this, just add a comment! |
I haven't had a chance to retest this yet as I have been on another project just recently. I will retry as soon as I can. However I see that @cturn-dev has just noted that it is still reproducible against v10. I suggest it is kept open for now. |
Same problem with flutter 2.2.1 and firebase messaging 10.0.1 |
In the file firebase/messaging/FlutterFirebaseMessagingBackgroundService.java, the class FlutterFirebaseMessagingBackgroundService extends JobIntentService. The JobIntentService documentation says: Could this be the problem? |
Any News on this? Same problem with flutter 1.22.6 and firebase messaging 8.0.0-dev.14 |
Issue still persists. Flutter SDK I can see that message is received by firebase_messaging via this log: But We are building a calling app and this issue is actually blocking us from release - our app won't wake on incoming call when phone is in doze mode :( |
@russellwheatley @markusaksli-nc |
got the same problem
|
Hey @pete-cth, I did quite a bit of digging on this. I was able to confirm the behaviour you & others outlined. The solution for me was to change the battery optimisation settings for my app. My Samsung device was stopping the background task from executing. Only when I updated the "App power management" settings to ensure the app wasn't put to sleep was I able to receive the background message. I highly recommend using don't kill my app to help remove any battery saving blockers your device might be using, and test if your device is able to receive the message. This is a problem with allowing vendors to implement their own battery saving optimisations on top of the android battery saving optimisations which makes it a big problem for us developers. |
@russellwheatley You are right about battery optimization. However I've checked previous version of our app that was native and it awakes from doze mode when we receive a high priority push. And this same push doesn't awake flutter app. This is not a problem with the device, this is a bug inside of this implementation of firebase_messaging. I think message handling should not be passed to JobIntentService cause in it's description it clearly says that JobIntentService will not handle messages while device is in Doze mode (except for the maintenance window) |
@russellwheatley I've tested your solution and it works indeed - all pushes are shown immediately if I turn off battery saving optimizations. However there is no way we can force all our users to do that and without push handling in Doze mode our calling app is useless. It also contradicts the information here, which states that only high priority data push messages will be handled right away in Doze. With your suggestion all messages are now handled right away and I think it might affect battery drain. I think we should look more into this issue and try to make high priority data messages work in Doze mode by default. I'm trying to fix it myself but unfortunately I have very limited knowledge of Java and Android cause I used to be a web dev and have only recently switched to Flutter. We really need help from maintainers to fix this 🙏 |
I solved the problem by using a modified version of JobIntentService, as telegram and onesignal do. |
@cturn-dev Thank you so much! 🤗 It is actually working now. The only changes I had to make are:
@russellwheatley may be we could use similar JobIntentService inside this package? There is even an explanation of why it is working in Doze mode. |
It's being looked into at the moment |
@makstheimba You're welcome! |
Bug report
I'm using the latest dev build 8.0.0-dev.14. Almost everything is working perfectly!
When I send a high priority FCM data message to the device, my background message handler is not given the message while the device is in doze (idle) state. As soon as the device comes out of doze the background handler is called.
The following log message is observed in LogCat at the correct time the message should be handled (during doze): D/FLTFireMsgReceiver: broadcast received for message
The message I send is set as high priority. I have tried sending from both the legacy HTTP api, and from the Node firebase-admin client
There is no notification section in the message being sent, just a data section.
I have tried setting a ttl of 0 for the message. The message is still delivered, but again only after the device comes out of doze.
I am testing on a Pixel Xl Android 10
I have primarily been testing the doze (idle) state by forcing it using adb (see below) however I have also tested by leaving the device to naturally go into a doze state, with the same effect.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
I expect that the high priority message should still be passed to the background message handler in a timely manner even if the device is in doze
It looks like this almost works as the FLTFireMsgReceiver log message is produced at the correct time, and there is also evidence that the Flutter app's UI does wake up a bit and is given network access for a brief period, but the background message handler is not called until later
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: