MusicKit JS loses PiP continuity between queued music videos in a background WKWebView

We are trying to play consecutive Apple Music videos in Picture in Picture from a native iOS app.

Our minimal reproduction uses one WKWebView, one MusicKit JS v3 instance and one preloaded queue. There are no parallel players or transitions implemented by our app.

Setup:

  • Inline playback enabled; allowsPictureInPictureMediaPlayback reads true.
  • UIBackgroundModes includes audio.
  • Initial PiP is opened through a user gesture and works correctly.
  • Reproduced on iOS 26.6.2 and iOS 27.0; failure details vary between runs.
await music.setQueue({
  musicVideos: ["1445284008", "1258705880", "290361007"]
});
await music.play();

The user opens PiP, goes to the Home screen and lets the first video finish naturally.

At the queue boundary, MusicKit replaces its HTMLVideoElement. The existing PiP window closes, and the next video does not inherit the presentation.

We also tested requesting PiP once on the new element, after it becomes ready, including a variant waiting for playing. In affected background runs, the element briefly reports the WebKit PiP mode, then receives leavepictureinpicture without enterpictureinpicture. The standard requestPictureInPicture() promise remains pending during observation. Native logs report a failed new PiP start while the source scene is backgrounded.

The equivalent explicit handoff succeeds in the foreground. In one background configuration, the next video continued audibly, while the PiP window still closed. Explicit native playback audio-session configuration did not resolve the continuity issue.

Is there a supported way to:

  1. Preserve the underlying media element/PiP presentation across MusicKit queue items?
  2. Transfer an existing PiP session to the replacement element while backgrounded?
  3. Obtain a reliable error or rejection when native PiP startup fails but the JavaScript promise remains pending?

We can provide a minimal reproducer and correlated JavaScript/native logs.

MusicKit JS loses PiP continuity between queued music videos in a background WKWebView
 
 
Q