this post was submitted on 13 Oct 2023
201 points (95.9% liked)

Android

17655 readers
224 users here now

The new home of /r/Android on Lemmy and the Fediverse!

Android news, reviews, tips, and discussions about rooting, tutorials, and apps.

πŸ”—Universal Link: !android@lemdro.id


πŸ’‘Content Philosophy:

Content which benefits the community (news, rumours, and discussions) is generally allowed and is valued over content which benefits only the individual (technical questions, help buying/selling, rants, self-promotion, etc.) which will be removed if it's in violation of the rules.


Support, technical, or app related questions belong in: !askandroid@lemdro.id

For fresh communities, lemmy apps, and instance updates: !lemdroid@lemdro.id

πŸ’¬Matrix Chat

πŸ’¬Telegram channels / chats

πŸ“°Our communities below


Rules

  1. Stay on topic: All posts should be related to the Android OS or ecosystem.

  2. No support questions, recommendation requests, rants, or bug reports: Posts must benefit the community rather than the individual. Please post to !askandroid@lemdro.id.

  3. Describe images/videos, no memes: Please include a text description when sharing images or videos. Post memes to !androidmemes@lemdro.id.

  4. No self-promotion spam: Active community members can post their apps if they answer any questions in the comments. Please do not post links to your own website, YouTube, blog content, or communities.

  5. No reposts or rehosted content: Share only the original source of an article, unless it's not available in English or requires logging in (like Twitter). Avoid reposting the same topic from other sources.

  6. No editorializing titles: You can add the author or website's name if helpful, but keep article titles unchanged.

  7. No piracy or unverified APKs: Do not share links or direct people to pirated content or unverified APKs, which may contain malicious code.

  8. No unauthorized polls, bots, or giveaways: Do not create polls, use bots, or organize giveaways without first contacting mods for approval.

  9. No offensive or low-effort content: Don't post offensive or unhelpful content. Keep it civil and friendly!

  10. No affiliate links: Posting affiliate links is not allowed.

Quick Links

Our Communities

Lemmy App List

Chat and More


founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] limerod@reddthat.com 1 points 1 year ago (4 children)

Unfortunately, that will mean your app can be killed on many smartphones from device makers like xiaomi, Oppo, and huawei, which have aggressive battery optimization. I had this issue on a redmi device where background apps would be killed unless a permanent notification was present.

The WireGuard and tailscale apps work great for me without a persistent notification.

I haven't tried wireguard. But, I should give them a try and see how it goes in samsung.

[–] out@lemmynsfw.com 7 points 1 year ago (1 children)

Ah, I have a pixel which apparently is pretty nice on the not killing your app side

https://dontkillmyapp.com/google

[–] limerod@reddthat.com 1 points 1 year ago (3 children)

The ranking may make it sound like samsung is the worst. But that's not been the case since android 12. I do not have app reload or app killing issues on this one and find it much better than what I used to experience on miui.

[–] russjr08@outpost.zeuslink.net 4 points 1 year ago (1 children)

I published an app on the play store that purely relies on a persistent notification + wakelocks to keep the screen active (since the whole point of the app is to keep the screen awake) - Samsung was definitely the worst when it comes to this for my app, as I would receive endless support emails about people with Samsung devices where it would get killed, even when disabling battery optimization for my app. The other manufacturers listed there came up every now and then, but disabling battery optimization generally did the trick for them.

With there being nothing that I could do for my app, I tried disabling compatibility in the play store for a ton of Samsung models, but then I got even more emails about people wondering why it wasn't available anymore so I re-enabled it, but to this day there's still (AFAIK) zero things I can do to prevent the app from getting killed on those devices.

[–] limerod@reddthat.com 1 points 1 year ago* (last edited 1 year ago) (1 children)

What app is that? I only notice app reload issues when I max my ram usage playing heavy games or running apps that require maximum ram.

[–] russjr08@outpost.zeuslink.net 2 points 1 year ago (1 children)

It's called "Caffeinate" (I'm avoiding posting the direct link just so I don't break any self promotion rules), I made it in the Android 7 days when the quick settings Tile API came out to replicate the similar tile that was available in CyanogenMod. It ended up getting way more downloads than I ever expected honestly - I just wanted to try the new API haha.

I know that Caffeinate itself doesn't use up a lot of RAM (the only thing it does when its active is create a persistent notification and creates a wakelock in order to keep the screen active), but perhaps the lower end Samsung device models just have less RAM available, so opening a browser or such kills it.

[–] limerod@reddthat.com 2 points 1 year ago (1 children)

I tried your caffeinate app. The last time I checked, it was using 32mb while running. Currently, using 11mb. Android says it uses an average of 143kb with a maximum of 7.8mb for the whole day.

It has been installed for the past 3 days, and I try it once a day from the drop-down tile. It hasn't been killed or reloaded yet.

I have 6GB of ram with 6GB of ram plus enabled. I guess its low ram and cpu usage make it never likely to be booted off ram. Those users who complain must be using Samsung devices on older oneui and / or low ram like 3GB or 4GB.

[–] russjr08@outpost.zeuslink.net 2 points 1 year ago (1 children)

