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

Safari extension fails with any error message
I migrated my extension from Manifest V2 to V3 recently, and it works fine on Chrome/Edge, but got failed on Safari. The only error message that I can see is: 由于出现错误,service_worker脚本载入失败。 It says service_worker failed to load. There is no other messages I can found. Can you please tell me how to get more informations about the error? Thanks!
2
0
1.3k
Nov ’22
how to prevernt "webViewWebContentProcessDidTerminate:"happen?
we have wkwebView page which use js bridge to launch camera to take photos. some times the "webViewWebContentProcessDidTerminate:" get called ,we have to relaod the page(it don't,the page will go blankl or unresponsive),but then the user content was lost. By my experience,this is associate with memory。at the moment we take photo,the total memory useage get high more the 10~20M high. but when I don't l;aucn the camera,it's worked well. i have question about this. how to reduce the memory useage by camera at the moment?I has already add @autoreleasepool to the take photo finish event,it's get down when finished, it has a peak but I want it keep steady。 as we know the wkwebview work in independent process,how the memory useage can affect the wk process? any other way to prevent this? please help!
1
0
1.5k
Dec ’22
Insert Images to iCloud Notes Web on Windows
Dear Apple Developers, I am an avid user of iCloud Notes Web on Windows 10, and I have noticed that a crucial functionality is currently missing – the ability to insert or paste images. As someone who frequently uses the Notes app in both Windows and the Apple ecosystem, I believe adding this feature to iCloud Notes Web would greatly improve the user experience. Given that many of us use iCloud Notes to keep track of important information, including images, this missing feature is a significant inconvenience. Without it, users may be forced to resort to alternative products like OneNote. I strongly recommend that you consider adding the ability to insert or paste images to iCloud Notes Web in order to better serve your users and provide a more complete and functional notes-taking experience. Thank you for your attention to this matter. Best regards, Byronmonkey
1
1
1.1k
Feb ’23
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.1k
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
915
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
852
Mar ’23
Does Web Push Notification Actions work on iOS 16.4 ?
I managed to get my Progressive Web App to send notifications to users via Web Push. However, it seems that the definable actions are not working. In Chrome, there is a button in the notification. If you click it, you get an overview of the available actions that the user can click. When I look at the notification on iOS, I only see the "View" action. My self-defined actions seem to be ignored and not displayed. Also, the "notificationclick" event should be executed by the browser as soon as the notification is clicked. In the Serviceworker I listened to the event and tried to link to a specific page of the PWA. In Chrome and Firefox this works fine. In Safari / iOS I only get to the start page of the PWA. Are the notification actions not yet supported with WebKit 16.4 ?
7
2
3.8k
Mar ’23
Occasional WKWebView didFinishNavigation:(WKNavigation*)navigation does not execute
When launching an app on iOS 16.3.1 (or other iOS 16+ versions) and opening a webpage in a webview, after using it for a while (opening and closing pages, switching to background, locking the screen, etc.), there may be occasional instances where the webview page continues to show as loading (for more than ten minutes), and this is due to the fact that the method - (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation was not called. Once this situation occurs, any subsequent attempt to open a webview page will fail to load. The symptom is that the method - (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation is not called. If the app is restarted, everything will be restored. This issue has been observed on iOS 16+ with a higher chance of recurrence on 16.3.1. I don't know if you handsome guys have encountered this situation before.
3
0
761
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.6k
Mar ’23
webRequest API on safari extension with manifest v3
I'm porting a Chrome extension to Safari. The Chrome extension's manifest version is 3 and must stay 3. I've encountered an error around webRequest API where Safari allows this API only on persistent background pages which available only on manifest v2. So, my questions are: Is it possible to use webRequest API on manifest v3 Safari extension? If no, is there any alternative API to listen to requests? Is it something that going to be supported soon? It feels really strange that his basic API is not supported by Safari while the rest of browsers supports this.
4
1
923
Mar ’23
Muted Video play: NotAllowedError - ignoring setting "Allow All Auto-Play"
Hello, Safari Desktop: Version 16.4 (18615.1.26.11.22) EDIT: This is related to the Macbooks "Low Power Mode" being set to "Only on Battery" and the power adapter not being connected. My battery is at 41%. The programatic playing of videos gets blocked even though the browser settings specifically should allow all video plays. The video is muted. Once I click anywhere inside the body the play no longer gets blocked. notallowederror: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission The behaviour is the same when I select the default option "Stop Media with Audio". I was not able to see this behaviour in previous Safari versions. On iOS this issue is not present. Is anyone else experiencing the same issue? This seems to be a bug? Thank you
1
0
1.9k
Apr ’23
HTML behavior for input type "date" and "time" on Safari
Hello, I'm working for an IT company which edit Web apps and we use HTML tags with type="date" and type="time". Actually, we've got different problems on Safari (what I read was that these problems appeared with Safari 16). For and , the User Agent of Safari create tags inside tags (with pseudo-class "-webkit-datetime-edit-day-field" for instance) to display "ghost"/faked data when the value is empty or NULL (in fact, Safari display the current date, in the local format, in ). This behavior is really problematical for us because these inputs don't have to be filled every time (they are not required and don't have the attribute "required"), but they appear filled to our users... When you submit the form, the value is really empty (no value returned and that is what we want) but "something" is always displayed. We found a CSS trick to hide these things to our users but I think it's not normal, isn't it ? Can we block this Safari behavior ? Second problem : for , they are not editable anymore if their value is empty (we detect it thursday, April 6th 2023). However, if we put a specific value when we load the page, then we delete this value in the form, and then we change the value without loosing the focus of the input, it works. If we loose the focus, we can't click on the input to change its value or something else. Do you know the reason why ? For now, we are forced to change the type of these inputs to type="text" when users are on Safari in Javascript... Nevertheless, the official documentation (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date and https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time) talks about compatibility between and Safari. Any idea ? Thank you for your time.
3
3
3.8k
Apr ’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.6k
Apr ’23
On safari 16, web push notifications are not receiving after 3 messages.
I have implemented the web push notifications using the FCM, the thing is I am getting the notifications on safari(but count is only 3 and it varies some time to 4-6). I know that safari will revoke the notification permission, if we do not send the notification to notification center. But in my case I am already sending the notification to notification center, and and it displays the notification on screen(up right corner), after that also it revokes the permission. Is their specific we need to handle in case of service worker ? that user have to mandatory open the notifications upon receiving otherwise it will revoke the permission. Do we have any sample code specific for web push notifications (not local notifications), on how to handle the background messages(through service workers), and the foreground messages(when tab is active). In case of tab active(generally onMessage), I am showing the notification using the following code : let notification = new Notification('title', { 'body': 'some test body' }); And in case of background message(service worker is handling it, specifically I am not doing any thing to show the notification). My service worker code : importScripts("https://www.gstatic.com/firebasejs/9.20.0/firebase-app-compat.js"); importScripts("https://www.gstatic.com/firebasejs/9.20.0/firebase-messaging-compat.js"); self.addEventListener('notificationclick', (event) => { console.log("background worker trigger"); event.notification.close() const pathname = event.notification?.data?.FCM_MSG?.data?.link if (!pathname) return const url = new URL(pathname, self.location.origin).href event.waitUntil( self.clients .matchAll({ type: 'window', includeUncontrolled: true }) .then((clientsArr) => { const hadWindowToFocus = clientsArr.some((windowClient) => windowClient.url === url ? (windowClient.focus(), true) : false ) if (!hadWindowToFocus) self.clients .openWindow(url) .then((windowClient) => //windowClient ? windowClient.focus() : null console.log("opened window") ) }) ) }) if (!firebase.apps.length) { firebase.initializeApp({ apiKey: "somekey", authDomain: "somekey", projectId: "somekey", storageBucket: "somekey", messagingSenderId: "somekey", appId: "somekey", vapidKey: 'somekey' }); } else { firebase.app(); // if already initialized, use that one } const messaging = firebase.messaging(); messaging.onBackgroundMessage(function(payload) { console.log('[firebase-messaging-sw.js] Received background message ', payload); })
1
0
1.4k
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
655
May ’23
Safari does better than Firefox, but better isn’t good.
Safari 16.3: some CSS: --images: 1; --count: round(up, calc(sqrt(var(--images))), 1); results `--count == 2!` As long as the numbers can be controled, you could do sth. like --count: round(up, calc(sqrt(var(--images)) - 0.01), 1); but … this is ugly! ceil(1) should be 1. Every calculator agree. BTW: Firefox has one solution for every root. √x == 0!
6
0
921
May ’23