iOS Audio Lockscreen Problem in PWA

iOS Audio Lockscreen Problem in PWA

Description

When running a PWA on iOS; playing audio from the lockscreen works as expected until you leave the audio paused for 30 seconds. After this, the audio will cease to function until you return the PWA to the foreground.

Reproduction

  1. In a PWA, create an HTML 5 audio element.
  2. Load an audio file into it.
  3. Set navigator.mediaSession data and action handlers for play and pause.
  4. Everything is in working order and your audio plays and pauses from the lock screen.
  5. Pause your audio and wait for 30 seconds.
  6. Now, press the play button. Your audio will no longer function.
  7. At this point, the only way to get the audio to function again is to open the PWA into the foreground. Once you do this, the audio will be in working order.

What is expected

In step number 6, when you press the play button, the audio should play. The lock screen audio should not enter a non-functional state or there should be some way to "wake up" the PWA.

Closing

If you follow these steps exactly on Android, you will see that the problem does not exist on those devices.

Addendum

I have researched additional information which is relevant to this problem.

WakeLock Web API

The WakeLock interface of the Screen Wake Lock API can be used to request a lock that prevents device screens from dimming or locking when an application needs to keep running.

This interface, and hence the system wake lock, is exposed through the Navigator.wakeLock property.

Why this is not a solution

  1. In this case, we want the screen to be able to sleep to conserve battery life for the user. Instead, we want the audio to play after sleep mode has ended. So this is not a solution.
  2. The WakeLock API is supported in all browsers except Mobile Safari iOS. See bug 254545. This bug was reported to Apple over a year ago. Based on my research; the developer community appears convinced that Apple has intentionally broken this functionality in PWA environments in order to keep their App Store monopoly. These are not my views, I am simply sharing my findings.

Addendum

I have done additional research into this matter and I've found some information that is relevant to this problem.

Apple Investigations

It appears that regulators have been investigating Apple for issues like the one we are having related to their antitrust practices.

Apple Lawsuit

Currently the Justice Department, joined by 16 US States, filed a civil antitrust lawsuit against Apple for monopolization or attempted monopolization of smartphone markets in violation of Section 2 of the Sherman Act. This information can be found on the Justice Department's website at justice.gov.

Next Steps

Considering that issues like ours have been reported and ignored for over a year, the next steps for problems like this one is to reach out to the relevant authorities in order to help strengthen their case against Apple.

We will mainly do this by compiling a list of all web features which are supported by all other browser, but not supported by iOS safari listed in order of importance to a web app's success.

iOS Audio Lockscreen Problem in PWA
 
 
Q