[GH-ISSUE #687] android: excessive battery drain on 4g network #506

Closed
opened 2026-05-07 00:24:53 +02:00 by BreizhHardware · 6 comments

Originally created by @danielleontiev on GitHub (Mar 27, 2023).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/687

Android application drains 5%/hour of battery for my device when using Websocket/Json stream notification method on 4g network. It's not the case for wifi connection

Device: Xiaomi Mi9 SE, lineageOS 20

Screenshot after 5 hours of testing

Here is bugreport.zip that can be used in battery historian.

Not 100% sure but the suspected cause is the permanent waking up of mobile radio:

Some insights

I've seen the discussions on it here github.com/binwiederhier/ntfy@23c5d4e345 here https://github.com/binwiederhier/ntfy/issues/76 and here https://github.com/binwiederhier/ntfy/issues/190 but it seems that the rate of battery drain also depends on the device hardware.

I see the same behavior for Signal messenger (it also uses permanent Websocket connection in the foreground service) and it drains my battery even 3-5 times more than ntfy - there are opened issues in their repository on the topic but the investigation is ongoing as far as I can see.

For me I can see such behavior in ntfy for both Websocket and Json stream mode (the report above is for Websocket mode).

I've tried to compare that to other open source applications and for my device I can see the following:

The reports above is from the clean phone without other apps installed, I've also have not touched it for 5 hours in the row while recording the behavior.

Originally created by @danielleontiev on GitHub (Mar 27, 2023). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/687 Android application drains 5%/hour of battery for my device when using Websocket/Json stream notification method on 4g network. It's not the case for wifi connection Device: Xiaomi Mi9 SE, lineageOS 20 <details> <summary>Screenshot after 5 hours of testing</summary> <img src="https://user-images.githubusercontent.com/24596613/228017558-6c71efd4-19cf-4533-9348-3876889be739.png"> </details> Here is [bugreport.zip](https://github.com/binwiederhier/ntfy/files/11081475/bugreport.zip) that can be used in battery historian. Not 100% sure but the suspected cause is the permanent waking up of mobile radio: <details> <summary>Some insights</summary> <img src="https://user-images.githubusercontent.com/24596613/228020257-e4fb82e7-44b3-4a3f-ae09-1f3a3a1d91dd.png"> </details> I've seen the discussions on it here https://github.com/binwiederhier/ntfy/commit/23c5d4e34554e69cd457080fa0a385625401d77f here https://github.com/binwiederhier/ntfy/issues/76 and here https://github.com/binwiederhier/ntfy/issues/190 but it seems that the rate of battery drain also depends on the device hardware. I see the same behavior for Signal messenger (it also uses permanent Websocket connection in the foreground service) and it drains my battery even 3-5 times more than ntfy - there are opened issues in their repository on the topic but the investigation is ongoing as far as I can see. For me I can see such behavior in ntfy for both Websocket and Json stream mode (the report above is for Websocket mode). I've tried to compare that to other open source applications and for my device I can see the following: - Signal has the similar implementation and the issue is the same - Element does not drain the battery but it seems that application does not try to maintain the permanent connection with the server and checks notifications periodically (https://github.com/vector-im/element-android/blob/716bd9a2e6781cea48b8f87cc492e15f375e9455/vector-app/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt#L47-L52) - Telegram https://github.com/DrKLO/Telegram also does not drain the battery but I've not found how it works with notifications when Firebase is not available - it even does not start foreground sync service which I though is necessary The reports above is from the clean phone without other apps installed, I've also have not touched it for 5 hours in the row while recording the behavior.
BreizhHardware 2026-05-07 00:24:53 +02:00
  • closed this issue
  • added the
    🪲 bug
    label
Author
Owner

@binwiederhier commented on GitHub (Mar 31, 2023):

Thank you for your bug report. Unfortunately, as you have already identified, this seems to be an issue with your phone hardware and/or your Android flavor. ntfy uses websocket or json stream for instant delivery. If you do not need instant delivery, you can use ntfy.sh with Firebase (default), or sign-up for Firebase yourself and build your own Android app. Beyond that, there is not much I can do for you sadly.

You can join the ntfy Discord/Matrix and see if others have similar experiences with the same phone. But this is certainly not a ntfy bug, because if the battery drain was like this for others, I would have heard about it already.

Good luck.

<!-- gh-comment-id:1491129772 --> @binwiederhier commented on GitHub (Mar 31, 2023): Thank you for your bug report. Unfortunately, as you have already identified, this seems to be an issue with your phone hardware and/or your Android flavor. ntfy uses websocket or json stream for instant delivery. If you do not need instant delivery, you can use ntfy.sh with Firebase (default), or sign-up for Firebase yourself and build your own Android app. Beyond that, there is not much I can do for you sadly. You can join the ntfy Discord/Matrix and see if others have similar experiences with the same phone. But this is certainly not a ntfy bug, because if the battery drain was like this for others, I would have heard about it already. Good luck.
Author
Owner

@danielleontiev commented on GitHub (Mar 31, 2023):

Is it possible to know (maybe from some API) wether LTE module of the phone is not battery friendly and maybe it's possible to disable instant delivery for such devices or at least print some sort of warning?

<!-- gh-comment-id:1491938473 --> @danielleontiev commented on GitHub (Mar 31, 2023): Is it possible to know (maybe from some API) wether LTE module of the phone is not battery friendly and maybe it's possible to disable instant delivery for such devices or at least print some sort of warning?
Author
Owner

@Finn10111 commented on GitHub (Jul 5, 2024):

Is it possible to know (maybe from some API) wether LTE module of the phone is not battery friendly and maybe it's possible to disable instant delivery for such devices or at least print some sort of warning?

I know this "issue" is old and closed, I understand it's not a bug in ntfy. @danielleontiev do you have any new findings?

<!-- gh-comment-id:2210342469 --> @Finn10111 commented on GitHub (Jul 5, 2024): > Is it possible to know (maybe from some API) wether LTE module of the phone is not battery friendly and maybe it's possible to disable instant delivery for such devices or at least print some sort of warning? I know this "issue" is old and closed, I understand it's not a bug in ntfy. @danielleontiev do you have any new findings?
Author
Owner

@jayb-g commented on GitHub (Oct 23, 2024):

@danielleontiev I feel like there's definitely something to it as I'm experiencing same issue with same set of apps. Maybe its related to specific OS/hw(not using same hw/OS as OP)

<!-- gh-comment-id:2430803215 --> @jayb-g commented on GitHub (Oct 23, 2024): @danielleontiev I feel like there's definitely something to it as I'm experiencing same issue with same set of apps. Maybe its related to specific OS/hw(not using same hw/OS as OP)
Author
Owner

@jayb-g commented on GitHub (Oct 25, 2024):

Is it possible to know (maybe from some API) wether LTE module of the phone is not battery friendly

It would definitely help to pinpoint the issue

<!-- gh-comment-id:2436903692 --> @jayb-g commented on GitHub (Oct 25, 2024): > Is it possible to know (maybe from some API) wether LTE module of the phone is not battery friendly It would definitely help to pinpoint the issue
Author
Owner

@jayb-g commented on GitHub (Feb 19, 2025):

If you do not need instant delivery, you can use ntfy.sh with Firebase (default)...

Isn't firebase too, made for instant delivery ?

But this is certainly not a ntfy bug, because if the battery drain was like this for others, I would have heard about it already

Is it known/tested to use (almost) same amount of battery in GMS vs non-GMS Androids?

<!-- gh-comment-id:2667897587 --> @jayb-g commented on GitHub (Feb 19, 2025): > If you do not need instant delivery, you can use ntfy.sh with Firebase (default)... Isn't firebase too, made for instant delivery ? > But this is certainly not a ntfy bug, because if the battery drain was like this for others, I would have heard about it already Is it known/tested to use (almost) same amount of battery in GMS vs non-GMS Androids?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#506
No description provided.