NoSleep.js
NoSleep.js copied to clipboard
Does not work on mobile Firefox
- Device Name: Shift Phone
- Device Version: 6m
- Browser Name: Firefox
- Browser Version: 68.0
- NoSleep.js Version: v0.9.0
Expected Behavior
I expect that the live demo keeps my screen from going black when I click the button and the background turns green.
Actual Behavior
The screen goes to sleep.
How Do We Reproduce?
I don't know if you can reproduce it, I was a bit surprised that I seem to be the only one with this. It works in chrome, my firefox doesn't turn off when I am on youtube, but surprisingly it also turns the screen off when I am running this site: https://gist.github.com/dmlap/5643609 (I added loop to the video tag and pressed play, still goes to sleep after a while). Maybe it has something todo with the fact that I installed adblock plus there but I deactivated it and it still happened. And also it seems to work on youtube with adblock on.
I can confirm that nosleep.js does not work on firefox 68.0 on android 8.1.0.
For what it's worth, there is a webcomponent WakeLock repo here. Disclaimer: I am the author.
Hello.
I can confirm that it does not work either using Firefox Browser 68.3.0 on Android 9 Pie.
Is there any trick to make it work without using that web component?
Thanks!
@madeInLagny I could not make your solution work on the latest version of Firefox android. There must be a way as Firefox does not go to sleep when watching a video.
Has anyone found a solution?
Hi, I could fix this by commenting the line
this._addSourceToVideo(this.noSleepVideo, 'webm', webm)
Is this still a problem with the latest version 91.2.0? It seems to work for me on two different Android devices (using Android 10). For an older version I was able to reproduce the problem I think it was 89.0 but not 100% sure.
(
Be aware of caching as I initially played around with source modification too and couldn't get it working, but after clearing the caches it worked (using npm pack
to create a local distribution nosleep.js-0.12.0.tgz
and then npm install nosleep.js-0.12.0.tgz
in my app to install it). And so I digged in code in firefox that seems to detect the audio part and decides not to lock the screen if no audio is available. See the code comment here and the comment in this repo containing no sound. See also these firefox tests indicating that this is expected behaviour. But likely they use different code for their mobile browser as it seems to be working now. Not sure.
)
Seems to intermittently be an issue on Firefox 99.2.0 on Android.
I have Firefox 99.2.0 (for Android 11) here too and nosleep is working for me. Really strange...
I suspect this could be caused on some devices by the (default?) blocking of auto-play media.
This is what I encountered on Firefox 102.0 on Ubuntu, with the browser informing me that it had blocked auto-play media.
I had again problems with Firefox on Android and I got it working when I always set the "loop" attribute:
this.noSleepVideo.loop = true;
(Currently this is only done if webm is the source)