Automatic PiP (Picture in Picture) with MusicKit JS in WKWebView

Our iOS app plays Apple Music catalog videos using MusicKit JS v3 in WKWebView. We use a WebView, with the current video visible. Tests are on an iPhone 16e running iOS 26.6.2, built with SDK 27.1.

Inline playback and PiP are allowed, background audio is enabled, and the system’s automatic PiP setting is on.

A real button click calling video.requestPictureInPicture() successfully opens PiP, which continues playing when returning to the Home Screen.

However, leaving the app without opening PiP manually produces audio only. We tested both public video PiP APIs, including an early request from UIScene.willDeactivateNotification. In the latest trace, AVKit reports a visible, supported and eligible source, then reads ForegroundInactive and immediately reports “Failed to start picture in picture.”

The video briefly reports PiP mode before returning inline; no PiP window appears. Our WebKit audio session also changes from ambient to auto on deactivation; its contribution has not been isolated.

  • Is automatic inline PiP supported for MusicKit JS videos in WKWebView?
  • Is there a supported configuration or initialization hook to prepare it while the scene is still active? We do not own WebKit’s underlying controller to set canStartPictureInPictureAutomaticallyFromInline.
  • What lifecycle and audio-session setup does Apple recommend? If this behavior is unexpected, which minimal reproduction and diagnostics would help DTS investigate?
Answered by DTS Engineer in 909106022

Thanks for showing that a tap starts PiP correctly, which narrows this to the automatic case.

I don't see a documented way to start Picture in Picture automatically for a video in a WKWebView, including video that MusicKit JS plays. I also don't see a configuration or setup hook that prepares it while the scene is active. The only PiP setting in WKWebViewConfiguration is allowsPictureInPictureMediaPlayback, which its documentation describes as "A Boolean value that indicates whether HTML5 videos can play Picture in Picture."

The canStartPictureInPictureAutomaticallyFromInline property belongs to AVPictureInPictureController and AVPlayerViewController. It indicates whether PiP starts automatically "when the controller embeds its content inline and the app transitions to the background." No WebKit API exposes a controller like that for web video.

For the app's audio setup, Configuring your app for media playback documents the playback category and the Audio, AirPlay, and Picture in Picture background mode. Beyond that, I don't have a lifecycle or audio-session recommendation. I don't see documentation of either for automatic PiP from web content.

Because no documented API covers this case, an enhancement request fits better than a bug report. Please file one using Feedback Assistant describing your use case: automatic PiP from inline playback for MusicKit JS video in a WKWebView. If you file the request, please post the Feedback number here so I can make sure it gets routed to the right team.

Please note that filing an enhancement request does not guarantee Apple will add any requested functionality to Apple products in the future. However, with that said, filing an enhancement request is a good way to get your ideas in front of the folks who make decisions about that sort of thing.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Thanks for showing that a tap starts PiP correctly, which narrows this to the automatic case.

I don't see a documented way to start Picture in Picture automatically for a video in a WKWebView, including video that MusicKit JS plays. I also don't see a configuration or setup hook that prepares it while the scene is active. The only PiP setting in WKWebViewConfiguration is allowsPictureInPictureMediaPlayback, which its documentation describes as "A Boolean value that indicates whether HTML5 videos can play Picture in Picture."

The canStartPictureInPictureAutomaticallyFromInline property belongs to AVPictureInPictureController and AVPlayerViewController. It indicates whether PiP starts automatically "when the controller embeds its content inline and the app transitions to the background." No WebKit API exposes a controller like that for web video.

For the app's audio setup, Configuring your app for media playback documents the playback category and the Audio, AirPlay, and Picture in Picture background mode. Beyond that, I don't have a lifecycle or audio-session recommendation. I don't see documentation of either for automatic PiP from web content.

Because no documented API covers this case, an enhancement request fits better than a bug report. Please file one using Feedback Assistant describing your use case: automatic PiP from inline playback for MusicKit JS video in a WKWebView. If you file the request, please post the Feedback number here so I can make sure it gets routed to the right team.

Please note that filing an enhancement request does not guarantee Apple will add any requested functionality to Apple products in the future. However, with that said, filing an enhancement request is a good way to get your ideas in front of the folks who make decisions about that sort of thing.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Thanks for your answer. Are you sure this shouldn't be reported as a bug ? As the video briefly reports PiP mode before returning inline while no PiP window appears ?

Thanks for following up. The behavior you describe, where the video reports PiP mode and then returns inline with no PiP window, is reasonable to report as a bug. Please file it using Feedback Assistant as a separate report from the enhancement request for automatic PiP, and include:

  • which API you called, such as requestPictureInPicture() or webkitSetPresentationMode()
  • what the promise from requestPictureInPicture() did, if you called it: resolved, rejected (with which error), or never settled
  • the PiP and presentation-mode events you logged, with timestamps
  • a sysdiagnose captured right after you reproduce the problem
  • a small project that reproduces it, ideally with a plain <video> element in a WKWebView so that it doesn't need an Apple Music subscription

If you file it, please post the Feedback number here so I can make sure it gets routed to the right team.