Well I definitely am glad to hear that! Yeah the situation is just unfortunate, as there's really nothing I can do for the users who are getting the issue - since as you've seen, Caffeinate is already really light on RAM usage (which would normally be one of the only ways to try to remedy the issue as a developer, from what I can tell).

In the end I just decided to keep it compatible for all mobile devices, though I did consider adding a "compatibility warning" type of banner to the app or a one-time notification for devices that had a small amount of RAM. Eventually the emails stopped coming in about it though so I figured either the problem ended up resolving itself as updates to the platform occurred, or everyone who was going to run into the issue already ran into the issue. I've pretty much considered the app to be feature complete now, short of any Android changes that break it (such as when notification channels was introduced, followed by full-on notification runtime permission requirements).

[–] limerod@reddthat.com 2 points 1 year ago (1 children)

You said the app is feature complete. But, if you find the time and energy to spend. You can probably try to add a dark theme that utilizes the "follow system" theme setting. And later if desired material you theming support. Otherwise, it does the job and is good as far as it can go.

[–] russjr08@outpost.zeuslink.net 2 points 1 year ago (1 children)

Dark theming is definitely a fair point, I'll definitely need to have a look into that.

Material You support is probably going to be out of scope though, as I feel that would be making it complex for the sake of being complex.

I do want to learn more about the Material You API that being said.

[–] limerod@reddthat.com 2 points 1 year ago (1 children)

Hey, I read the top review of a samsung user. Even in my own testing, the app doesn't appear to extend the screen timeout on samsung. It locks out after the default timeout.

[–] russjr08@outpost.zeuslink.net 2 points 1 year ago (1 children)

Interesting, sounds like they're killing the wakelock that Caffeinate acquires then (which is what actually keeps the screen active), rather than killing the whole app itself.

That's another one of those issues that I don't think there's too many workarounds for. Theoretically I might be able to have the app check to see if the wakelock is still active and if not, re-acquire it... but if there's no way for the app to "know" that the wakelock has been killed in the first place, the only way around it would be to constantly ask Android "Is the wakelock still active? Is the wakelock still active? Is the wakelock still active?" over and over again, which would definitely lead to battery issues.

I do know it works on some Samsung devices, as I bought an old A2... something to test it on, and couldn't find any signs of a problem there.

I mean hell, I'd love for there to be a way to not even require a wakelock for Caffeinate, but the only other way is a "soft" wakelock, in which you tell Android "Never turn the screen off while my app's window is open", but of course that would mean you'd need to keep the actual app window in the foreground and would defeat the whole purpose (such as my favorite usecase, keeping the screen on while I'm reading a recipe - or keeping the screen on while I'm tracking a delivery from a food delivery application).

[–] limerod@reddthat.com 2 points 1 year ago

I do know it works on some Samsung devices, as I bought an old A2... something to test it on, and couldn't find any signs of a problem there.

I tested on A22 5g android 13.

I mean hell, I'd love for there to be a way to not even require a wakelock for Caffeinate, but the only other way is a "soft" wakelock, in which you tell Android "Never turn the screen off while my app's window is open", but of course that would mean you'd need to keep the actual app window in the foreground and would defeat the whole purpose

You could also do it so it requests the draw over other apps' permission and have a small UI element keeping the screen on(if it can work). But that could complicate things a bit further. The permission being misused(by malware), and it being restricted in secure places(banking apps, settings, etc). It would be an imperfect solution.

[–] out@lemmynsfw.com 3 points 1 year ago* (last edited 1 year ago) (1 children)

Clicking on Samsung makes it sound like it's still a problem on Android 13 at least.

I'm glad it works for you at least, I have never used a Samsung phone so I might be fixed altogether but idk.

You could if you want, add an issue or something on their GitHub

[–] limerod@reddthat.com 1 points 1 year ago

I do not feel too strongly about it, so I will refrain. But, if I find the time and energy to spend, I may open an issue later.

[–] skullgiver@popplesburger.hilciferous.nl 1 points 1 year ago* (last edited 11 months ago)

[This comment has been deleted by an automated system]

[–] folkrav@lemmy.world 2 points 1 year ago (1 children)

I was under the impression that the "Disable battery optimisations" feature was to prevent exactly this. Maybe I misunderstood what it does, but a bunch of apps designed to run in the background tell you to disable this functionality for their app for this very reason.

[–] BearOfaTime@lemm.ee 4 points 1 year ago (1 children)

Some phone's battery optimization goes beyond the native Android stuff, so even with that step, apps without a notification may get killed.

[–] folkrav@lemmy.world 1 points 1 year ago
[–] ShortFuse@lemmy.world 1 points 1 year ago

That is for applications that need access to a LOCAL_SERVICE while not in foreground. That's like Geolocation or screen orientation. VPN is not one of those. You can kill the foreground application from the recent apps by sliding up.

No real VPN app needs to have an application window and a background service (same thread) running to provide a VPN. If it does, it is doing something else not related to VPN.

If you want to add a pause button, applications can add custom tiles.

[–] eyepatchcheetah@lemmy.world 1 points 1 year ago* (last edited 1 year ago)

WireGuard works fine on my samsung