Explore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.

General Documentation

Post

Replies

Boosts

Views

Activity

Mac Catalyst WKWebView keyDown never trigger (no more keyboard events)
Everything was working fine for 4 years. But since Ventura, when the WKWebView is in focus, the keyDown event are not happening. Not only they don't fire inside of web page input box, but they won't register in the app either. As long as a WKWebView is in focus, the keyboard events won't work. The app does not receive the key events, and the web page will not receive the js events keyDown and friends. This is particularly painful with auto complete input box. Test with an empty project with only a WKWebView with this page https://www.toptal.com/developers/keycode/for/d It does work fine on iPhone and iPad. Message to Apple : You force us to use your Safari engine, yet it is always broken. Don't wait for 8 months to fix it this time, we would be tempted to go full web and skip native app with all the store certification problems.
9
6
2.4k
Dec ’22
Enable WKWebView Web Inspector Under Mac Catalyst?
I'm trying to enable the web inspector on WKWebView in a Mac Catalyst app. I'm only doing this for debugging purposes. In the released the web inspector will not be enabled. Doing this under Mac Catalyst does not work:  WKPreferences *prefs = [[WKPreferences alloc]init];   [prefs _setDeveloperExtrasEnabled:YES]; //Assign the WKPreferences to a WKWebViewConfiguration and create the web view.. Is there any way to do this? Thanks in advance.
4
0
1.3k
Feb ’23
WKWebView on Mac Catalyst elementFullscreenEnabled set to YES on WKPreferences but it does not work
Setting elementFullscreenEnabled property to YES on WKPreferences is not honored on Mac Catalyst.  WKWebViewConfiguration *webViewConfig = [[WKWebViewConfiguration alloc]init];  WKPreferences *prefs = [[WKPreferences alloc]init]; prefs.elementFullscreenEnabled = YES;   webViewConfig.preferences = prefs; //then create the WKWebView.. I load a Youtube url in the WKWebView. Youtube complains that the browser doesn't support full screen. Is there a workaround? Full screen does work in an AppKit app though using the exact same API...though it causes an Autolayout crash (I will be making another thread about that separate issue shortly).
4
0
1k
Feb ’23
declarativeNetRequest does not always work
I'm not sure what is special about Gmail of if this is an issue on other sites as well, but my declarativeNetRequest rules are totally ignored in a Safari Extension that runs on Gmail. I make an web extension that blocks email trackers (1x1 pixel images embedded in emails to track if and when you open email sent to you). All images in Gmail are loaded through Google's proxy: googleusercontent.com/proxy/#originalURL But no matter what I do, I can't block a single image that is loaded in an email. To try and prove it is a bug in Safari, I created a new template web extension in Xcode. I block all resourceTypes (images and other should be all that is needed) and added two rules: Block all images loaded through Google's proxy server (this should block all embedded images in all emails) Block any image with copper in the URL (just in case the blocking doesn't apply to the proxy root url for some reason). {   "id": 1,   "priority": 1,   "action": { "type": "block" },   "isUrlFilterCaseSensitive": false,   "condition": {    "regexFilter": "googleusercontent.com/proxy",    "resourceTypes": [     "image",     "media",     "main_frame",     "sub_frame",     "stylesheet",     "script",     "font",     "xmlhttprequest",     "ping",     "websocket",     "other"    ]   }  },  {   "id": 2,   "priority": 1,   "action": { "type": "block" },   "isUrlFilterCaseSensitive": false,   "condition": {    "regexFilter": "copper",    "resourceTypes": [     "image",     "media",     "main_frame",     "sub_frame",     "stylesheet",     "script",     "font",     "xmlhttprequest",     "ping",     "websocket",     "other"    ]   }  } ] = = = = = = Even though I know this isn't needed, I also added the requester domain (mail.google.com) and the proxy domain (googleusercontent.com) to the permissions list in the manifest file: ... "declarative_net_request": {    "rule_resources": [{      "id": "ruleset_1",      "enabled": true,      "path": "rules.json"     }]   },  "permissions": [    "declarativeNetRequest",    "*://mail.google.com/*",   "*://*.googleusercontent.com/proxy/*" ] = = = = = = If I open an email from copper, the image still loads in Gmail: = = = = = = If I right click and select "Open Image in New Tab", the image will not load and I am told it was blocked = = = = = = If I open a test page that has two images in it, one the image from the email, the image is blocked and the other image is not (as expected, the second image is from wikipedia and should not be blocked) = = = = = = Running the same extension in Chrome DOES block the image in Gmail (and in all the other cases too) = = = = = = Sidenotes: This is a reposting of this post which was locked when the wwdc21-10131 tag was applied to the post which disabled my ability to reply, comment, or update the post. Please do NOT apply tags that lock the post. As requested on the original post by @bweinstein, I filed a bug report on Feedback assistant under FB 10544296 last year and haven't gotten any replies on it. I verified before reposting this (on Mar 1, 2023) that the bug still exists.
1
0
974
Mar ’23
WKWebView inline media playback issue
I have enabled inline media playback with code as below: let config = WKWebViewConfiguration() config.mediaTypesRequiringUserActionForPlayback = [] config.allowsInlineMediaPlayback = true let webView = WKWebView(frame: .zero, configuration: config) But when user touch play button on the video, it's automatically stopped the video and print out some errors as below: 2023-03-30 08:28:46.961218+0700 [22319:217776] [assertion] Error acquiring assertion: <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)}> 2023-03-30 08:28:46.961404+0700 [22319:217776] [ProcessSuspension] 0x14dfe8820 - ProcessAssertion: Failed to acquire RBS assertion 'WebKit Media Playback' for process with PID=22415, error: 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)} 2023-03-30 08:28:46.966357+0700 [22319:217776] [assertion] Error acquiring assertion: <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)}> 2023-03-30 08:28:46.966553+0700 [22319:217776] [ProcessSuspension] 0x14dfe8870 - ProcessAssertion: Failed to acquire RBS assertion 'WebKit Media Playback' for process with PID=22319, error: 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)} 2023-03-30 08:28:46.968951+0700 [22319:217776] [assertion] Error acquiring assertion: <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)}> 2023-03-30 08:28:46.969615+0700 [22319:217776] [ProcessSuspension] 0x14dfe88c0 - ProcessAssertion: Failed to acquire RBS assertion 'WebKit Media Playback' for process with PID=22422, error: 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)} What's the solution for this issue? Please help!
4
0
1.9k
Mar ’23
PWA not working with Screen Time/Limit Adult websites even with specific website in allow list
We have developed a PWA that we encourage our users to dock to their home screen. One of our users has implemented some combination of Screen Time//Content & Privacy Restrictions/Content Restrictions/Web Content then enabling "Limit Adult websites". This breaks the PWA on both the home screen instance and within Safari. All we see is a white screen. We have tried adding the domain to the "Always Allow" section of the Screen Time Web Content screen, but we still just get a white page. Has anyone else here had this issue? Anything we can do to work around this? We reported this bug through feedback (FB12126097 ), but I was hoping someone else could help. Here is the text of our feedback (from another developer on my team): Web apps that use service workers appear blank when "limit adult websites" is selected This just started happening in iOS 16.4.1. The web content restriction, "restrict adult websites", causes applications that use service workers to break. My guess is that the cache storage API is no longer retrieving stored js/html assets. I have seen this on three different applications that use different javascript libraries. 1) Install the fastmail application from the apple app store. 2) No fastmail account is needed. You can see this on the login page. 3) Go to iOS settings -> content & privacy restrictions 4) Enable Content & Privacy Restrictions 5) Go to Content Restrictions -> Web Content and select "Limit Adult Websites" 6) Open the fastmail application. You will see a blank page/screen. 7) Go to iOS settings -> content & privacy restrictions and disable "Enable Content & Privacy Restrictions" 8) Close and re-open fastmail. You will see a login screen.
5
6
1.8k
Apr ’23
Safari Extension browser.tabs.query returns invalid results
When you have a blank Safari new tab open, the browser.tabs.query API inaccurately includes those tabs in results that include a url or title in the query options. To reproduce, open several tabs, and a blank new tab. Open the background page devtools, and execute the following command: browser.tabs.query({url: 'https://github.com/'}, console.log) In addition to any potentially valid results (if you have github.com open, for example), there will also be an entry for the blank tab, which has an empty, non-matching URL. Tab { active: true, audible: false, height: 1095, highlighted: true, id: 6, incognito: false, index: 3, isArticle: false, isInReaderMode: false, mutedInfo: {muted: false}, pendingUrl: "", pinned: false, status: "complete", title: "", url: "", width: 1792, windowId: 1 } I hope that this bug can be addressed, as it causes some unexpected behavior.
1
0
784
May ’23
getMatchedRules does not seem to work
Hi. For my Safari Web Extension, using getMatchedRules() from declarativeNetRequest does not seem to work. I've declared the permission for declarativeNetRequestFeedback in my manifest.json file and tried the activeTab permission too. getMatchedRules() was added in a previous Safari release and was adjusted in Safari 16.4. I'm using Safari 16.5. It only returns an empty array when it's called. I know the rules are there and they're being applied from the static rules json, it's just that getMatchedRules() is not showing them for some reason. I'm using: const rules = await browser.declarativeNetRequest.getMatchedRules(); But it only ever returns: {rulesMatchedInfo: []} Can anyone tell me what I'm doing wrong please? The same code works fine in Chromium based browsers. Thank you.
2
0
850
Jun ’23
How to use Map initializers Xcode15
Hello, I'm trying to learn swift and making the Landmarks tutorial I found a problem with the map view. The error read as follow: "'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead." My code is: import MapKit struct MapView: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 34.011_286, longitude: -116.166_868), span: MKCoordinateSpan(latitudeDelta: 0.2, longitudeDelta: 0.2) ) // The error happens here! var body: some View { Map(coordinateRegion: $region) } } #Preview { MapView() } Any suggestions about hot to solve this will be appreciate it. Thanks, BR Skalex
3
1
2.2k
Jul ’23
Authenticate with ProxyConfiguration in WebKit
Hello, I am trying to apply ProxyConfiguration on the WebKit webview. I've tried HTTP and SOCKSv5 without authentication, and it proxies normally. However, after I set up username authenticate on the server side, then set username and password with applyCredential on the client side, it couldn't authenticate the connection. Logs on the server side show the client side says it doesn't support any authentication. So I have some questions about the authentication: Does the ProxyConfiguration support authentication now? Does applyCredential apply credentials on HTTP/HTTPS and SOCKSv5 proxy?
4
1
977
Jul ’23
Vision Pro Safari WebXR video playback not working
The Safari version for VisionOS (or spatial computing) supports WebXR, as reported here. I am developing a Web App that intends to leverage WebXR, so I've tested several code samples on the safari browser of the Vision Pro Simulator to understand the level of support for immersive web content. I am currently facing an issue that seems like a bug where video playback stops working when entering an XR session (i.e. going into VR mode) on a 3D web environment (using ThreeJS or similar). There's an example from the Immersive Web Community Group called Stereo Video (https://immersive-web.github.io/webxr-samples/stereo-video.html) that lets you easily replicate the issue, the code is available here. It's worth mentioning that video playback has been successfully tested on other VR platforms such as the Meta Quest 2. The issue has been reported in the following forums: https://discourse.threejs.org/t/videotexture-playback-html5-videoelement-apple-vision-pro-simulator-in-vr-mode-not-playing/53374 https://bugs.webkit.org/show_bug.cgi?id=260259
5
1
2.5k
Aug ’23
Safari Responsive Design Mode Simulators are not showing up.
I have simulators downloaded to my 14" M2 Pro Macbook Pro, and for some reason, I cannot see any simulators as an option in Safari's Responsive Design Mode. Am I missing something obvious, or is my computer bugged? Above is an image of the Responsive Design Mode showing no simulators. I would offer more screenshots to prove that I have simulators installed, but it won't let me upload any more photos for some reason.
23
9
5.1k
Sep ’23
Getting Redis Server Error
After System update to Sonoma 14.0 (23A344) today, I am getting error in my local that -> Can't start redis server. Check logs for details. Even I did setup redis in my local and checked the port (6379) which I configured in my code and which is default port as well, is running fine. The moment I updated my machine I am getting this error and the same code test is getting passed on server and working fine.
6
0
1.3k
Sep ’23
Autofill verification codes received in Mail
As announced for iOS 17 and macOS Sonoma, “One-time verification codes you receive in Mail are filled in automatically, so you can log in without leaving Safari.” Is there any documentation about this? Maybe for a specific keyword that must be in the HTML email body? I tried it on my website with a verification code sent by email and it didn't work.
4
4
3.1k
Oct ’23
Safari 17.0 does not support css-function as Safari 16.x
I’m talking about CSS-functions: https://w3c.github.io/csswg-drafts/css-values/#round-func) .example { --result: round(up, var(--number), 1); } In Safari 16.x css round didn’t work perfect.round(up, x, 1) did its job, if x wasn’t a “natural” number (all digits after the fraction mark 0). If it was, it resulted the next one! Now Safari 17.0 gives 0 for all numbers! !Update! Sorry, Safari 17 does round! But: not in code like that: :root { --result: round(up, var(--number), 1); Had a project, where this was used to define the number of columns and rows I wanted for an (mostly) quadratic layout. What’s working instead: grid-template-columns: repeat(round(up, sort(var(--items), 1), minimal(…); the former css used the :root-variant (grid-template-columns: repeat(var(--result) …). !Update 2! After some experiments I found: Safari 17 doesn’t like :root any more! (https://www.w3.org/TR/selectors-3/#root-pseudo) And: Safari doesn’t calc correct: `round(up,1,1)˚ is 2 — says Apple. YOU MUST NOT CALC CSS-INTEGERS! CSS-DPI ist ####### ENOUGH!
1
0
1.3k
Oct ’23