I'm building a Capacitor iOS app with a plain <video> element playing an MP4 file inline. I want Picture-in-Picture to activate automatically when the user goes home — swipe up from the bottom edge of the screen (on an iPhone with Face ID) or press the Home button (on an iPhone with a Home button).
Fullscreen → background works perfectly — iOS automatically enters Picture-in-Picture. But I need this to work from inline playback without requiring the user to enter fullscreen first.
Setup
<video id="video" playsinline autopictureinpicture controls
src="http://podcasts.apple.com/resources/462787156.mp4">
</video>
// AppDelegate.swift
let audioSession = AVAudioSession.sharedInstance()
try? audioSession.setCategory(.playback, mode: .moviePlayback)
try? audioSession.setActive(true)
UIBackgroundModes: audio in Info.plist
allowsPictureInPictureMediaPlayback is true (Apple default)
iOS 26.3.1, WKWebView via Capacitor
What I've tried
1. autopictureinpicture attribute
<video playsinline autopictureinpicture ...>
WKWebView doesn't honor this attribute from inline playback. It only works when transitioning from fullscreen.
2. requestPictureInPicture() on visibilitychange
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden' && !video.paused) {
video.requestPictureInPicture();
}
});
Result: Fails with "not triggered by user activation". The visibilitychange event doesn't count as a user gesture.
3. webkitSetPresentationMode('picture-in-picture') on visibilitychange
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden' && !video.paused) {
video.webkitSetPresentationMode('picture-in-picture');
}
});
Result: No error thrown. The webkitpresentationmodechanged event fires with value picture-in-picture. But the PIP window never actually appears. The API silently accepts the call but nothing renders.
4. await play() then webkitSetPresentationMode
document.addEventListener('visibilitychange', async () => {
if (document.visibilityState === 'hidden') {
await video.play();
video.webkitSetPresentationMode('picture-in-picture');
}
});
Result: play() succeeds (audio resumes in background), but PIP still doesn't open.
5. Auto-resume on system pause + PIP on visibilitychange
iOS fires pause before visibilitychange when backgrounding. I tried resuming in the pause handler, then requesting PIP in visibilitychange:
video.addEventListener('pause', () => {
if (document.visibilityState === 'hidden') {
video.play(); // auto-resume
}
});
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden' && !video.paused) {
video.webkitSetPresentationMode('picture-in-picture');
}
});
Result: Audio resumes successfully, but PIP still doesn't open.
6. Native JS eval from applicationDidEnterBackground
func applicationDidEnterBackground(_ application: UIApplication) {
webView?.evaluateJavaScript(
"document.querySelector('video').requestPictureInPicture()"
)
}
Result: Same failure — no user activation context.
Observations
The event order on background is: pause → visibility: hidden
webkitSetPresentationMode reports success (event fires, no error) but the PIP window never renders
requestPictureInPicture() consistently requires user activation, even from native JS eval
Audio can be resumed in background via play(), but PIP is a separate gate
Fullscreen → background automatically enters Picture-in-Picture, confirming the WKWebView PIP infrastructure is functional
Question
Is there any way to programmatically enter PIP from inline playback when a WKWebView app goes to background? Or is this intentionally restricted by WebKit to fullscreen-only transitions?
Any pointers appreciated. Thanks!
WebKit
RSS for tagDisplay web content in windows and implement browser features using WebKit.
Posts under WebKit tag
200 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
We are experiencing an issue after Xcode 26.0 to load local javascript files to WKWebView to render our own design.
it used to work well, however after Xcode 26.0, when
[self.webView loadFileURL:fileURL allowingReadAccessToURL:accessURL];
it returns
[PID=1514] WebProcessProxy::hasAssumedReadAccessToURL(3198190): no access
self.webRootPath = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:CHAT_VIEW_WEB_ROOT];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error = nil;
if (! [fileManager fileExistsAtPath:self.webRootPath]){
[fileManager createDirectoryAtPath:self.webRootPath withIntermediateDirectories:NO attributes:nil error:&error];
}
NSURL *accessURL = [NSURL fileURLWithPath:self.webRootPath];
Not sure how to assign access permission to WKWebView.
Any help much appreciated.
Subject: Cross-Domain Access Behaviour in WKWebView – Clarification Required
Description:
We are facing a cross-domain issue in our iOS application where WKWebView loads content from one domain and attempts to access resources/data from another domain.
Current Setup:
App Platform: iOS
WebView: WKWebView
iOS Version: 26
Primary Domain: *.franconnectqa.net
Data/Analytics Domain: analytics.franconnectdev.net
SSL: Valid certificates configured
ATS: Enabled
Issue:
When WKWebView loads content from franconnectqa.net, it attempts to access resources or analytics from analytics.franconnectdev.net, resulting in cross-domain restrictions.
We would like to understand:
Does WKWebView support cross-domain resource access by default?
Are there any configuration settings that allow controlled cross-domain access?
Are there known limitations regarding cookies, local storage, or session sharing across domains?
Does WKWebView enforce additional restrictions beyond standard browser CORS policies?
Are there recommended best practices for handling cross-domain scenarios in WKWebView?
Expected Behavior:
We want to determine whether:
Cross-domain access is supported under certain configurations, OR
The recommended approach is to align all resources under the same domain.
Kindly provide guidance on the supported architecture and any configuration recommendations.
Hi, we were recently approved for the com.apple.developer.web-browser.public-key-credential entitlement and have added it to our app. It initially worked as expected for a couple of days, but then it stopped working. We're now seeing the same error as before adding the entitlement:
Told not to present authorization sheet: Error Domain=com.apple.AuthenticationServicesCore.AuthorizationError Code=1 "(null)"
ASAuthorizationController credential request failed with error: Error Domain=com.apple.AuthenticationServices.AuthorizationError Code=1004 "(null)"
Do you have any insights into what might be causing this issue?
Thank you!
When using passkeys stored in iCloud Keychain (Passwords app) via Passkey Autofill in browsers other than Safari, the userVerification parameter is ignored and user verification (UV) is not performed.
As a result, relying party servers that require userVerification = required fail validation because the UV flag is not set, causing passkey authentication to fail.
This issue occurs when the following setting is disabled:
Settings → Face ID & Passcode → Use Face ID For → Password AutoFill
The issue is reproducible only with the following combination:
Non-Safari browsers (e.g. Chrome)
Passkeys stored in iCloud Keychain (Passwords app)
Passkey Autofill
The issue does not occur in the following cases:
Safari with passkeys stored in any credential manager
Non-Safari browsers using credential managers other than iCloud Keychain
Steps to Reproduce:
Go to Settings → General → Autofill & Passwords, and enable the Passwords app under “Autofill From”.
Go to Settings → Face ID & Passcode → Use Face ID For, and disable “Password AutoFill”.
Open Chrome and navigate to https://webauthn.io
Enter a username and tap “Register” to create a passkey using the Passwords app (iCloud Keychain).
On webauthn.io, go to Advanced Settings → Authentication Settings, and set “User Verification” to “Required”.
Reload the page, tap the input field, and perform Passkey Autofill.
User Verification is not triggered, and “Authentication failed” is displayed on webauthn.io.
===
This issue has already been reported via Feedback Assistant as FB21756948.
I am posting here to confirm whether this behavior is working as intended or represents a bug, and to make other developers aware of the current behavior.
Hi,
We're experiencing a WKWebView issue where the screen intermittently turns pure magenta (#FF00FF) in our production iOS app. After investigation, we traced this to WebKit's internal WKCompositingView.mm where [UIColor magentaColor] is used as a pending state indicator when coverView.hidden == NO.
This matches rdar://163597990 / WebKit Bug 303157 ("Magenta flash when loading page"), which was fixed in commit 303720@main on 2025-12-01 via PR #54499.
My question is simple: which iOS/Safari release includes this fix?
We're on iOS 26.3 and still seeing the issue. We need to know:
Is the fix already in iOS 26.3? (If so, there may be another unfixed code path)
If not, which upcoming iOS version will include it?
Our environment
iOS 26.3, iPhone 15 Pro Max
WKWebView with complex web content
App codebase contains zero magenta color usage — this is purely from WebKit
Related
rdar://163597990
Bug 303157 — RESOLVED FIXED
Bug 230531 — "Pages render as magenta after being in background"
PR #54499 — Merged to main 2025-12-01
Any information about the release timeline would be very helpful. Thanks!
In iOS 26.4 beta, I noticed that when loading pages using WKWebView and using WebSocket to establish IP type addresses, the connection duration was several seconds and sometimes even failed to connect (normally, the connection duration should be in milliseconds). However, when establishing WebSocket connections using domain names, the connections were normal.
Additionally, I discovered a special scenario:
When directly establishing WebSocket connections using IP type addresses, it remained in the "connect" state. At the same time, based on Wireshark packet capture, it was found that no TCP connection was sent at this time. However, if two connections with the same address were established simultaneously, those two connections could successfully connect.
This bug has seriously affected the use of my application service. Is there a chance that this version will solve the problem?
Before iOS 26.3, the WKWebView method open func loadFileURL(_ URL: URL, allowingReadAccessTo readAccessURL: URL) -> WKNavigation? worked fine when both parameters were passed the same path (e.g., h5path/index.html), allowing access to and loading of other files like CSS and JS within the h5path directory. However, in iOS 26.4 Beta, this results in an error, and the second parameter must point to a parent directory. Is this a bug?
Hi Team,
We're trying to load an Image Ad inside WKWebView and we're wondering if we can adjust its width and height based on the loaded content.
Currently, we're using evaluateJavaScript("document.body.scrollHeight") query to fetch the height of the content but often times we get incorrect value from it.
We looked at the WKWebView documentation but couldn't find anything related to our use case.
Could someone from the team guide us through the next step?
Thanks
We are developing a mobile-first, browser-only web application that requires users to upload 20–200 images stored inside a single folder (for example, a merchant product directory).
On iOS Safari:
window.showDirectoryPicker() is not supported.
is not supported.
File System Access API is not available.
Users must manually multi-select images from the Photos picker.
This creates significant friction for bulk upload workflows.
We are NOT requesting unrestricted file system access.
We are asking whether a privacy-preserving, user-granted folder-scoped permission model is being considered for web applications. For example:
User explicitly selects a folder.
The web app receives scoped access only to that selected folder.
Access is session-bound and revocable.
No background or global storage access is required.
Questions:
Is folder-level access for web apps being considered for iOS Safari?
Does installing a PWA provide any enhanced file access capability?
Are there recommended best practices for handling bulk image uploads in browser-only iOS applications?
Is there any roadmap alignment with the File System Access API standard?
Our goal is to remain browser-only and maintain strict user privacy while improving usability for high-volume image workflows.
Any clarification on intended platform direction would be appreciated.
Hello there,
Credit card autofill works in Safari when accessing the checkout on my website, but does NOT work when the same page is loaded in a WKWebView within the my iOS mobile app.
is there any way I can make it work?
Summary:
We are facing a serious issue on iPhone where multiple passkey authentication problems occur when accessing passkey-enabled login pages via shortcuts placed on the iPhone Home Screen. These issues may also occur when opening the same pages directly in a standard browser window. However, launching the login pages from a Home Screen shortcut appears to increase the likelihood of encountering these issues.
Affected Services (examples, not exhaustive):
Amazon
GitHub
Adobe
Observed Issues:
Issue 1: A passkey authentication dialog/popup shows two times without any user operation:
What happens due to this issue:
Login does not complete after the first passkey authentication.
A second passkey authentication UI automatically appears.
Completing or canceling the second authentication allows the login to proceed.
Issue 2: Login remains stuck until the user manually invokes passkey again
What happens due to this issue:
The login page does not advance after the first authentication.
The user must tap the ID/username field again to manually trigger the passkey UI.
Completing the second authentication enables login.
Issue 3: Automatic second authentication occurs, but login still fails
What happens due to this issue:
A second automatic authentication UI appears.
Login still does not complete.
Tapping the ID field no longer opens the passkey UI; instead, the password auto-fill panel appears.
Passkey login becomes impossible.
Observed reproduction steps (not guaranteed but most consistently observed):
On iPhone, navigate to a passkey-enabled login page (e.g., Amazon, GitHub, Adobe) using a browser.
Create a shortcut from the browser's share menu and place it on the Home Screen.
Launch the login page from the Home Screen shortcut.
Tap the ID/username field to invoke the passkey prompt.
Complete passkey authentication.
→ One of the issues described above occurs.
Environment:
Device: iPhone SE
OS: iOS 18.6.2
Topic:
Safari & Web
SubTopic:
General
Tags:
WebKit
Safari
Safari and Web
Passkeys in iCloud Keychain
Hello,
After upgrading to macOS 26.2, I’ve noticed a significant performance regression when calling evaluateJavaScript in an iOS App running on Mac (WKWebView, Swift project).
Observed behavior
On macOS 26.2, the callback of evaluateJavaScript takes around 3 seconds to return.
This happens not only for:
evaluateJavaScript("navigator.userAgent")
but also for simple or even empty scripts, for example:
evaluateJavaScript("")
On previous macOS versions, the same calls typically returned in ~200 ms.
Additional testing
I created a new, empty Objective-C project with a WKWebView and tested the same evaluateJavaScript calls.
In the Objective-C project, the callback still returns in ~200 ms, even on macOS 26.2.
Question
Is this a known issue or regression related to:
iOS Apps on Mac,
Swift + WKWebView, or
behavioral changes in evaluateJavaScript on macOS 26.2?
Any information about known issues, internal changes, or recommended workarounds would be greatly appreciated.
Thank you.
Test Code Swift
class ViewController: UIViewController {
private var tmpWebView: WKWebView?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
setupUserAgent()
}
func setupUserAgent() {
let t1 = CACurrentMediaTime()
tmpWebView = WKWebView(frame: .zero)
tmpWebView?.isInspectable = true
tmpWebView?.evaluateJavaScript("navigator.userAgent") { [weak self] result, error in
let t2 = CACurrentMediaTime()
print("[getUserAgent] \(t2 - t1)s")
self?.tmpWebView = nil
}
}
}
Test Code Objective-C
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
NSTimeInterval startTime = [[NSDate date] timeIntervalSince1970];
WKWebView *webView = [[WKWebView alloc] init];
dispatch_async(dispatch_get_main_queue(), ^{
[webView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id result, NSError *error) {
NSTimeInterval endTime = [[NSDate date] timeIntervalSince1970];
NSLog(@"[getUserAgent]: %.2f s", (endTime - startTime));
}];
});
}
Fatal Exception: NSInternalInconsistencyException
Cannot remove an observer <WKWebView 0x135137800> for the key path "configuration.enforcesChildRestrictions" from <STScreenTimeConfigurationObserver 0x13c6d7460>, most likely because the value for the key "configuration" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the STScreenTimeConfigurationObserver [class.]
I noticed that on iOS 26, WKWebView registers STScreenTimeConfigurationObserver, Is this an iOS 26 system issue? What should I do?
VideoMaterial Black Screen on Vision Pro Device (Works in Simulator)
App Overview
App Name: Extn Browser
Bundle ID: ai.extn.browser
Purpose: A visionOS web browser that plays 360°/180° VR videos in an immersive sphere environment
Development Environment & SDK Versions
Component
Version
Xcode
26.2
Swift
6.2
visionOS Deployment Target
26.2
Swift Concurrency
MainActor isolation enabled
App is released in the TestFlight.
Frameworks Used
SwiftUI - UI framework
RealityKit - 3D rendering, MeshResource, ModelEntity, VideoMaterial
AVFoundation - AVPlayer, AVAudioSession
WebKit - WKWebView for browser functionality
Network - NWListener for local proxy server
Sphere Video Mechanism
The app creates an immersive 360° video experience using the following approach:
// 1. Create sphere mesh (10 meter radius for immersive viewing)
let mesh = MeshResource.generateSphere(radius: 10.0)
// 2. Create initial transparent material
var material = UnlitMaterial()
material.color = .init(tint: .clear)
// 3. Create entity and invert sphere (negative X scale)
let sphere = ModelEntity(mesh: mesh, materials: [material])
sphere.scale = SIMD3<Float>(-1, 1, 1) // Inverts normals for inside-out viewing
sphere.position = SIMD3<Float>(0, 1.5, 0) // Eye level
// 4. Create AVPlayer with video URL
let player = AVPlayer(url: videoURL)
// 5. Configure audio session for visionOS
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setCategory(.playback, mode: .moviePlayback, options: [.mixWithOthers])
try audioSession.setActive(true)
// 6. Create VideoMaterial and apply to sphere
let videoMaterial = VideoMaterial(avPlayer: player)
if var modelComponent = sphere.components[ModelComponent.self] {
modelComponent.materials = [videoMaterial]
sphere.components.set(modelComponent)
}
// 7. Start playback
player.play()
ImmersiveSpace Configuration
// browserApp.swift
ImmersiveSpace(id: appModel.immersiveSpaceID) {
ImmersiveView()
.environment(appModel)
}
.immersionStyle(selection: .constant(.mixed), in: .mixed)
Entitlements
<!-- browser.entitlements -->
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
Info.plist Network Configuration
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
The Issue
Behavior in Simulator: Video plays correctly on the inverted sphere surface - 360° video is visible and wraps around the user as expected.
Behavior on Physical Vision Pro: The sphere displays a black screen. No video content is visible, though the sphere entity itself is present.
Important: Not a DRM/Licensing Issue
This issue is NOT related to Digital Rights Management (DRM) or FairPlay. I have tested with:
Unlicensed raw MP4 video files (no DRM protection)
Self-hosted video content with no copy protection
Direct MP4 URLs from CDN without any licensing requirements
The same black screen behavior occurs with all unprotected video sources, ruling out DRM as the cause.
(Plain H.264 MP4, no DRM)
Screen Recording: Working in Simulator
The following screen recording demonstrates playing a 360° YouTube video in the immersive sphere on the visionOS Simulator:
https://cdn.commenda.kr/screen-001.mov
This confirms that the VideoMaterial and sphere rendering work correctly in the simulator, but the same setup shows a black screen on the physical Vision Pro device.
Observations
AVPlayer status reports .readyToPlay - The video appears to load successfully
VideoMaterial is created without errors - No exceptions thrown
Sphere entity renders - The geometry is visible (black surface)
Audio session is configured - No errors during audio session setup
Network requests succeed - The video URL is accessible from the device
Same result with local/unprotected content - DRM is not a factor
Console Logs (Device)
The logging shows:
Sphere created and added to scene
AVPlayer created with correct URL
VideoMaterial created and applied
Player status transitions to .readyToPlay
player.play() called successfully
Rate shows 1.0 (playing)
Despite all success indicators, the rendered output is black.
Questions for Apple
Are there known differences in VideoMaterial behavior between the visionOS Simulator and physical Vision Pro hardware?
Does VideoMaterial(avPlayer:) require specific video codec/format requirements that differ on device? (The test video is a standard H.264 MP4)
Is there a required Metal capability or GPU feature for VideoMaterial that may not be available in certain contexts on device?
Does the immersion style (.mixed) affect VideoMaterial rendering on hardware?
Are there additional entitlements required for video texture rendering in RealityKit on physical hardware?
Attempted Solutions
Configured AVAudioSession with .playback category
Added delay before player.play() to ensure material is applied
Verified sphere scale inversion (-1, 1, 1)
Tested multiple video URLs (including raw, unlicensed MP4 files)
Confirmed network connectivity on device
Ruled out DRM/FairPlay issues by testing unprotected content
Environment Details
Device: Apple Vision Pro
visionOS Version: 26.2
Xcode Version: 26.2
macOS Version: Darwin 25.2.0
Hello everyone,
I am currently working on integrating a WebView into my macOS application, intended to allow users to browse tutorial webpages directly within the app.
Although I’ve followed an example that appears syntactically correct, the WebView does not render any webpage content.
Below is a code snippet for reference:
import SwiftUI
import WebKit
struct HelpWebView: View {
@State private var toggle = false
@State private var page = WebPage()
private var url: URL {
toggle
? URL(string: "https://www.webkit.org")!
: URL(string: "https://www.swift.org")!
}
var body: some View {
WebView(page)
.onAppear {
page.load(URLRequest(url: url))
}
.onChange(of: toggle) {
page.load(URLRequest(url: url))
}
.toolbar {
Button("Reload", systemImage: "arrow.clockwise") {
toggle.toggle()
}
}
}
}
I would greatly appreciate any insights or suggestions on what might be causing this issue or how to resolve it.
Thank you in advance for your help!
Hello everyone,
I am currently working on integrating a WebView into my macOS application, intended to allow users to browse tutorial webpages directly within the app.
Although I’ve followed an example that appears syntactically correct, the WebView does not render any webpage content.
Below is a code snippet for reference:
import SwiftUI
import WebKit
struct HelpWebView: View {
@State private var toggle = false
@State private var page = WebPage()
private var url: URL {
toggle
? URL(string: "https://www.webkit.org")!
: URL(string: "https://www.swift.org")!
}
var body: some View {
WebView(page)
.onAppear {
page.load(URLRequest(url: url))
}
.onChange(of: toggle) {
page.load(URLRequest(url: url))
}
.toolbar {
Button("Reload", systemImage: "arrow.clockwise") {
toggle.toggle()
}
}
}
}
I would greatly appreciate any insights or suggestions on what might be causing this issue or how to resolve it.
Thank you in advance for your help!
I am using the native SwiftUI WebView and WebPage APIs (iOS 26+) and would like to implement file download functionality using the native SwiftUI WebView. However, I have not been able to find any APIs equivalent to WKDownload.
In WKWebView, the WKDownload API can be used to handle downloads. I am looking for a similar API or recommended approach in the native SwiftUI WebView that would allow downloading files.
If anyone has guidance or suggestions on how to implement this, I would appreciate your help.
Expected Behavior:
Display the digit “6”.
Actual Behavior:
The rendered character appears as a composite glyph—the left half resembles “9” and the right half resembles “6”, resulting in a malformed digit.
other examples:
Environment & Characteristics:
Occurs intermittently on iPhone 15 Pro Max and iPhone 16 Pro Max.
Reproducible within the Taobao App, specifically in WKWebView.
Font Used:
AlibabaSans102_v1_TaoBao-Bd.ttf
I’m currently developing an application using WKWebView.
After updating to iOS 26.2 Developer Beta, the following Web API started returning false:
isUserVerifyingPlatformAuthenticatorAvailable
MDN: https://developer.mozilla.org/ja/docs/Web/API/PublicKeyCredential/isUserVerifyingPlatformAuthenticatorAvailable_static
This issue did not occur on iOS 26.1 — it only happens on the beta version.
Has anyone else encountered this problem or is aware of any related changes?
OS: iOS 26.2 beta 3 (23C5044b)