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

WebKit Documentation

Posts under WebKit tag

274 Posts
Sort by:
Post not yet marked as solved
0 Replies
213 Views
In Android there's a helpful feature in webview to load local files in assets folder as https to comply with same origin content policy (https://developer.android.com/reference/androidx/webkit/WebViewAssetLoader) Is there anything equivalent in WKWebView? I've been looking it up for a while and couldn't find anything conclusive. Thank you.
Posted
by JBsnaf.
Last updated
.
Post not yet marked as solved
0 Replies
615 Views
Since the release of Xcode 15, my tests aren't functioning on Xcode Cloud. The login screen, which is a web view, isn't loading correctly during the Xcode Cloud UI tests, as depicted in the screenshot below: Any insights on what might be causing this error? We haven't made any changes to this feature, and it operates smoothly locally.
Posted Last updated
.
Post not yet marked as solved
0 Replies
340 Views
I'm migrating a macOS application from the old and deprecated WebView to the new and sparkly WKWebView. It seems to work fine, but four error messages appear in the console (see below) just after the dialog is closed. I searched. It seems this issue can be fixed through the addition of a target entitlement called Background Modes. This particular capability is however not listed by Xcode, so I can't add it. I think this is because we're targeting macOS and not iOS, but I'm not certain. Stuck. Tips and advice appreciated! Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> 0x2c40246c0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'WebProcess NearSuspended Assertion' for process with PID=66538, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit} Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit}> 0x2c4024720 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'GPUProcess Background Assertion' for process with PID=66540, error: Error Domain=RBSServiceErrorDomain Code=1 "target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit" UserInfo={NSLocalizedFailureReason=target is not running or doesn't have entitlement com.apple.runningboard.assertions.webkit} Deployment target is 10.15, Xcode version is 15.3.
Posted
by pelle_se.
Last updated
.
Post not yet marked as solved
0 Replies
375 Views
Hi, We have recently observed that support for PWAs has been ended in the EU region in iOS 17.4. The changes were visible while the OS was in beta as well. We have a web app with our user base in the US. Is there any plan for these restrictions to be implemented in any other region?
Posted Last updated
.
Post not yet marked as solved
0 Replies
334 Views
I'm currently using a WKWebView to load certain types of documents via loadRequest, but I've recently been running into an issue with .doc files doing this: static NSString *customScheme = @"customscheme"; @interface WordDocWKSchemeHandler : NSObject <WKURLSchemeHandler> @end @implementation WordDocWKSchemeHandler { NSData *_data; NSString *_mimeType; } - (instancetype)initWithData:(NSData*)data mimeType:(NSString*)mimeType{ self = [super init]; if (self) { _data = data; _mimeType = mimeType; } return self; } - (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask { NSURL *url = urlSchemeTask.request.URL; if (![url.scheme isEqualToString:customScheme]){ return; } NSURLResponse *response = [[NSURLResponse alloc] initWithURL:url MIMEType:_mimeType expectedContentLength:_data.length textEncodingName:@""]; [urlSchemeTask didReceiveResponse:response]; [urlSchemeTask didReceiveData:_data]; [urlSchemeTask didFinish]; } - (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask{ //empty } @end - (void)_setupWebViewPropertiesAndConstraints{ _webView.navigationDelegate = self; _webView.hidden = YES; [self.view addConstrainedSubview:_webView]; [self.view addConstraints:[_webView constraintsForFillingSuperview]]; self.container.showsLoadingIndicator = YES; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; WKWebViewConfiguration *docConfig = [WKWebViewConfiguration new]; WordDocWKSchemeHandler *schemeHanlder = [[WordDocWKSchemeHandler alloc] initWithData:_content.data mimeType:_content.contentType]; [docConfig setURLSchemeHandler:schemeHanlder forURLScheme:customScheme]; //Setup webview with custom config handler _webView = [[WKWebView alloc] initWithFrame:self.view.frame configuration:docConfig]; [self _setupWebViewPropertiesAndConstraints]; NSURL *customURL = [NSURL URLWithString:[NSString stringWithFormat:@"\%@:/",customScheme]]; [_webView loadRequest:[NSURLRequest requestWithURL:customURL]]; } The mimeType is correctly being resolved to "application/msword" but any time we try to load this the navigation fails: -(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { The error message here is OfficeImportErrorDomain Code=912. I've tried this on both a simulator and actual device on iOS 17 and 16 and this always fails. I've also tried turning the data into a base64 string and loading it that way and this also fails. Any advice here would be appreciated. It seems like this used to work at some point but no longer works.
Posted Last updated
.
Post not yet marked as solved
1 Replies
509 Views
Hi Apple Team, we are observing following error intermittently when trying to playback FairPlay protected HLS streams. The error happens immediately after loading the certificate. Playback with same certificate on same device(Mac, iPhone) works most of time but intermittently this error is observed with following codes. The code=6 means MEDIA_KEYERR_DOMAIN but I did not find any information on what does systemCode=4294955417 mean? Is there a way to check what does this system code mean and what could be causing this intermittent behaviour? { "code": 6, "systemCode": 4294955417 }
Posted Last updated
.
Post not yet marked as solved
0 Replies
499 Views
Xcode 15.3 build with device(iPhone 12 / iOS 17.4) var webView: WKWebView = { let view = WKWebView(frame: .zero, configuration: WKWebViewConfiguration()) return view }() Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1a049fa48) Hello. Also in Firebase too. At first I thought it was a Firebase issue. https://github.com/firebase/firebase-ios-sdk/issues/12485 But there seems to be a problem with iOS 17.4. There is no problem when running the app after disconnecting. Thanks for attention.
Posted
by yyyng.
Last updated
.
Post not yet marked as solved
3 Replies
995 Views
We have an angular/ionic based app that has an audio playback feature. It appears that iphone (but not ipad) users who upgrade to iOS 17.4 can no longer play audio in our app. iPad users who upgraded to 17.4 don't have an issue. We use the HTMLAudioElement for audio playback. It appears that in 17.4 it is no longer firing the 'canplay' event that we listening for, for starting our playback. The other data buffering events like 'loadeddata' are also not being delivered. By changing the logic to listen for the 'loadstart' event, audio playback works and then the remaining 'canplaythrough' and 'canplay' are delivered. In other words, I need to start playback before any data buffering status events are delivered, otherwise they never get delivered. I am testing this against an audio delivery server on my same machine and have confirmed that the data is correctly delivered. Is anyone else experiencing a similar issue on iphones in iOS 17.4?
Posted
by drjvp.
Last updated
.
Post marked as solved
3 Replies
5.2k Views
Good morning! I am developing an iOS app that gets its data from an API and displays it in a list. The list item view has NavigationLink embedded in it that sends users to a detail view. In this detail view, I have some Text views but the issue I am running into is a WKWebView that I have implemented to display some HTML that's is retrieved from the API call. The WKWebView displays the HTML just how I want it to. The issue I have is in the HyperLinks that are displayed in the WKWebView. When a user taps on a link, it opens inside of the web view. Instead of opening in the web view, I would like this link to open in the user's default web browser. I have searched and found ways of doing this in older versions of Swift using classes but my web view is initialized inside of a struct that conforms to the UIViewRepresentable protocol. I don't know how to get links to open in the browser instead of the WebView so any help would be appreciated. Here is the code for my WebView that is being used on the details page. struct NewsItemWebView: UIViewRepresentable { // HTML from API Call     var text: String // Method to create the View     func makeUIView(context: Context) -> WKWebView {         return WKWebView()     } // Method to update the View by changing properties of the WebView     func updateUIView(_ uiView: WKWebView, context: Context) {         uiView.isOpaque = false         uiView.backgroundColor = UIColor.white         uiView.loadHTMLString(text, baseURL: nil)     } } Here is how I am implementing the WebView on DetailView NewsItemWebView(text: item.PageContent) .frame(height: 450) Any help on how I can make links open in a browser would be great. Thanks in advance.
Posted
by ChuckVJr.
Last updated
.
Post not yet marked as solved
2 Replies
426 Views
Hi folks, I have a couple questions relating to the user gesture requirement on iOS, specifically regarding WebKit. From my testing, it looks like only one webauthn invocation without user gesture is allowed even if there's intervening user gestures, e.g. navigating to another page, clicking buttons, etc. I have to close Safari and reopen in order to reset the count. Is this expected behavior? It seems like it was originally supposed to be one per user navigation [1]. I see the user gesture requirement was removed recently [2]. I agree with the decision, but am curious what was the context behind this move as it seems like a reversal of https://webkit.org/blog/11312/meet-face-id-and-touch-id-for-the-web/. [1] https://bugs.webkit.org/show_bug.cgi?id=220897 [2] https://bugs.webkit.org/show_bug.cgi?id=264444
Posted Last updated
.
Post marked as solved
2 Replies
653 Views
I am having a problem when trying to implement a WKWebView in a window in VisionOS and that when trying to do it in full screen and exiting full screen, the size of the webview changes, becoming smaller or larger while the window remains the same size as before. I used webView.configuration.preferences.isElementFullscreenEnabled = true for enabling fullscreen mode. I made a simple code to test this. import SwiftUI @main struct TestApp: App { var body: some Scene { WindowGroup() { ContentView() } } } import SwiftUI import WebKit struct WebView: UIViewRepresentable { let url: URL func makeUIView(context: Context) -&gt; WKWebView { let wkwebView = WKWebView() wkwebView.configuration.preferences.isElementFullscreenEnabled = true let request = URLRequest(url: url) wkwebView.load(request) return wkwebView } func updateUIView(_ uiView: WKWebView, context: Context) { } } struct ContentView: View { var body: some View { WebView(url: URL(string: "https://glitch.com/~fullscreen-test")!) } }
Posted
by Aytordj.
Last updated
.
Post not yet marked as solved
1 Replies
265 Views
Problem statement- WKWebView cookies management. We need to clone the connection used by the WKWebView to the same end point, this connection utilize cookies for routing and missing even one the cookies will end up with a wrong route to be used. It appears that when retrieving the cookies from the WKWebView connection some cookies are missing. From some analysis seems that the missing cookies all have in common a value containing special characters. The question for Apple is if they are going to relax the constraint on cookies value to allow such cookies to be used. Technical Description:- We are using WKWebView. There are some cookies being set during server connection. We are retrieving all cookies using 'getAllCookies' method of WKWebview. Sometime its not giving correct set of cookies in case if there are any special characters in any cookie. For example - Cookie- ss2QKagAdkAV3My1pnKElaFDnQ6lxhgqNbD03IaRbX6WfDz2+P9dT6DdlK8G5WIH3svEATnehZSmWGQ3QFTnew==\n It contains special character "+ = !".
Posted Last updated
.
Post not yet marked as solved
0 Replies
212 Views
In iMessage you can link a twitter post and it gets the image (if any), tweet content and title. Yet as a regular dev, I think, that we cannot get the tweet content like iMessage. From this Github issue of Mastodon, I know that in the header there is everything we need, yet in a simple swift code using LPLinkMetadata we cannot get the description. Here is the code below import SwiftUI import LinkPresentation class LinkViewModel : ObservableObject { let metadataProvider = LPMetadataProvider() @Published var metadata: LPLinkMetadata? @Published var image: UIImage? init(link : String) { guard let url = URL(string: link) else { return } metadataProvider.startFetchingMetadata(for: url) { (metadata, error) in guard error == nil else { assertionFailure("Error") return } DispatchQueue.main.async { self.metadata = metadata } guard let imageProvider = metadata?.imageProvider else { return } imageProvider.loadObject(ofClass: UIImage.self) { (image, error) in guard error == nil else { // handle error return } if let image = image as? UIImage { // do something with image DispatchQueue.main.async { self.image = image } } else { print("no image available") } } } } } struct MetadataView : View { @StateObject var vm : LinkViewModel var body: some View { VStack { if let metadata = vm.metadata { Text(metadata.title ?? "no title") Text(metadata.value(forKey: "_summary") as? String ?? "np description" ) } if let uiImage = vm.image { Image(uiImage: uiImage) .resizable() .frame(width: 100, height: 100) } } } } struct ContentView: View { var links = [ "https://www.google.com", "https://www.hotmail.com", "https://twitter.com/t3dotgg/status/1764398959513276630"] let metadataProvider = LPMetadataProvider() var body: some View { List(links, id:\.self) { item in Section{ VStack { Text(item) MetadataView(vm: LinkViewModel(link: item)) } } } } } The twitter link doesn't return any description, I also tried third party OG libraries with the og:title in Swift with no success, yet it works on iMessage. Any tips ? :-)
Posted
by 911.
Last updated
.
Post not yet marked as solved
2 Replies
212 Views
Getting the document data from a server using JSON encoded to Base64. WKWebView is not rendering .docx file accurately. The docx file has logos in header and watermark at the background which is not displayed correctly to the user. Steps taken to load the docx file in WKWebview: Stored the document data on app documents directory. Displaying the document file in WKWebView on mobile app with help of local document directory file path. Below is the code that renders the docx file: let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] let filePath = String(format: "%@/%@", documentsPath, "file.docx") let fileURL = URL(fileURLWithPath: filePath) docWebView.loadFileURL(fileURL, allowingReadAccessTo: fileURL) Has anyone encountered this issue? Please provide some assistance to resolve this issue.
Posted Last updated
.
Post not yet marked as solved
4 Replies
1.4k Views
The iOS 17.4 beta4 version was released this Tue(Feb.20). we received lots of web view crashes in this version. we have checkout our udpates we didn't do related code changes recently. Do you meet similar issues in your app? anyone can give some advices? Thanks By crash report in Xcode, the crash frame is WebKit: ***::Detail::CallableWrapper<WebKit::ProcessLauncher::launchProcess()::$_0::operator()(***::ThreadSafeWeakPtr<WebKit::ProcessLauncher>, _SEExtensionProcess*, ***::ASCIILiteral, NSError*) const::'la... + 2480 screenshot for the call stack is
Posted Last updated
.
Post not yet marked as solved
2 Replies
417 Views
I am working on a native visionOS app. I'm running into a problem when websites request fullscreen. Sample code: import SwiftUI import WebKit struct WebViewWrapper: UIViewRepresentable { let url: String func makeUIView(context: Context) -> WKWebView { let webConfiguration = WKWebViewConfiguration() webConfiguration.allowsInlineMediaPlayback = false webConfiguration.mediaPlaybackRequiresUserAction = false let webView = WKWebView(frame: .zero, configuration: webConfiguration) webView.navigationDelegate = context.coordinator webView.uiDelegate = context.coordinator return webView } func updateUIView(_ uiView: WKWebView, context: Context) { if let url = URL(string: url) { let request = URLRequest(url: url) uiView.load(request) } } func makeCoordinator() -> Coordinator { Coordinator(self) } class Coordinator: NSObject, WKNavigationDelegate, WKUIDelegate { var parent: WebViewWrapper init(_ parent: WebViewWrapper) { self.parent = parent } func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { if navigationAction.targetFrame == nil { webView.load(navigationAction.request) } return nil } } } struct ContentView: View { var body: some View { GeometryReader { geo in VStack { WebViewWrapper(url: "https://youtube.com") .clipShape(RoundedRectangle(cornerSize: CGSize(width: geo.size.width/40, height: geo.size.height/40))) .padding() } } } } #Preview(windowStyle: .automatic) { ContentView() } The error I'm getting: -[AVPlayerViewController enterFullScreenAnimated:completionHandler:] failed with error Invalid call of -[AVPlayerViewController (0x153087600) _transitionToFullScreenAnimated:interactive:completionHandler:]! Any help would be greatly appreciated.
Posted Last updated
.
Post not yet marked as solved
0 Replies
341 Views
Hi, We're currently developing a PWA for our company - with Vue 3 and Quasar - and we have added it into the App Store (but in testing only, for now). We have multiple problems but the worst is the following one: it seems that the app doesn't want to open external links with "window.open()" JS method. Instead it shows a screen with a progress bar and a crossed-out Wi-Fi icon. It shows this for a few seconds then once the progress bar is completly filled it goes back to the previous page where it triggered. Needless to say that the wireless is connected (see the status icons at the top). We have the same behavior when we try to download a PDF created as a BLOB file with some JS code. I don't have an iPhone to test so maybe you have a good idea about this ? Kind regards, V.
Posted
by vincent_l.
Last updated
.
Post not yet marked as solved
1 Replies
470 Views
I am developing a macOS application and have encountered an issue with entitlements that I am unable to resolve. The error emerges from the RunningBoard service when I try to play a video in a WKWebView. Here is the specific error: Error acquiring assertion: &lt;Error Domain=RBSServiceErrorDomain Code=1 "(originator doesn't have entitlement com.apple.runningboard.assertions.webkit AND originator doesn't have entitlement com.apple.multitasking.systemappassertions)" UserInfo={NSLocalizedFailureReason=(originator doesn't have entitlement com.apple.runningboard.assertions.webkit AND originator doesn't have entitlement com.apple.multitasking.systemappassertions)}&gt; I'm seeking answers to the following questions: What do the entitlements com.apple.runningboard.assertions.webkit and com.apple.multitasking.systemappassertions refer to specifically? How can I resolve the errors associated with the absence of these entitlements? This problem appears to affect many users, yet a public solution has not been identified. I've tried adding NSMicrophoneUsageDescription and NSCameraUsageDescription to my Info.plist, as suggested here, but to no avail. An apparent Apple employee suggested adding Background Modes to capabilities here, but such options do not exist. Numerous similar issues are documented online, but none provide a resolution. When I attempt to include the entitlements com.apple.runningboard.assertions.webkit and com.apple.multitasking.systemappassertions as indicated in the logs, my application fails to start, resulting in the following error message: Could not launch “My App Name” Runningboard has returned error 5. Please check the system logs for the underlying cause of the error. The error logs are extensive and include: Could not launch “Quick Music Bar” Domain: IDELaunchErrorDomain Code: 20 Recovery Suggestion: Runningboard has returned error 5. Please check the system logs for the underlying cause of the error. User Info: { DVTErrorCreationDateKey = "2024-02-24 06:26:22 +0000"; DVTRadarComponentKey = 968756; IDERunOperationFailingWorker = IDELaunchServicesLauncher; } -- The operation couldn’t be completed. Launch failed. Domain: RBSRequestErrorDomain Code: 5 Failure Reason: Launch failed. -- Launchd job spawn failed Domain: NSPOSIXErrorDomain Code: 153 -- Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : { "device_model" = "Mac14,10"; "device_osBuild" = "14.3.1 (23D60)"; "device_platform" = "com.apple.platform.macosx"; "dvt_coredevice_version" = "355.7.7"; "dvt_mobiledevice_version" = "1643.60.2"; "launchSession_schemeCommand" = Run; "launchSession_state" = 1; "launchSession_targetArch" = arm64; "operation_duration_ms" = 113; "operation_errorCode" = 20; "operation_errorDomain" = IDELaunchErrorDomain; "operation_errorWorker" = IDELaunchServicesLauncher; "operation_name" = IDERunOperationWorkerGroup; "param_debugger_attachToExtensions" = 0; "param_debugger_attachToXPC" = 1; "param_debugger_type" = 3; "param_destination_isProxy" = 0; "param_destination_platform" = "com.apple.platform.macosx"; "param_diag_MainThreadChecker_stopOnIssue" = 0; "param_diag_MallocStackLogging_enableDuringAttach" = 0; "param_diag_MallocStackLogging_enableForXPC" = 1; "param_diag_allowLocationSimulation" = 1; "param_diag_checker_tpc_enable" = 1; "param_diag_gpu_frameCapture_enable" = 0; "param_diag_gpu_shaderValidation_enable" = 0; "param_diag_gpu_validation_enable" = 0; "param_diag_memoryGraphOnResourceException" = 0; "param_diag_queueDebugging_enable" = 1; "param_diag_runtimeProfile_generate" = 0; "param_diag_sanitizer_asan_enable" = 0; "param_diag_sanitizer_tsan_enable" = 0; "param_diag_sanitizer_tsan_stopOnIssue" = 0; "param_diag_sanitizer_ubsan_stopOnIssue" = 0; "param_diag_showNonLocalizedStrings" = 0; "param_diag_viewDebugging_enabled" = 1; "param_diag_viewDebugging_insertDylibOnLaunch" = 1; "param_install_style" = 0; "param_launcher_UID" = 2; "param_launcher_allowDeviceSensorReplayData" = 0; "param_launcher_kind" = 0; "param_launcher_style" = 99; "param_launcher_substyle" = 8192; "param_runnable_appExtensionHostRunMode" = 0; "param_runnable_productType" = "com.apple.product-type.application"; "param_structuredConsoleMode" = 1; "param_testing_launchedForTesting" = 0; "param_testing_suppressSimulatorApp" = 0; "param_testing_usingCLI" = 0; "sdk_canonicalName" = "macosx14.2"; "sdk_osVersion" = "14.2"; "sdk_variant" = macos; } -- System Information macOS Version 14.3.1 (Build 23D60) Xcode 15.2 (22503) (Build 15C500b) Timestamp: 2024-02-24T15:26:22+09:00 The system information is as follows: macOS Version 14.3.1 (Build 23D60), Xcode 15.2 (22503) (Build 15C500b), Timestamp: 2024-02-24T15:26:22+09:00 Has anyone else encountered this issue, or can anyone provide guidance on how to proceed?
Posted
by yachty66.
Last updated
.
Post not yet marked as solved
0 Replies
334 Views
I’m creating a hybrid app using Swift and Angular. Angular content is loading on top of the Native Swift WkWebView. Starting from iPad 10th generation only in the app initial launch header area become invisible(invisible means header text becomes white). But once I send the app to background and return to foreground header text becomes black and it will show without problem. I would really like to know whether this is a OS problem and if so is there any pro-grammatical solution for this? if anyone can guide me to proper way fix this much a appreciated!!! Environment: ・Device: iPad 10th generation ・OS:iPad OS 17.3.1 ・Native App : Swift 5
Posted Last updated
.