Hi, we are experiencing a strange issue with our Web App. Our web app runs entirely on the same domain , and we are making several AJAX requests to the same server. The Error occurs only on Iphones, the app works completely fine on androids and computers.
Most of the requests work fine, but suddenly, one specific request always fails with the following error:
XMLHttpRequest cannot load https://demo2.artios.cz/app37g/v105/php/endpoint.php due to access control checks
What we have checked so far:
✅ CORS headers seem correct. Also we operate entirely on the same domain, client and server.
✅ The same request works fine in computer and android devices.
✅ The issue occurs only on iPhone (tested on Chrome and Safari).
✅ Some requests to the same endpoint pass, but suddenly, this specific request always fails.
✅ There is no OPTIONS preflight request logged in the network tab, but we use only simple requests.
✅ We are making a POST request with multipart/form-data.
What is Your advice, or where I can find more info about this error? We do not think the CORS is the problem. We have tried to inspect with WebInspector but with no relevant answers. Thank You very much!
WebKit
RSS for tagDisplay web content in windows and implement browser features using WebKit.
Posts under WebKit tag
200 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
In my content blocker I have a bunch of rules that block some content in Safari, but I want my users to be able to whiltelist a website so the blocker rules don't apply on that site.
I have something like this:
{
"action": {
"type":"css-display-none",
"selector":"a[href*='Bobbins']"
},
"trigger": {
"url-filter":".*"
}
},
{
"trigger": {
"url-filter": ".*",
"if-domain": ["*mydomain.com"]
},
"action": {
"type": "ignore-previous-rules"
}
}
I think that should block any a link where the href includes Bobbins but not if the site is mydomain.com. However, that simply doesn't work. It doesn't matter what I put in the array of domains to whitelist, it just doesn't apply it. In every case, the a link is blocked.
How do you actually whitelist a website in a Safari content blocker?
Prime Objective
I am trying to have a scroll view with a fixed header, a fixed footer, and a WKWebView in between. Using JavaScript, the height of the webView is determined and set to be large enough to hold the entire content.
The Problem
When selecting text on the webView, the view does not scroll when the edges are reached (this works if the webView is shown without being embedded in a Scroll view, or if it is the last element)
What did I try?
I tried reading the scroll view, or adding a gesture recognizer, but all of that does not work because the selection is essentially a system task
Sourcecode
Sourcecode to demonstrate the issue can be found on GitHub
As discussed and acknowledged here, there is a known bug with the FamilyActivityPicker. When a user expands a category that contains enough tokens to exceed the 50mb memory limit, the FamilyActivityPicker crashes.
This happens quite frequently for heavy Safari users. An apple engineer mentioned on this thread that WebDomains shown in the picker are present based on the last 30 days of usage data as surfaced by WebKit.
Is there any way a user can clear these WebDomains? Either programatically through our app or any other process we can guide them to as a workaround while this issue is getting fixed?
Is ServiceWorker supported on WKWebView? As per Mozilla Developer Network(MDN Web) docs[1] its not supported, but our research shows that ServiceWorker becomes available for a domain in WKWebView 1) if the domain is allowlisted in app-bound domains[2] or 2) if app is registered as default browser(this can not be considered for our app as its not a browser).
How to enable ServiceWorker on WKWebView? Is adding domain as app-bound domain the right/only way to enable ServiceWorker on WKWebView? We didn't find any official documentation about this.
Can WebView get ServiceWorker support by default without enabling app bound domains since that is not an option for our app? Our app needs to support more than 10 domains. Powerful APIs such as JavaScript injection, cookie manipulation, event handlers are by default available to all domains/WebView instances even if App doesn't enable app-bound domains. Is it possible to do same for ServiceWorker?
If ServiceWorker can not be supported by default then can Apple provide a feature by which ServiceWorker will be enabled in App for all the domains?
Apple enforces maximum of 10 app-bound domains. Is it possible to remove this limit and provide a way to dynamically add to this list at the time of a request?
[1] https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorker#browser_compatibility
[2] https://webkit.org/blog/10882/app-bound-domains/
I want the wkwebview to revert to its previous state when I restart it.
decidePolicyFor delegate method:
import WebKit
@objc extension DocumentationVC
{
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void)
Being called just alright in swift 5 minimal concurrency.
Raising concurrency to complete with swift 5 or swift 6. Changing the code to avoid warnings:
@preconcurrency import WebKit
@objc extension DocumentationVC
{
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
The delegate method is not being called. Changing back to swift 5 concurrency minimal - it is called.
Looking at WKNavigationDelegate:
WK_SWIFT_UI_ACTOR
@protocol WKNavigationDelegate <NSObject>
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(WK_SWIFT_UI_ACTOR void (^)(WKNavigationActionPolicy))decisionHandler WK_SWIFT_ASYNC(3);
Changing the delegate method to:
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping @MainActor (WKNavigationActionPolicy) -> Void) {
And it is called across swift 5 concurrency minimal to complete to swift 6.
I thought, the meaning of @preconcurrency import WebKit was to keep the delegate without @MainActor before the (WKNavigationActionPolicy) still matching regardless the swift concurrency mode?
My point is - this can introduce hidden breaking changes? I didn't see this documented anyhow at: https://www.swift.org/migration/documentation/migrationguide/.
decidePolicyFor is an optional method - so if signature 'mismatches' - there will be no warning on not-implementing the delegate method.
How do we catch or diagnose irregularities like this? Is it something @preconcurrency import WebKit should be ensuring and it is not?
Is this delegate mismatch a bug on swift side or something we should be taking care of while migrating? If it is on us, how do we diagnose these potential mismatches?
I want to implement webauthn using WKWebView for my mac application. I want to host the asaa file in the rpid. Below are my site configuration -
Main domain - example.com
Subdomain which has the sign-in view and where webauthn kicks in - signin.example.com
RPID - example.com
Where shall i host the asaa file at domain(example.com) or subdomain(signin.example.com)?
I'm having issues with opening up role="link". links in wkwebview. Is there a way in my decideforpolicy to allow these links to open up in the current webview vs another window like a traditional web browser does? Thank you ahead of time.
I'm developing an application that needs smooth framerates within a wkwebview that interacts with native code. However, requestAnimationFrame by default is still throttled to 60hz even if all my target devices (the iPad Pro for example) have supported 120hz for a long time already. I noticed that the latest Safari in 18.3 beta supports unlocked framerates, but that's only under Safari feature flags. To my knowledge, these flags do not apply to WKWebView. Is there a way to enable unlocked framerate in WKWebView via requestAnimationFrame? (Calling JS at a faster rate from the native code side will not work, almost definitely, since WKWebView will still render at its own rate.)
This is an experimental application for internal use and I'm okay if there are temporary beta solutions available.
Hi,
I am wondering if anyone has experience with Smart Banners for an application not released on the app store, but still in TestFlight, specifically an AppClip.
I am working on an exisiting project where a Smart Clip is used with a smart banner on the website for core functionality. Previously, even in test environment (app is in test flight and not app store) the smart banner would correctly show on the website and allow testers to launch the app clip experience, however this no longer seems to work.
Its noted the test environment was last tested and deployed 2 years ago, and was working correctly, and there have been no changes to the website (the meta tag and .aasa file are all setup correctly). The only recent change was upgrading the app to support the latest iOS version, however beyond that no functionality in the app has changed.
Apple developer support hasn't been very helpful, and reviewed our account and stated "everything appears to be running as expected on our end"
Has something changed in Safari in that it no longer accepts test flight app smart banners, and if it doesn't, does anyone have any other suggestions?
Cheers
Hello,
I'm using Safari 18.2 on Sonoma 14.6.1.
I was using the Developer Tools to do a Local Request Override in the Source tab for a CSS file that had a changing query string. I thought I had a good regular expression to catch all variants, but apparently it was too generic and possibly wrong, and made both Source and Network tabs no longer work in my Safari.
The regular expression I entered for the Local Request Override was: //build/style.css(?.*)?$
Now my dev tools is broken to the extent that the Source and Network tabs no longer work. The slide-out panel on Source that shows Breakpoints, LocalOverrides, etc no longer shows. The toggle for it does, but does nothing now. UI in general looks a little wack on both tabs.
So, since I can't turn off the Local Request Override, I've been trying to locate where Safari may have stored it to manually delete it. Not having a lot of luck on that front.
It seems to me that Safari was unable to escape my regular expression correctly and it then causes additional issue. Just a guess though.
Any advice or help in getting Safari Source & Network working again / manual removal of the LocalOverride would be greatly appreciated. I'm fluent in OSX and Linux, but grep was not much help surfacing anything that worked.
Thanks in Advance, possibly a Safari bug as well.
Having the app localised and configured to Dutch from Belgium (nl_BE), I open a url with WKWebView. The website locale detects Dutch from Netherlands (nl_NL)
Hi,
I’m encountering an unexpected issue in Safari. Specifically, navigator.clipboard.writeText() fails when called from a content script in my extension immediately after sending a message to background.js while it works fine in Chrome and Firefox. Is this expected?
Environment
Safari
18.2 (20620.1.16.11.8)
Technology Preview 210
macOS Sequoia 15.2 (24C101)
Example
This is a minimal reproducible example, which adds a button to example.com:
https://github.com/mshibanami/ClipboarAPIIssueExample
Below is the related code:
// content.js
copyButton.addEventListener('click', async () => {
// 👇️ This call seems to trigger the issue
await chrome.runtime.sendMessage({});
try {
await navigator.clipboard.writeText(text);
alert(`✅ Copied '${text}' to clipboard!`);
} catch (err) {
alert(err + '\n\n' + `navigator.userActivation.isActive: ${navigator.userActivation.isActive}`);
}
});
// background.js
chrome.runtime.onMessage.addListener(() => { });
When I click the button, I expect the text to be copied successfully. However, I receive an error in Safari.:
Interestingly, if I remove chrome.runtime.sendMessage(), the clipboard operation works without any problems. Also, note that navigator.userActivation.isActive is true, which might mean it's not related to the User Activation API.
Misc.
This might be related to another question I posted here:
https://developer.apple.com/forums/thread/772275
Hi,
I'm encountering an issue with the Clipboard API's writeText() method in Safari. It throws a NotAllowedError even when triggered by a user action (selecting an option from a <select> element). Is this expected?
This issue seems specific to Safari, as the same code works perfectly in Firefox and Chrome.
Perhaps I should send feedback to Apple, but I'd like to post it here first in case I misunderstand something.
Problem
In Safari, when I try to copy text to the clipboard using navigator.clipboard.writeText() within an input event listener attached to a <select> element, it fails with the following error:
NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
Environment
Safari
18.2 (20620.1.16.11.8)
Technology Preview 210
macOS Sequoia 15.2 (24C101)
Example
I've created a minimal reproducible example on CodePen: https://codepen.io/mshibanami/pen/LEPdxXZ
Here's the relevant JavaScript code from the example:
selectElement.addEventListener('input', async (event) => {
const selectedText = event.target.options[event.target.selectedIndex].text;
try {
await navigator.clipboard.writeText(selectedText);
alert(`Text copied to clipboard: ${selectedText}`);
} catch (err) {
alert('Failed to copy text to clipboard: ' + err);
}
});
Firefox and Chrome handle this code without any issues, successfully copying the text to the clipboard, but not Safari.
Possible Cause
I suspect this issue might be related to WebKit's User Activation API. It seems like Safari is not correctly recognizing the input or change event on a <select> element as a valid user activation for the Clipboard API, even though it is initiated by a user gesture.
Questions
Is this behavior unexpected? Should Safari allow the Clipboard API to work in this context?
(Technically, this might be expected as of now, as such events are not explicitly described in https://webkit.org/blog/13862/the-user-activation-api/.)
Any insights or suggestions would be greatly appreciated. Thanks!
I was in the webview long according to the pictures, and then select "save image" will lead to collapse, I have passed on the info plist add NSPhotoLibraryAddUsageDescription solved it.
Now I have another question, does the last item "query" in the screenshot have a similar problem? Since I couldn't click the button (I don't know why this happened), I couldn't test it on the real machine.
When WKWebView loads a site that has username and password on different pages, standard "Passwords" button above keyboard does nothing. Reproducible on both physical device and simulator. At the same time, Safari works fine in this case.
Any chance to fix this behavior in the upcoming iOS updates?
Here's video demonstrating the issue:
and a sample code to reproduce it (nothing specific, just bare WKWebView with default configuration):
class ViewController: UIViewController {
private let webView = WKWebView(frame: .zero)
override func viewDidLoad() {
super.viewDidLoad()
view.addSubview(webView)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
webView.frame = view.bounds
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
webView.load(URLRequest(
url: URL(string: "https://accounts.google.com/")!
))
}
}
I have a content blocker that generally works correctly, but I need to block an element that has certain text in it.
For example, <span id="theId">Some text</span> is easy enough to block because I can locate the id and block that, but what if there is no id, or the id is completely random? What if it's just <span>Some text</span>? How do I block that?
Let's say this is my only content blocker rule:
[
{
"action": {
"type": "css-display-none",
"selector": ":has-text(/Some text/i)"
},
"trigger": {
"url-filter": ".*"
}
}
]
No errors are seen when the rule is loaded, so it's syntactically correct, it just doesn't block the HTML. I gather this is because :has-text() works on attributes, not contents, so it works on alt, href, aria-label etc. but not on the contents of the element itself.
How do I block Some text in my example above? Thanks!
Hi,
Our company has an application uses the WKWebview to host a lot of content.
The content is web based and hosts a lot of charts and metrics.
Because of the high content, we've seen the memory of the WebContent hit above 1.25 GB.
When that happens, it'll eventually terminate and we have our recovery code to reload the same page
Seems like the limit is hidden / internal. Some Apple devs also noted something might be hard coded to be limited as well.
Yes, we have our optimizations but we still need to keep our queries, use react, cache, etc... It's just a heavy web application.
Request:
Can you help us raise that limit?
Are there some limitations in Webkit for such a need to terminate?
As some devices have much higher RAM than before, we were hoping to be able to dynamically adjust the limit for the wkwebview before it resets.
We contacted our internal contacts but they said to post here.
Enhancement in managing tabs in Safari
It would really be awesome to bring the fascinating tab management feature of Arc Browser to Safari across iOS, iPadOS and macOS.
Especially below listed features;
Multitask
Create
Organize
Rev Up
Release Notes
For further info , here is the official link of Arc Browser, https://resources.arc.net/hc/en-us/categories/16435255982103-Features.