Display web content in windows and implement browser features using WebKit.

Posts under WebKit tag

200 Posts

Post

Replies

Boosts

Views

Activity

mediaTypesRequiringUserActionForPlayback Configuration in iOS 26 WebView
Hello, I'm exploring the new SwiftUI WebView and WebPage APIs introduced in iOS 26, and I have a question about configuring media playback behavior. In our app, we currently use WKWebView with the mediaTypesRequiringUserActionForPlayback property set to [] (or WKAudiovisualMediaTypeNone) to allow HTML videos with an "autoplay" attribute to play automatically without requiring user interaction. This property is part of WKWebViewConfiguration and controls which media types require a user gesture to begin playing. According to the official documentation (WKWebViewConfiguration.mediaTypesRequiringUserActionForPlayback), this allows us to support video content that needs to autoplay for our specific use case. With the new iOS 26 WebView and WebPage APIs, I haven't been able to find a way to configure this behavior. Looking through the available configuration options, there doesn't appear to be an equivalent setting. My questions are: Has the default behavior changed for the new SwiftUI WebView? Does it now allow media autoplay by default? If not, is there a way to configure this behavior that I'm missing? If this configuration is intentionally not exposed, what is the recommended approach for apps that need to enable media autoplay? Currently, we're wrapping WKWebView in a UIViewRepresentable to maintain this functionality, but we'd love to migrate to the native SwiftUI WebView later this year if possible. Thank you for any guidance you can provide!
1
0
117
4w
javaScriptCanOpenWindowsAutomatically Configuration in iOS 26 WebView
Hello, I'm exploring the new SwiftUI WebView and WebPage APIs introduced in iOS 26, and I have a question about configuring JavaScript window opening behavior. In our app, we currently use WKWebView with the javaScriptCanOpenWindowsAutomatically property set to true to support a specific use case. This property is part of WKPreferences and controls whether JavaScript can open windows without user interaction. According to the official documentation (WKPreferences.javaScriptCanOpenWindowsAutomatically), this property defaults to false on iOS and true on macOS. With the new iOS 26 WebView and WebPage APIs, I haven't been able to find a way to configure this behavior. Looking through the available configuration options, there doesn't appear to be an equivalent setting. My questions are: Has the default behavior changed for the new SwiftUI WebView? Does it now allow JavaScript to open windows automatically by default on iOS? If not, is there a way to configure this behavior that I'm missing? If this configuration is intentionally not exposed, what is the recommended approach for apps that need to enable automatic window opening? Currently, we're wrapping WKWebView in a UIViewRepresentable to maintain this functionality, but we'd love to migrate to the native SwiftUI WebView later this year if possible. Thank you for any guidance you can provide!
1
0
114
4w
Safe areas ignored after navigating a WebView/WebPage back in a NavigationStack
I'm using the new iOS 26 WebPage/WebView for SwiftUI in a NavigationStack. The initial load works as expected, but when loading items from the back/forward lists, the content jumps beneath the navigation bar: struct WebPageTestView: View { var webPage = WebPage() var body: some View { NavigationStack { WebView(webPage) .toolbar { Button("Back") { if let backItem = webPage.backForwardList.backList.last { webPage.load(backItem) } } Button("Forward") { if let forwardItem = webPage.backForwardList.forwardList.first { webPage.load(forwardItem) } } } } .task { webPage.isInspectable = true webPage.load(URL(string: "https://domchristie.co.uk/")) } } } I have run this on the iOS 26.0 and 26.1 Simulators and get the same issue. The demo website does not use any JavaScript. I was able to replicate this behaviour using a wrapped WKWebView and calling the .ignoresSafeArea(.all) modifier.
3
1
477
Oct ’25
Web view delayed layout during window resize
The app I work on uses WKWebView to render customer data. In iPadOS 26, we observe that there is a delay when resizing the window (and thus the web view) before the content is re-rendered. The same behavior is visible in Safari. For demonstration purposes, consider this test page: https://phet-dev.colorado.edu/html/build-an-atom/0.0.0-3/simple-text-only-test-page.html Initially, the window is small: Then when the window is expanded, the content scales up temporarily: It eventually re-renders to the correct size, but then if you make the window small again, you get (temporarily): Is there anyway around this behavior? We would love to have the content reflow interactively.
1
1
305
Sep ’25
Is this path within launchd legitimate?
Command: com.apple.WebKit.Networking Path: /private/preboot/Cryptexes/OS/System/Library/ExtensionKit/Extensions/NetworkingExtension.appex/com.apple.WebKit.Networking Identifier: com.apple.WebKit.Networking Version: ??? (8621.3.11.10.3) Resource Coalition: "com.apple.mobilesafari"(1005) Architecture: arm64e Parent: launchd [1] PID: 1708
1
0
104
Sep ’25
Deprecation of WKWebView printOperationWithPrintInfo:
I have some working Objective-C code that displays a WKWebView and allows printing that content. However, it uses the method -[WKWebView printOperationWithPrintInfo:], which the documentation says is deprecated as of macOS 10.15. However, it doesn't say why this method is deprecated, or what the recommended replacement is. The declaration in WKWebView.h does not even indicate that the method is deprecated. But as an alternative, I tried using +[NSPrintOperation printOperationWithView:printInfo]. Doing it that way just prints a blank page. So, should I keep doing it the doubtful way?
1
0
61
Sep ’25
Webview In-App Browser Microsoft Login Redirection Not Working
Hello, We received a rejection on one of our IOS applications because we were doing Microsoft MSAL login through the user's browser. The representative recommended that we use Webview to do in-app logins. However when we tried to handle the custom app uri redirection (looking like myapp://auth/), Webview does not seem to send the user back to the application. Does anyone have a fix for this? Thanks!
0
0
255
Sep ’25
Why does my website header look different in Safari on macOS compared to Windows browsers?
Hi Developers, I am working on a small project and I noticed that my website header looks different in Safari on macOS compared to Windows browsers like Chrome and Edge. In Safari, the header text and spacing look slightly shifted (screenshot attached). On Windows browsers, everything looks perfectly aligned. Here is my live project for reference: https://gratuitycalculatorae.com/ Screenshot from Safari (macOS): Is this related to Safari-specific CSS rendering? Should I use -webkit- specific fixes or is there a better cross-browser solution? Any guidance or best practices would be really helpful. Thanks
Topic: Safari & Web SubTopic: General Tags:
1
0
99
Sep ’25
iOS version 26.0, get pixel alpha value invalid if subviews contains WKWebView
using renderInContext fetch pixel faild if subviews contains WKWebView, the code is as follows: self.contentView = [SimpleClearContentView alloc] initWithFrame:CGRectMake(0, 100, 100, 100)]; contentView.backgroundColor = [UIColor clearColor]; self.contentView.webView = [[WKWebView alloc] init]; self.contentView.webView.frame = CGRectMake(0, 0, 50, 100); // make web view clear bg color self.contentView.webView.backgroundColor = [UIColor clearColor]; self.contentView.webView.scrollView.backgroundColor = [UIColor clearColor]; // webView load clear background webpage [self.contentView.webView loadRequest:xxx]; [self.view addSubView:contentView]; // this method still return 0.0f anywhere -(CGFloat)getPixelAlphaAtPoint:(CGPoint)point { unsigned char pixel[4] = {0}; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); CGContextRef context = CGBitmapContextCreate(pixel, 1, 1, 8, 4, colorSpace, kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedLast); CGContextTranslateCTM(context, -point.x, -point.y); WKWebView *webView = self.contentView.webView; [webView.layer renderInContext:context]; CGContextRelease(context); CGColorSpaceRelease(colorSpace); CGFloat alpha = pixel[3]/255.0; return alpha; }
1
0
86
Sep ’25
iOS 26 Safari will not render position: fixed content below the browser controls
Bug Report: Safari refuses to render content that is position: fixed or position: sticky if it goes below the iOS 26 navigation controls at the bottom of the browser. Since the controls are transparent and floating, this is a problem as fixed content is effectively unable to reach the bottom of the page. Attempting to move it below 100vh causes it to be cut off rather than rendering behind the navigation elements. Here is some code reproducing the issue: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> html, body { margin: 0; padding: 0; background-color: #363636; } #just-a-bird { position: fixed; bottom: -100px; width: 300px; height: auto; background: red; } </style> </head> <body> <img id="just-a-bird" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e1/Cattle_tyrant_%28Machetornis_rixosa%29_on_Capybara.jpg/640px-Cattle_tyrant_%28Machetornis_rixosa%29_on_Capybara.jpg"> </body> </html>
2
6
672
Sep ’25
Can we Wrap a web application in a React Native Web view and Make it live on iOS
Can we Wrap a website in a React Native Web view and Make it live on iOS? Here is an example code (Just a web application wrapped inside React Native ) import React, { useEffect, useRef, useState } from "react"; import { BackHandler, StyleSheet } from "react-native"; import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context"; import { WebView } from "react-native-webview"; export default function App() { const webviewRef = useRef<WebView>(null); const [canGoBack, setCanGoBack] = useState(false); // Handle Android back button useEffect(() => { const backHandler = BackHandler.addEventListener("hardwareBackPress", () => { if (canGoBack && webviewRef.current) { webviewRef.current.goBack(); return true; // prevent app exit } return false; // allow app exit }); return () => backHandler.remove(); }, [canGoBack]); return ( <SafeAreaProvider> <SafeAreaView style={styles.container} edges={["top", "bottom", "left", "right"]}> <WebView ref={webviewRef} source={{ uri: "https://www.kallardo.com/" }} style={styles.webview} startInLoadingState={true} javaScriptEnabled={true} domStorageEnabled={true} onNavigationStateChange={(navState) => setCanGoBack(navState.canGoBack)} /> </SafeAreaView> </SafeAreaProvider> ); } const styles = StyleSheet.create({ container: { flex: 1, }, webview: { flex: 1, }, }); I want to know will we get approval easier or makes it complicated or not allowed
1
0
60
Sep ’25
SwiftUI's `WebPage` back navigation not working as expected
I'm currently testing SwiftUI's WebKit by building a browsing application. For the back navigation, I have the following code implemented: if let item = webPage.backForwardList.backList.last { webPage.load(item) print( """ ===== backForwardList.backList: \(webPage.backForwardList.backList) --- backForwardList.currentItem: \(webPage.backForwardList.currentItem) --- backForwardList.forwardList: \(webPage.backForwardList.forwardList) ===== """.trimmingCharacters(in: .whitespacesAndNewlines) ) } When I look at the logs, it shows that whenever I navigate back, the currentItem is updated with the item, but the backList is appended with the previous currentItem, and the forwardList is always empty. Am I implementing this incorrectly? Thanks in advance!
0
0
87
Sep ’25
Can't turn off inline auto predictions in WKWebView on Mac
I have a WKWebView that contains a js text editor, built on top of a content editable div. Currently, inline predictions on Mac break the text editors functionality significantly every time there's a prediction. There's not a way for me to fix this on the js side unless I can know when a prediction is shown. I've tried disabling inline predictions and writing tools with the web view config, but it doesn't work: let config = WKWebViewConfiguration() config.writingToolsBehavior = .none config.allowsInlinePredictions = false let webView = WKWebView(frame: .zero, configuration: config) I've also tried disabling all spellcheck and autocorrect features in the html but that doesn't work either: <div contenteditable="true" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off"></div> Is there anything I can do to turn it off? Or, is it possible to know when the WebView is predicting text?
1
0
242
Sep ’25
keyboard crash
My app encountered a crash problem. The analysis stack seems to be related to the keyboard. The system keyboard code is unresponsive for a long time until it crash. The feature of the stack, BrowserEngineKit, seems to indicate the webview scene. Xcode debugging found that tap the input box on the webview page can reproduce the same stack as the crash, but the crash cannot be reproduced. I noticed a feedback link https://developer.apple.com/forums/thread/784718, which is the same as the top of the crash stack I encountered, so the root cause of the problem may be similar, caused by the locking operation related to UIKeyboardTaskQueue. Hope to give some suggestions. Thanks. crash log: Incident Identifier: 39E3AFE6-43B1-4DE6-AC2B-D62C5EC89752 CrashReporter Key: AppleMetricKit Hardware Model: iPhone17,2 Process: iAliexpress Code Type: ARM-64 Parent Process: ? [1] Date/Time: 2025-07-02 22:59:00 Launch Time: Unknown OS Version: iPhone OS 18.1.1 (22B91) Report Version: 104 Exception Type: EXC_CRASH Exception Codes: KERN_SUCCESS Triggered by Thread: 0 Application Specific Information: &lt;RBSTerminateContext| domain:10 code:0x8BADF00D explanation:scene-update watchdog transgression: app&lt;com.alibaba.iAliexpress(A182346C-2A09-4082-9AAE-0EC7A1A1B5AB)&gt;:2263 exhausted real (wall clock) time allowance of 10.00 seconds ProcessVisibility: Unknown ProcessState: Running WatchdogEvent: scene-update WatchdogVisibility: Background WatchdogCPUStatistics: ( "Elapsed total CPU time (seconds): 15.280 (user 9.430, system 5.850), 25% CPU", "Elapsed application CPU time (seconds): 0.210, 0% CPU" ) reportType:CrashLog maxTerminationResistance:Interactive&gt; Thread 0 Crashed: 0 libsystem_kernel.dylib 0x00000001ea7f7f90 __psynch_cvwait :8 (in libsystem_kernel.dylib) 1 libsystem_pthread.dylib 0x000000022296aa7c _pthread_cond_wait :1248 (in libsystem_pthread.dylib) 2 Foundation 0x000000019908fa9c -[NSCondition waitUntilDate:] :132 (in Foundation) 3 Foundation 0x000000019908bea8 -[NSConditionLock lockWhenCondition:beforeDate:] :80 (in Foundation) 4 UIKitCore 0x000000019d05cbb4 -[UIKeyboardTaskQueue lockWhenReadyForMainThread] :784 (in UIKitCore) 5 UIKitCore 0x000000019d05c85c -[UIKeyboardTaskQueue waitUntilAllTasksAreFinished] :160 (in UIKitCore) 6 UIKitCore 0x000000019d56720c -[_UIKeyboardStateManager prepareForSelectionChange] :128 (in UIKitCore) 7 UIKitCore 0x000000019d5674f4 -[_UIKeyboardStateManager selectionWillChange:] :72 (in UIKitCore) 8 BrowserEngineKit 0x0000000257671688 -[BETextInteraction selectionWillChange:] :84 (in BrowserEngineKit) 9 UIKitCore 0x000000019d75d654 -[UIAsyncTextInteraction selectionWillChange:] :68 (in UIKitCore) 10 UIKitCore 0x000000019dbae374 -[_UIKeyboardTextSelectionController beginSelectionChange] :64 (in UIKitCore) 11 UIKitCore 0x000000019df5fed0 -[UITextSelectionInteraction tappedToPositionCursorWithGesture:atPoint:granularity:completionHandler:] :476 (in UIKitCore) 12 UIKitCore 0x000000019df5f948 -[UITextSelectionInteraction _checkForRepeatedTap:gestureLocationOut:] :1072 (in UIKitCore) 13 UIKitCore 0x000000019df60488 -[UITextSelectionInteraction _handleMultiTapGesture:] :852 (in UIKitCore) 14 UIKitCore 0x000000019cf879cc -[UIApplication sendAction:to:from:forEvent:] :100 (in UIKitCore) 15 UIKitCore 0x000000019d84ce98 -[UITextMultiTapRecognizer onStateUpdate:] :280 (in UIKitCore) 16 UIKitCore 0x000000019cfb6ac4 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] :128 (in UIKitCore) 17 UIKitCore 0x000000019cfb6934 _UIGestureRecognizerSendTargetActions :92 (in UIKitCore) 18 UIKitCore 0x000000019cfb66f4 _UIGestureRecognizerSendActions :284 (in UIKitCore) 19 UIKitCore 0x000000019cc69b28 -[UIGestureRecognizer _updateGestureForActiveEvents] :572 (in UIKitCore) 20 UIKitCore 0x000000019cc3b724 _UIGestureEnvironmentUpdate :2488 (in UIKitCore) 21 UIKitCore 0x000000019cd2fa00 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] :336 (in UIKitCore) 22 UIKitCore 0x000000019cecffe4 -[UIGestureEnvironment _updateForEvent:window:] :188 (in UIKitCore) 23 UIKitCore 0x000000019cecf3c8 -[UIWindow sendEvent:] :2948 (in UIKitCore) 24 iAliexpress 0x0000000104e92000 -[UIWindow(AliHA) aliHASwizzledSendEvent:] UIWindow+AliHA.m:18 (in iAliexpress) 25 UIKitCore 0x000000019cd63b70 -[UIApplication sendEvent:] :376 (in UIKitCore) 26 iAliexpress 0x0000000104e91c84 -[UIApplication(SPM) alg_sendEvent:] AFSPMManager.m:0 (in iAliexpress) 27 UIKitCore 0x000000019cd6409c __dispatchPreprocessedEventFromEventQueue :1048 (in UIKitCore) 28 UIKitCore 0x000000019cd6df3c __processEventQueue :5696 (in UIKitCore) 29 UIKitCore 0x000000019cc66c60 updateCycleEntry :160 (in UIKitCore) 30 UIKitCore 0x000000019cc649d8 _UIUpdateSequenceRun :84 (in UIKitCore) 31 UIKitCore 0x000000019cc64628 schedulerStepScheduledMainSection :172 (in UIKitCore) 32 UIKitCore 0x000000019cc6559c runloopSourceCallback :92 (in UIKitCore) 33 CoreFoundation 0x000000019a434328 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ :28 (in CoreFoundation) 34 CoreFoundation 0x000000019a4342bc __CFRunLoopDoSource0 :176 (in CoreFoundation) 35 CoreFoundation 0x000000019a431dc0 __CFRunLoopDoSources0 :244 (in CoreFoundation) 36 CoreFoundation 0x000000019a430fbc __CFRunLoopRun :840 (in CoreFoundation) 37 CoreFoundation 0x000000019a430830 CFRunLoopRunSpecific :588 (in CoreFoundation) 38 GraphicsServices 0x00000001e64101c4 GSEventRunModal :164 (in GraphicsServices) 39 UIKitCore 0x000000019cf96eb0 -[UIApplication _run] :816 (in UIKitCore) 40 UIKitCore 0x000000019d0455b4 UIApplicationMain :340 (in UIKitCore) 41 iAliexpress 0x0000000104e9b0b8 _main main.m:17 (in iAliexpress) 42 dyld 0x00000001bfe1eec8 start :2724 (in dyld)
2
1
195
Sep ’25
WebView makes website content unaccessible on the top/bottom edges
I'm being faced with an issue when using SwiftUI's WebView on iOS 26. In many websites, the top/bottom content is unaccessible due to being under the app's toolbars. It feels like the WebView doesn't really understand the safe areas where it's being shown, because the content should start right below the navigation bar, and only when the user scrolls down, the content should move under the bar (but it's always reachable if the users scroll back up). Here's a demo of the issue: Here's a 'fix' by ensuring that the content of the WebView never leaves its bounds. But as you can see, it feels out of place on iOS 26 (would be fine on previous OS versions if you had a fully opaque toolbar): Code: struct ContentView: View { var body: some View { NavigationStack { WebView(url: URL(string: "https://apple.com")).toolbar { ToolbarItem(placement: .primaryAction) { Button("Top content covered, unaccessible.") {} } } } } } Does anyone know if there's a way to fix it using some sort of view modifier combination or it's just broken as-is?
11
1
261
Sep ’25
iOS 26 Webview and alert issue
Hello, In iOS 26 beta, we are seeing an unexpected behavior when using SwiftUI WebView (or a custom WKWebView via UIViewRepresentable). When an alert is presented above the WebView, the WebView immediately reloads to its initial page. The alert itself also disappears instantly, making it impossible for the user to interact with it. This issue occurs both with the new SwiftUI WebView / WebPage API and with a wrapped WKWebView. The problem was not present in previous iOS versions (iOS 17/18). Steps to reproduce: Create a SwiftUI view with a WebView (pointing to any URL). Add a toolbar button that toggles a SwiftUI alert. Run the app on iOS 26 beta. Tap the button to trigger the alert. Expected behavior: The WebView should remain as-is, and the alert should stay visible until the user dismisses it. Actual behavior: As soon as the alert appears, the WebView reloads and resets to the initial page. The alert disappears immediately. Minimal Example: struct ContentView: View { @State private var showAlert = false var body: some View { NavigationStack { WebView(URL(string: "https://apple.com")!) .toolbar { ToolbarItem(placement: .topBarTrailing) { Button("Close") { showAlert = true } } } .alert("Confirm close?", isPresented: $showAlert) { Button("Cancel", role: .cancel) {} Button("Close", role: .destructive) {} } } } } I'm using Xcode Version 26.0 beta 7 Thanks for your help.
2
1
714
Sep ’25