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

Wakelock API iOS 16.4 browser mode vs Add to home screen mode #156

Open
pelord opened this issue Mar 30, 2023 · 14 comments
Open

Wakelock API iOS 16.4 browser mode vs Add to home screen mode #156

pelord opened this issue Mar 30, 2023 · 14 comments

Comments

@pelord
Copy link

pelord commented Mar 30, 2023

  • Device Name: Apple
  • Device Version: iOS 16.4
  • Browser Name: Safari
  • Browser Version: 16.4
  • NoSleep.js Version: 0.12.0

Expected Behavior

NoSleep is suposed to handle iOS 16.4

Actual Behavior

When using the Wake Lock API, on Safari, in a browser mode, the Wake Lock API work properly.
On the same website, opened after have done "Add to home screen", the Wake Lock API don't work properly. The Wake Lock API seem to not be able to be acquired.

An issue has been reported to WebKit https://bugs.webkit.org/show_bug.cgi?id=205104

How Do We Reproduce?

Here the test page: https://pelord.github.io/wakeLockApiAddHomeScreen/

To test the Wake Lock API, you have to toggle the ZZZ button.

Unchecked ZZZ = Wake Lock API released
Checked ZZZ = Wake Lock API acquired

I'll try do propose a PR soon.

@z-x
Copy link

z-x commented Apr 25, 2023

When I saw Safari upgrading to support Wakelock I was like 'AT LAST'. And then I saw it doesn't work in PWA at all, and on top of that it breaks the current NoSleep workaround so my app just broke for people overnight. That is just stupid. Thanks for letting the Safari team know!

@pelord
Copy link
Author

pelord commented Apr 25, 2023

Here my local fix.

image

@z-x
Copy link

z-x commented Apr 25, 2023

@pelord - this will disable the Wake Lock for both - in-browser and apps pinned to home screen, right? You could test against this as well to target just the PWAs:

window.matchMedia('(display-mode: standalone)').matches

@pelord
Copy link
Author

pelord commented Apr 25, 2023

You're right. In my specific use case, my users are strongly encouraged to "Install" the app... but, I will try it soon. Thanks for the hint..

@Mrc527
Copy link

Mrc527 commented Sep 25, 2023

I’m having the same issue, in-browser app works but as soon as I install it on my device, the wake lock is not acquired anymore.

Any chance to incorporate the fix a new revision of the library? I know it’s not nice but if the native functionality is broken in PWA mode, we cannot rely on that.

@pelord
Copy link
Author

pelord commented Sep 25, 2023

Still not fixed in iOS 17
https://bugs.webkit.org/show_bug.cgi?id=254545

@Mrc527
Copy link

Mrc527 commented Sep 26, 2023

Anything we can do to overcome the issue at least temporarily?

@jebabin
Copy link

jebabin commented Sep 26, 2023

The fix provided by @pelord works perfectly, so I would suggest to use it. When IOS will have a fix, then we will need to chance the regex to only match the bugged versions

@Mrc527
Copy link

Mrc527 commented Sep 28, 2023

The fix provided by @pelord works perfectly, so I would suggest to use it. When IOS will have a fix, then we will need to chance the regex to only match the bugged versions

OK but that’s requiring a change in the library, isn’t it? I mean, I’ve to insert nosleep as code instead of installing it via yarn and apply this change on the nosleep code right?

@robertvanlienden
Copy link

robertvanlienden commented Sep 28, 2023

I think https://github.com/Uriopass/NoSleep.js is the most active/working for for this repo.

Maybe we can submit a PR to that repo to add the fix of pelord.
It seems that the owner of this repository never looks back on it 😢 .

For Android this repository works fine on most browsers, but iOS seems to be a pain in the 🍰 ...

@zakj
Copy link

zakj commented Oct 13, 2023

I forked this repository and included the above fix (with @z-x's modification): https://github.com/zakj/no-sleep

It's published on npm as @zakj/no-sleep. I couldn't resist some refactoring so buyer beware, but it's working for me.

@Mrc527
Copy link

Mrc527 commented Oct 13, 2023 via email

@HenriqueMatias
Copy link

I forked this repository and included the above fix (with @z-x's modification): https://github.com/zakj/no-sleep

It's published on npm as @zakj/no-sleep. I couldn't resist some refactoring so buyer beware, but it's working for me.

Hey thanks for the improvement in the lib. So this should fix the issue with browsers in IOs 16 ? or I misunderstood?

@zakj
Copy link

zakj commented Jun 16, 2024

Yep, it's working for me.

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

7 participants