TelegramMessenger / Telegram-iOS

Telegram-iOS
5.51k stars 1.49k forks source link

Background activity drains battery very fast #81

Open atapin opened 5 years ago

atapin commented 5 years ago

Telegram always keeps 1st place among all my apps as a power consumer. During the night it consumes energy exclusively (95-100%).

AndreyAkifev commented 4 years ago

Same issue. Telegram 5.9.1

hyposlasher commented 4 years ago

Same issue. Turning off background app refresh doesn’t help. Telegram drains battery in the background like nothing else.

ttyusupov commented 4 years ago

Still happening with version 5.10. Also noticed that even with background app refresh disabled, telegram background activity for the last 24 hours is almost the same as foreground: fg/bg - 47/50 minutes.

mijndert commented 4 years ago

Also still happening on 5.11.1.

This has been a bug for ages now, and we really really need a fix. It's kind of 'amazing' that one app can eat up about 50% of my battery at the end of the day.

VadimGaltsev commented 4 years ago

Same issue Any solutions? Telegram 5.11

mijndert commented 4 years ago

I tweeted at Telegram but they won't respond. This issue has been going for a very long time now - but Telegram doesn't seem to care at all.

Maybe we should just open more issues - flood their GitHub project with reports of this.

Battery stats for today:

Ambros94 commented 4 years ago

Same here on IPhone X and iOS 12. Have someone gathered data regarding the number of public groups / channels and this battery drain? Meaning, would quit some channels help?

mijndert commented 4 years ago

In my tests, the amount of channels doesn't make a difference.

cringeops commented 4 years ago

I’m really speculating over here, but try to disable background download (it’s in Data and Storage).

ttyusupov commented 4 years ago

I’m really speculating over here, but try to disable background download (it’s in Data and Storage).

Already did that week or two ago, but the issue is still there. For example for the last 24 hours - foreground activity 1h54m, background activity 2h37m. Also turned off gif and video auto play.

cringeops commented 4 years ago

Too many factors to consider. It might as well be a push mechanism that drains too much, for example. Or local area chats might access geolocation services too much. I have quite a few channels and group chats with notifications disabled for them. I do allow background activity, but my stats are 31 h on screen and 11.5 h background in last 10 days, yet the consumption is mere 28%. I’m a pretty heavy Telegram user and I don’t have issues with excess battery drain. I’d try to disable every single permission for the app and see if it works. It surely will become practically unusable though.

mijndert commented 4 years ago

I don't think us coming up with different ways to possibly work around the problem are very productive. The real problem lies with the developers who seem to refuse to do anything about this problem. I mentioned it on Twitter a couple of times, only to get ignored. This issue has been open for ages now, and if you look around on the internet the issue's been going for much much longer. The only way this problem will get solved is bring it up as much as possible.

My stats in the last 24 hours: On screen 1h44 Background 2h52 Usage 62%

ttyusupov commented 4 years ago

Or local area chats might access geolocation services too much.

I turned off geolocation services for telegram - this didn't help.

mijndert commented 4 years ago

I disabled "download in background" (or whatever it's called) in data settings within Telegram. Looks like it helps a bit, but I'll know for sure 24 hours from now.

akaczm commented 4 years ago

Issue seems to be ongoing, no matter if "background downloading" is on or off. I did notice it seems to be somewhat tied to Telegram use on other devices - including PC. Notifications go through, but don't get cleared once read on another device.

mijndert commented 4 years ago

Disabling 'Download in background' doesn't do anything. Battery usage is still horrible. No response from Telegram at all yet.

mijndert commented 4 years ago

Issue is still going. No answers from Telegram devs.

hyposlasher commented 4 years ago

actually we can spam their email qa@telegram.org

LeviSchuck commented 4 years ago

Ever since upgrading to iOS 13, my device with telegram is literally a heater in my pocket.

This terrible use of my battery stops, and my device cools down, when I kill telegram, the app.

mijndert commented 4 years ago

The last 10 days: 13 hours on screen, 33 hours in background. Insane.

Neliger commented 4 years ago

I join in. Battery usage of this app is incredible, I don't know how it manage to use so much battery in background without having background refresh enabled.

I've killed it and don't use it anymore on iOS, or occasionnaly, then kill the app right after.

mijndert commented 4 years ago

I join in. Battery usage of this app is incredible, I don't know how it manage to use so much battery in background without having background refresh enabled.

I've killed it and don't use it anymore on iOS, or occasionnaly, then kill the app right after.

Any alternatives we can use? The official app is a dumpster fire and the dev should be ashamed.

ttyusupov commented 4 years ago

An alternative could be fork a source code and turn off background tasks on a source code level. But that requires some development work to do. (I am not related to telegram team).

iDevPro commented 4 years ago

And now prevent turn off background mode :) (iOS 13.2.2)

Riconec commented 4 years ago

The same thing for me: SE, iOS13, latest Telegram. Background activities are killing my battery, two times it was too hot (the same as in benchmarks like antutu) and drained almost all battery in 30 minutes

peterevertz commented 4 years ago

I have turned all background activities off. After Rebooting the device has normal battery usage, up to point when telegram is first started. Then the battery is draining again.

iDevPro commented 4 years ago

I have turned all background activities off. After Rebooting the device has normal battery usage, up to point when telegram is first started. Then the battery is draining again.

I can't do this because background activities toggle there is inactive! On iPhone iOS 13.2.2 :) IMG_808694571A7F-1

Riconec commented 4 years ago

I tried to clear cache (5.5Gb) and reinstall app after it drained my SE in only 4 hours. Will report if anything will change

giuseppe4 commented 4 years ago

