I ran into this same issue a while back, and yeah, it’s a bit of a pain that macOS doesn’t have the `allowsPictureInPictureMediaPlayback` property like iOS does for `WKWebView`. The [Apple docs](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration) make it pretty clear it’s iOS-only, so we’ve got to get creative.
From what I’ve dug up, there’s no direct built-in way to enable Picture-in-Picture (PiP) in `WKWebView` on macOS, but you can lean on the HTML5 Picture-in-Picture API. If your web content supports it (think `videoElement.requestPictureInPicture()` in JavaScript), it should work in `WKWebView`—kinda like how it does in Safari. I’ve tested this with some basic video pages, and it’s solid when the stars align. Check out [MDN’s docs](https://developer.mozilla.org/en-US/docs/Web/API/Picture-in-Picture_API) for the nitty-gritty on that.
Now, here’s the catch: if you’re building for the Mac App Store, sandboxing can throw a wrench in things. Some folks have tried using the `com.apple.PIPAgent` entitlement to force PiP—there’s chatter about it on [Apple’s forums](https://developer.apple.com/forums/thread/756472)—but Apple’s rejected apps for it unless it’s super justified. So, if you’re not going App Store, you might experiment with that, but it’s dicey.
Another workaround I’ve seen is pulling the video URL out of the `WKWebView` and playing it with `AVPlayer`, which does support PiP on macOS. It’s a hassle, though, and not always practical if the video’s buried in tricky web code. [Kodeco’s got a guide](https://www.kodeco.com/24247382-picture-in-picture-across-all-platforms) that touches on this if you’re curious.
Honestly, macOS just doesn’t seem as PiP-friendly for web stuff as iOS. If you control the webpage, the HTML5 API is your best shot. Otherwise, you might be stuck tweaking things case-by-case or waiting for Apple to throw us a bone in a future update. Anyone else found a slicker way around this?
### Key Citations
1. [Apple WKWebViewConfiguration Docs](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration)
2. [MDN Picture-in-Picture API](https://developer.mozilla.org/en-US/docs/Web/API/Picture-in-Picture_API)
3. [Apple Developer Forums](https://developer.apple.com/forums/thread/756472)
4. [Kodeco PiP Guide](https://www.kodeco.com/24247382-picture-in-picture-across-all-platforms)