Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Safari IOS 15.0 #135

Open
vivipeder opened this issue Sep 26, 2021 · 25 comments
Open

Not working with Safari IOS 15.0 #135

vivipeder opened this issue Sep 26, 2021 · 25 comments

Comments

@vivipeder
Copy link

Not working with last update IOS 15.0!

@pinoceniccola
Copy link

From my quick tests, iOS 15 Safari stays awake only if the video is playing, has no loop flag, is not muted AND is visible on a webpage (also tried absolute positioning with opacity:0 with no luck).

At this point, with no new workarounds available, there's only hope for proper Screen Wake Lock API support somewhere in the future.

@RotemAkerman
Copy link

I can confirm, doesn't work since IOS 15

@marcphk
Copy link

marcphk commented Oct 2, 2021

Reckon this'll work with a 1x1 mp4? Perhaps it's the new spacer.gif...

@vivipeder
Copy link
Author

vivipeder commented Oct 7, 2021

Apparently it's working again on IOS 15.0.1 update!

@cerchez07
Copy link

Not working for me on iOS 15.0.2. Also I am seeing in Network tab that the video is infinitely fetched?

@rhamnett
Copy link

rhamnett commented Nov 7, 2021

Anyone found a solution to this?

@steida
Copy link

steida commented Nov 8, 2021

@rhamnett I think if your iPhone is seeing your face, it will not lock.

@rhamnett
Copy link

rhamnett commented Nov 8, 2021

@steida thanks, seems you are correct!

@paulaegido
Copy link

It happens to me too. I have it set that once you press the login button, the function is activated to prevent the screen from suspending. The call and execution seems to work fine, but it doesn't work, and both on IOS and Android and on computers, the screen turns off.

@brunocarneiro
Copy link

brunocarneiro commented Nov 18, 2021

I can confirm it's not working on iOS 15.1 but on Androids are.
Seems the event 'timeupdate' is not being called. Then, the video is only played once.
Tried many things but none gave any good result.

@z-x
Copy link

z-x commented Nov 19, 2021

@brunocarneiro @paulaegido @rhamnett Found a solution. It seems that the timeupdate event is only triggered when the element is actually appended to DOM, so this few lines did the trick.

const hideCss = {
  position: 'absolute',
  left: '-100%',
  top: '-100%'
}
Object.assign(this.noSleepVideo.style, hideCss);

document.querySelector('body').append(this.noSleepVideo);

this.noSleepVideo.addEventListener("loadedmetadata", () => {
[...]

@richtr - I'm kinda too lazy to fork the whole repo, would you apply this to the code?

@z-x
Copy link

z-x commented Nov 20, 2021

@RotemAkerman - Well I guess you are missing something, would need to see the code to help.

@RotemAkerman
Copy link

My bad, had the script in <head> so <body> wasn't indeed present during execution

@brunocarneiro
Copy link

brunocarneiro commented Nov 26, 2021

@z-x Nice! I can confirm it's working now!
Many thanks!

@andy88ctv
Copy link

This works on an iPhone 8 but doesn't work on an iPhone SE2020 both running 15.1

@paulaegido
Copy link

const hideCss = {
position: 'absolute',
left: '-100%',
top: '-100%'
}
Object.assign(this.noSleepVideo.style, hideCss);

document.querySelector('body').append(this.noSleepVideo);

this.noSleepVideo.addEventListener("loadedmetadata", () => {
[...]

@z-x where should I put this? I have my NoSleepJS in my custom.js.

@paulaegido
Copy link

Okey this works for me!
https://github.com/Uriopass/NoSleep.js

Found it in #138

@brunocarneiro
Copy link

Hey everyone, it seems it stopped working. Is it happening with you too?

@dkt01
Copy link

dkt01 commented Sep 2, 2022

It's not working for me in iOS 15.6.1 with NoSleep 0.12.

@z-x
Copy link

z-x commented Sep 9, 2022

@brunocarneiro @dkt01 iOS 15.6.1 seems to be working for https://pushu.ps running as a PWA, the source is open if you want to figure it out by yourselves: https://github.com/z-x/pushu.ps/

@dkt01
Copy link

dkt01 commented Sep 9, 2022

@z-x That site isn't working on my phone either. It still locks the screen after the time I've configured.
My app is also an open source PWA ( Sequence Timer - Source ). nosleep.js is activated while the timer is running.
On the pushu.ps site, at what point is it supposed to disable sleep?

@z-x
Copy link

z-x commented Sep 9, 2022

@dkt01 - on the training screen, right after you click 'Start next training'. I've just checked and left the screen open and it does not turn off.

@dkt01
Copy link

dkt01 commented Sep 9, 2022

@z-x, thanks. I can confirm that that page within pushu.ps does keep my screen awake and unlocked. I'll have to check how my application is misusing the nosleep.js library.

@MasterInQuestion
Copy link

    [ Quote pinoceniccola @ CE 2021-09-28 10:56:16 UTC:
https://github.com/richtr/NoSleep.js/issues/135#issuecomment-929079462
    iOS 15 Safari stays awake only if the video ... is visible on a webpage ]
<^>    Unsure what's going on with Safari.
    But from my testing on large variety of browsers [1]: all of them could work without having the "<video>" attached to the DOM.
    And Chrome (all versions) doesn't seem to require the existence of audio.

[1] Both contemporary and legacy Firefox and Chrome.

@aroman
Copy link

aroman commented Jul 24, 2023

fwiw, i'm using iOS 15.7 and i cannot reproduce this issue. i'm not sure if something changed in later versions of iOS 15, but inserting the video into the document seems not to be necessary anymore...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests