Want to run a PWA in the background?
Easy, just play music constantly, and the OS won't kill the app.
@Alex Gleason blew my mind with this hack!
Thread
Login to reply
Replies (26)
So like a silent 1s 1kb loop?
Yep β thatβs the same black magic Aegis relies on to keep running in the background on iOS
Yea but which song?
All of them
G is gatekeeping the knowledge.
The answer is Earl Scruggs Foggy Mountain Breakdown
Yeah, ... which wallet did that with some annoying beep sound I had trouble figuring out? Play mostly silence please!
What's the impact of this on battery life?
I guess as much as any music player?
That's not a lot on its own, but can multiple PWAs play concurrently? If so, the impact might be quite noticeable!
I love the idea as a hack, but I also like efficient programming π
Nope, only one app can use the hack at a time, and it breaks when the user wants to listen to actual music.
Let's use this π
I play a video in minimized mode at work to keep my computer alive.
brilliant!
I don't know if this is a joke but look this @Cody
No wonder some apps immediately shut off my music when I open them. π
The same trick works for native apps as well, including iOS
Lol yeah, the βjust play silent audio to keep a PWA aliveβ trick technically works because mobile OS schedulers whitelist active media sessions from background throttling. It basically hijacks the systemβs media lifecycle to prevent service workers from being garbage-collected. Itβs clever, but itβs also a battery vampire, surfaces phantom media controls, and gets flagged in App Review if you ever wrap it natively. Real background stability comes from periodic sync, web push, and wake locks, not abusing the audio pipeline.
Educate yourselves.
Okay ChatGPT
The vibe-coding morons will never understand.
π€―
Good for PWAs. For native apps, good for Testflight, but try getting past AppStore review with it.
Yeah I was wondering that too...
Might not even go through test flight...
Yeah don't bother. There's no hope. If you sneak it by App Store review once, then on some future update they'll zoink you. PWA best for now.
In @Nostria you can listen do podcasts (any RSS feed), live streams, music, etc and it'll stay up in the background. Can even lock your phone and it displays on lock screen, supports skip, etc.
When videos are playing it should also do the keep screen alive, I'll get that added soon.
Wouldn't use this trick to play a muted sound for staying alive, perhaps for some very specific purpose.
I was hopeful some months back to do remote signer using Tauri (like Electron just more optimized), unfortunately it kills the WebView as soon as its hidden, so all logic must be written in the Rust part of Tauri apps.
Which OS kills the PWA in the background?
There are some API's to do some background stuff with PWAs.
πΆπΌπ΅βΎοΈ
View quoted note β