question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Closing Element closes background services

See original GitHub issue

Hello,

I’m using Android 10 with Element from F-Droid store. When I’m closing the app from “Recent apps” menu, this also stops any background activity, such as listening for events. This was not the case for Android 8 + RiotX. Also, for example, Telegram FOSS (which also has custom push notifications mechanism and not firebase) doesn’t cancel event listening in this case.

Also Element does not appear in Developer options -> Running services unlike mentioned Telegram FOSS.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
andrewaylettcommented, Feb 25, 2021

My current understanding of this issue is that Element schedules synchronisation using a Worker or an Alarm, has a notification active while actually syncing, then schedules the next synchronisation. But if the system declines to run your worker, there’s no mechanism for restarting. I’ve had a play about with trying to add one (in #2921) but I’m not entirely clear that’s the direction to go in.

Also, we currently run the SyncService as a background service which runs a thread doing long-polling only while the application is in the foreground. From https://developer.android.com/guide/components/foreground-services?hl=en#start I think that it should be possible to run the SyncService as a foreground service even when not actively running the application. This would result in a persistent notification (which can be hidden) and an ongoing sync. As we’re long-polling, this wouldn’t use (much) more battery than FCM, even, and should help avoid the delay of restarting synchronisation when returning to the app.

2reactions
immanuelfodorcommented, Mar 10, 2021

Gotify Android (https://github.com/gotify/android), the self-hosted notification system, uses a websocket connection with its server + recommends disabling battery optimizations + utilizes a foreground notification for keepalive. In my experience, it uses minuscule battery over the day, doesn’t even show up on the battery stats page in Settings. However, I always receive every notification instantaneously.

Two takeaways:

  • Maybe an optional minimized notification can keep Element running (could be turned on in app settings)
  • A websocket-based notification method could be tudned on if Synapse or another used Matrix homeserver supported it. It could be a viable alternative to FCM notifications for users without Play services. It could also provide an alternative to privacy minded self-hosters even when they have Play services and even if they know that the notifications are also E2E encrypted but want to go for the all-selfhosted way.
Read more comments on GitHub >

github_iconTop Results From Across the Web

When closing my app, it remains in background - Stack Overflow
1 Answer 1 · Either make the threads realize application is stopping (difficult but efficient approach) · Tell threads to terminate automatically ...
Read more >
Element does not stay running in background #2143 - GitHub
I'll try to always close it from now on and see if I can discern a pattern. I was able to reproduce the...
Read more >
Exit Chrome Completely by Closing Background Apps ...
Step 1: Go to Settings in Google Chrome. chrome settings ; Step 2: Scroll to the bottom of the screen and click Show...
Read more >
Close programs running in the background in Windows
3. From the Windows Task Manager, open the Applications tab. From the Applications tab, highlight each application you want to close and then...
Read more >
Error about closing apps or processes while installing
Error asking you to close an app or process. Some apps or processes run in the background even though you do not see...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found