Same issue for me. Telegram is the main app in Battery statistics. Background activity is there even if I disable background from iPhone settings. Same issue on iPad too.

hyposlasher commented 4 years ago

This is actually getting ridiculous. 96% of battery usage in last 24h 347B1A1C-E087-42E2-807A-4FE4A6CCD272

A-Annan commented 4 years ago

same issue IMG_C33D4627BC5E-1

Riconec commented 4 years ago

I ended up moving to "Nicegram" and now all is fine. Will wait official telegram to catch up

LeviSchuck commented 4 years ago

I am on the Nicegram fork, this issue is not fixed there either. You may just be experiencing a fresh install. @Riconec

Kylmakalle commented 4 years ago

@LeviSchuck You just using Nicegram app for a huge amount of time. Cause the main reason of battery draining is constant update of chatlist, messages, bages and etc in background. Which is currently impossible due to #178

giuseppe4 commented 4 years ago

I can confirm Nicegram doesn’t have this issue. Tested for two days on my iPad with very small usage, and background activity is only 1 minute. In two days Telegram had more than 3h background activity with same usage.

Riconec commented 4 years ago

@LeviSchuck But I also tried cleaning official telegram app and this won't help. But nicegram works nice for me and it is better than strugling with hot phone that drains battery in a few hours since October

kernbug commented 4 years ago

The same problem, iOS 13.3/Telegram 5.13.1.

4m On-screen, 6m Background. Also if a notification has arrived - 1m or 2m in the background the application will work for 1 notification. What for? For a 24h it can drain battery 2h-3h in a background.

Support does not respond, developers does not respond. Do not believe that this is a mistake, most likely the phones are engaged in calculation of various information required by the service.

Preclowski commented 4 years ago

What the hell is going on? Is this time to switch telegram to signal? It does bitcoin mining or something.

DoctorRyner commented 4 years ago

@Preclowski

No, it's time to use Nicegram

ghost commented 4 years ago

~Have anyone tried disabling iOS Call Integration? I want to believe that it disables PushKit for regular notifications, making the app woken up by fewer push notifications. I'm most certainly wrong, don't quote me on this.~

~@Kylmakalle Pardon the cc, but can you confirm that Telegram for iOS uses PushKit/the VoIP priority for push notifications by default?~


Edit: It seems that that doesn't do the trick from my initial testing. It may be that I just don't understand the push notification mechanism on iOS. This is awkward.

Either way, I would love to see an option to receive less time-accurate notifications (or really anything to limit the background activities via push notifications), assuming they're the main culprit here, if it served as a temporary workaround to this issue.

Edit2: Disregarding what I said in the first edit, my long term recommendation would be, if possible, to use to prioritized push notifications, whether silent or regular, for events, such as a message deletion, that only require this treatment (again, I may be wrong, and actually using them all the time solves problems in some edge cases, thus making them an unavoidable necessity). But for now, limiting the time Telegram takes in the background should be a priority. I'm surprised that iOS doesn't enforce hard background time limits on Telegram, despite the iOS 13 bugs that supposedly affect multitasking.

Kylmakalle commented 4 years ago

Hey @Bryophyllum As user - all you can do is to disable Cellular data for Telegram app in your iOS settings, this will prevent voip pushes waking your app while you're not on wi-fi.

Telegram use basic APNS notifications with it's priority types (seems like only max priority used)

Other types of notifications are VOIP/PushKit - which are used for syncing messages, updating badge counter and etc. More info there https://github.com/TelegramMessenger/Telegram-iOS/issues/178

As the docs says - app receives MESSAGE_MUTED VOIP push - Sent rarely, every 10th message in chats or once per 15 sec in PM, to update badge or download messages, which will be kinda frequently if you have a good spare of chats.

You also can get Telegram calls straight to your device via CallKit iOS Call Integration will just disable/enable this API for the app. The main purpose in support disabling CallKit is Chinese Regulatory which does not allow using CallKit. Read more

Since April 2020 Apple will deny all the apps which are using PushKit not for voip calls. It was announced on WWDC 2019. Read More

On the same WWDC 2019 Apple presented new BackgroundTasks feature to comply with their Pushkit restrictions. Solution with iOS 13 BackgroundTasks was implemented in Telegram's code, but it's disabled currently. And does not work in my own builds for some reason :(

On the other hand, there's suspicious entitlement that probably allows app to run in background even with voip pushes and bypass PushKit restrictions. This entitlement not available in public (Requires Apple approvement) and also used by huge companies like WhatsApp, Signal App and etc.

I believe Telegram team will fix all the mess with pushes soon (for forked apps as well!) and iOS will probably do better with battery while on BackgroundTasks module.

MacDragon commented 4 years ago

Yep, noticed my ipad has been draining battery pretty fast in standby nowadays, and battery seems to indicate main user is Telegam form me too.

dderg commented 4 years ago

419C2D67-084D-40B8-AAEC-6A1880FEC9CF

Preclowski commented 4 years ago

Switch to nicegram :) it works well and looks almost same as telegram

dderg commented 4 years ago

I don’t trust third party apps without big enough audience

Preclowski commented 4 years ago

Yeah but telegram is unusable on ios/ipados

dderg commented 4 years ago

It’s okay on my iPhone since I use it quite a lot, but it’s really annoying to take the ipad and realize that battery is dead

Kylmakalle commented 4 years ago

without big enough audience

How many will be enough for you @prog666?

image

dderg commented 4 years ago

8152885B-6C56-4CE7-BE7C-0C7054572350 That’s what AppStore says

Kylmakalle commented 4 years ago

Appstore has different regions. As well as AS separates reviews & ratings in different languages. Probably iPad/iPhone ratings too @prog666