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.
Explore the integration of web technologies within your app. Discuss building web-based apps, leveraging Safari functionalities, and integrating with web services.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
When attempting to authorize an Apple Payment on an iOS 18 device using the scannable code in a non-Safari browser (i.e. Chrome), the payment sheet displays briefly, then dismisses.
This same exact implementation of Apple Pay on the Web works flawlessly in Safari, so this feels like a bug given that the merchant session works fine in Safari.
The following errors were found in my iOS device logs:
(PassbookUIService) Codable: Failed to decode Merchant Session Created: Error Domain=NSCocoaErrorDomain Code=4864 UserInfo={NSDebugDescription=<private>, NSCodingPath=<private>}
(PassbookUIService) Session 29592: Fatal Error: Failed to decode merchant session created`
Safari 18.0.1 on macOS 15.01 doesn't support the Passkey PRF extension during cross-device WebAuthn authentication when using QR code scanning, while it works correctly with iCloud passkeys.
Steps to Reproduce:
Clone and setup:
git clone https://github.com/quocle108/passkey-prf-test
yarn
yarn start
Test iCloud Passkey Flow:
Open http://localhost:3000 in Safari
Open DevTools (Cmd+Option+I)
Click "Register"
Choose "Passkey on iCloud"
Expected console output: PRF supported: true
Test Cross-Device Flow:
Click "Register"
Choose "Phone/Tablet"
Scan QR with mobile device
Expected: PRF supported: true
PRF extension should be supported in cross-device flow, matching iCloud passkey behavior.
Actual: PRF supported: false
Cross-device flow returns empty extension results.
Verify in Chrome
Repeat steps 2-3 in Chrome
Both flows return proper PRF extension results: PRF supported: true
Test Environment:
Browser: Safari 18.1.1 , Chrome 131.0.6778.70
OS: macOS 15.01
Mobile: iOS 18.x / Galaxy Note9 Android 10
Test repo: https://github.com/quocle108/passkey-prf-test
We are encountering an issue where the Safari extension we are developing stops working while in use on relatively new iOS versions (confirmed on 17.5.1, 17.6.1, and 18). Upon checking the Safari console, the content script is displayed in the extension script, so the background script or Service Worker must be stopping. The time until it stops is about 1 minute on 17.5.1 and about one day on 17.6.1 or 18.
When it stops, we would like to find a way to restart the Service Worker from the extension side, but we have not found a method to do so yet. To restart the extension, the user needs to turn off the corresponding extension in the iPhone settings and then turn it back on.
As mentioned in the following thread, it is written that the above bug was fixed in 17.6, but we recognize that it has not been fixed. https://forums.developer.apple.com/forums/thread/758346
On 17.5.1, adding the following process to the background script prevents it from stopping for about the same time as on 17.6 and above.
// Will be passed into runtime.onConnect for processes that are listening for the connection event
const INTERNAL_STAYALIVE_PORT = "port.connect";
// Try wake up every 9S
const INTERVAL_WAKE_UP = 9000;
// Alive port
var alivePort = null;
// Call the function at SW(service worker) start
StayAlive();
async function StayAlive() {
var wakeup = setInterval(() => {
if (alivePort == null) {
alivePort = browser.runtime.connect({ name: INTERNAL_STAYALIVE_PORT });
alivePort.onDisconnect.addListener((p) => {
alivePort = null;
});
}
if (alivePort) {
alivePort.postMessage({ content: "ping" });
}
}, INTERVAL_WAKE_UP);
}
Additionally, we considered methods to revive the Service Worker when it stops, which are listed below. None of the methods listed below resolved the issue.
①
Implemented a process to create a connection again if the return value of sendMessage is null. The determination of whether the Service Worker has stopped is made by sending a message from the content script to the background script and checking whether the message return value is null as follows.
sendMessageToBackground.js
let infoFromBackground = await browser.runtime.sendMessage(sendParam);
if (!infoFromBackground) {
// If infoFromBackground is null, Service Worker should have stopped.
browser.runtime.connect({name: 'reconnect'}); // ← reconnection process
// Sending message again
infoFromBackground = await browser.runtime.sendMessage(sendParam);
}
return infoFromBackground.message;
Background script
browser.runtime.onConnect.addListener((port) => {
if (port.name !== 'reconnect') return;
port.onMessage.addListener(async (request, sender, sendResponse) => {
sendResponse({
response: "response form background",
message: "reconnect.",
});
});
②
Verified whether the service worker could be restarted by regenerating Background.js and content.js.
sendMessageToBackground.js
export async function sendMessageToBackground(sendParam) {
let infoFromBackground = await browser.runtime.sendMessage(sendParam);
if (!infoFromBackground) {
executeContentScript(); // ← executeScript
infoFromBackground = await browser.runtime.sendMessage(sendParam);
}
return infoFromBackground.message;
}
async function executeContentScript() {
browser.webNavigation.onDOMContentLoaded.addListener((details) => {
browser.scripting.executeScript({
target: { tabId: details.tabId },
files: ["./content.js"]
});
});
}
However, browser.webNavigation.onDOMContentLoaded.addListener was not executed due to the following error.
@webkit-masked-url://hidden/:2:58295
@webkit-masked-url://hidden/:2:58539
@webkit-masked-url://hidden/:2:58539
③
Verify that ServiceWorker restarts by updating ContentScripts
async function updateContentScripts() {
try {
const scripts = await browser.scripting.getRegisteredContentScripts();
const scriptIds = scripts.map(script => script.id);
await browser.scripting.updateContentScripts(scriptIds);//update content
} catch (e) {
await errorLogger(e.stack);
}
}
However, scripting.getRegisteredContentScripts was not executed due to the same error as in 2.
@webkit-masked-url://hidden/:2:58359
@webkit-masked-url://hidden/:2:58456
@webkit-masked-url://hidden/:2:58456
@webkit-masked-url://hidden/:2:58549
@webkit-masked-url://hidden/:2:58549
These are the methods we have considered. If anyone knows a solution, please let us know.
I have a question. In the file located at /Library/Preferences/com.apple.networkd.plist, if the dict entry for enable_unified_http is set to true or if the value is missing, there is an issue where the video player does not run on MacOS Sequoia Safari 18.0. I found that setting it to false allows it to function properly. Could you explain what this setting does and whether it is possible to change this setting to false within the app?
Topic:
Safari & Web
SubTopic:
General
Despite using the iPad in landscape mode, self-camera video is forced to portrait (Rotate 90 degrees).
Only the video is portrait, even though the browser is in landscape orientation.
Our app use getUserMedia() to get the video.
The problem also happend in iPad Safari GoogleMeet.
Details:
The problem occurs even when the screen orientation is locked.
After the video has been forced to portrait, rotating the iPad temporarily changes the video to landscape, but forces it to portrait again.
It takes around 0 - 30 seconds before the video is forced to portrait.
Both selfie camera and back camera
I have confirmed this problem on the following devices
iPad 8th iPadOS: 18.3.1
iPad10th iPadOS:18.3.1
iPadPro(M4) iPadOS:18.3.1
Some devices do not have this problem, even if they are the same model and OS version.
I have tried the following
restart
factory reset
Configuration changes (Settings > Apps > Safari)
SETTINGS FOR WEBSITES
Camera > Allow, Ask
Microphone > Allow, Ask
Advanced > Feature Flags
Reset All to Defaults
Screen Orientation API (Locking / Unlocking)
Screen Orientation API
WebRTC AV1 codec
Please help me to resolve this problom. Thanks.
Hi, in our app we have a WKWebView with complex web content that is loaded with cachePolicy: .reloadIgnoringLocalCacheData. If the app is in the background for several hours and returns in the foreground we noticed that the system reloads the webpage, but it does so with a cachePoliy returnCacheDataElseLoad. This could break the app if older cache content is present.
To reproduce start an app in the simulator (tested with iOS 17.2), put it in the background and via activity monitor stop the processes
com.apple.Webkit.WebContent
com.apple.Webkit.networking
After foreground the reload will happen.
Two questions:
why is this reload happening after some hours in the background? We haven't seen any crash reports related to this. It mostly happens on one of our test devices (iphone13 with iOS17.2.1).
why is the webview reloading with a modified cachePolicy (returnCacheDataElseLoad)?
Our temporary fix is to detect this case in "webView:decidePolicyFor navigationAction decisionHandler", cancel the request and reload with modified cachePolicy.
Any ideas?
Thanks,
Heiko
Sample code:
class ViewController: UIViewController, WKNavigationDelegate, WKUIDelegate {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let config = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: config)
webView.uiDelegate = self
webView.navigationDelegate = self
view.addSubview(webView)
let myRequest = URLRequest(url: URL(string: "https://www.apple.com")!, cachePolicy: .reloadIgnoringLocalCacheData)
print("request \(myRequest)")
webView.load(myRequest)
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
print("start loading \(String(describing: navigationAction.request.url)), cache:\(navigationAction.request.cachePolicy)")
decisionHandler(.allow)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let fullscreen = CGRect.init(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height)
webView.frame = fullscreen
}
}
Hi everyone,
I'm exploring the new app icon appearance options (Clear, Dark, Tinted) for Progressive Web Apps (PWAs) on iOS26, iPadOS26, and macOS26. Currently, PWA icons don't seem to render well with these new appearances, particularly in Clear and Tinted modes, resulting in very very poor visual quality. You can hardly see anything.
Has support for these icon appearances been fully implemented for PWAs? If so, could someone point me to the relevant Apple Developer documentation or provide guidance on how to configure PWA icons to support Clear, Dark, and Tinted appearances? I've searched the Apple Developer Forums, Stack Overflow, and Reddit but haven't found clear information on this topic.A possible solution is a png file with transparent areas, but if the pattern is dark, nothing will be visible in dark mode.
Any insights or resources would be greatly appreciated. Thanks!
(plz don't give up on PWA😭)
Reference:
https://developer.apple.com/forums/thread/761615
https://stackoverflow.com/questions/78780916/is-there-a-way-to-provide-light-dark-and-tinted-variants-of-apple-touch-icon
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html
Hi, this is my first post in the community, so please correct me if i am posting this somewhat in a wrong manner.
Im using my Apple M1 Pro(14inch, 2021) and installed the os 26 yesterday.
Today, I was using Safari, and all of sudden it gets frozen, then the following window popped up.
Is this something expected? i.e. my usage is somewhat unusual or is there any report around potential memory leak in Safari? appreciate any suggestions, as Safari is my main browser and currently on hold due to this issue. Thanks
Hi,
I have an app that uses WKWebView and it's crashing on iOS 26 Simulator in places I've never had problems before. In this case it's crashing when calling WKWebView.callAsyncJavaScript, but in my other project WKWebView is crashing with some sort of EXC_BAD_ACCESS other than callAsyncJavaScript.
Am I missing something?
Thanks,
Topic:
Safari & Web
SubTopic:
General
Since update to Safari version 18 our browser extension stopped working. Our developers came to following conclusions:
After saving a state of the extension (communication of the service_worker background script), the extension is blocked until user clicks to other window than Safari. After that the extension restarts and everything works correctly. Until next interaction with extension on the option page and popup window. We use for communication functionality chrome.runtime.onMessage.
Extension sometimes incorrectly loads data from chrome.storeage.local and user loses all data
Options page is always displayed in the new window instead of the new tab
All problems described above were not happening in Safari version 17. Unfortunately there is no advice in the developer community, how to fix these problems.
Anybody here experiences same problem or has a solution for it?
Topic:
Safari & Web
SubTopic:
General
Hello there I have a nested USDZ file I had created a long time ago with some make-up products.
Its behaviour was always the same in the past: nested usdz files allow you to control each object "nested" separately. So I used this as a way to allow people to play around with a "set of objects".
Today I went to try it and since I'm on ios 18 it shows an "assets tab" on the bottom that allows me to see all the assets inside the tab but doesn't allow me to see or anchor them at all!
What changes do I need to do in order for this to work and where can I check documentation on these new behaviours for USDZ files? And what will this allow for in the future?
Thank you in advance
I’m encountering an issue with CSS not displaying when using WKURLSchemeHandler to load local HTML files.
• When I package the app using Xcode 15.3 or above, the CSS styles do not display on iOS 17 or higher. However, on iOS 16.7.1, the CSS displays correctly.
• If I use Xcode 15.2 to package the app, the CSS loads and displays correctly on all iOS versions.
I am using WKURLSchemeHandler to intercept and load the local HTML files. Is there any known issue or workaround for this?
You can now post this in the “Safari & Web” section of the Apple Developer forums for further assistance!
//
// CustomURLSchemeHandler.m
// HTMLTest
//
// Created by lvxue on 2024/9/23.
//
// CustomURLSchemeHandler.m
#import "CustomURLSchemeHandler.h"
@implementation CustomURLSchemeHandler
// 拦截请求并提供本地 HTML 文件
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
NSURL *url = urlSchemeTask.request.URL;
//NSString *filePath;
// 获取本地 HTML 文件路径
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html" inDirectory:@"LoaclHtml.bundle/A4"];
// 判断请求的是 HTML、CSS 或其他文件
if ([url.lastPathComponent hasSuffix:@".css"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"style" ofType:@"css" inDirectory:@"LoaclHtml.bundle/A4/css"];
} else if ([url.lastPathComponent hasSuffix:@".js"]) {
filePath = [[NSBundle mainBundle] pathForResource:@"yourJSFileName" ofType:@"js" inDirectory:@"LoaclHtml.bundle/A4/js"];
} // 可以继续添加其他资源类型如图片
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
NSString *mimeType = [self mimeTypeForPath:filePath];
// 创建响应头
NSURLResponse *response = [[NSURLResponse alloc] initWithURL:url
MIMEType:mimeType
expectedContentLength:htmlData.length
textEncodingName:@"utf-8"];
// 提供响应数据
[urlSchemeTask didReceiveResponse:response];
[urlSchemeTask didReceiveData:htmlData];
[urlSchemeTask didFinish];
}
// 停止请求
- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id<WKURLSchemeTask>)urlSchemeTask {
// 通常不需要处理停止请求的逻辑
}
- (NSString *)mimeTypeForPath:(NSString *)path {
NSString *fileExtension = [path pathExtension];
if ([fileExtension isEqualToString:@"html"]) {
return @"text/html";
} else if ([fileExtension isEqualToString:@"css"]) {
return @"text/css";
} else if ([fileExtension isEqualToString:@"js"]) {
return @"application/javascript";
} else if ([fileExtension isEqualToString:@"png"]) {
return @"image/png";
} else if ([fileExtension isEqualToString:@"jpg"] || [fileExtension isEqualToString:@"jpeg"]) {
return @"image/jpeg";
} else if ([fileExtension isEqualToString:@"gif"]) {
return @"image/gif";
}
return @"application/octet-stream";
}
@end
code-block
Topic:
Safari & Web
SubTopic:
General
On iPhone 16 running iOS 18.0(Xcode 16.2), cookies configured with SameSite=None; Secure fail to apply correctly—iOS forcibly converts the attribute to SameSite=Lax. As a result, cross-site requests from H5 pages within our app cannot carry the required cookies, causing failures.
Can anyone help me on this?
Thanks in advance.
Hi! Is there any fix:
Sounds are not recreated while using websites with, for example, virtual piano keyboard or metronome.
Hi, I'm using a webview in Swift, where I load an html file locally. Basically I have an angular project built and loaded directly into my app bundle. The webview requires the use of the camera. I request permissions via and javascript, the pop-up appears, I accept the permissions and the app works correctly. Only that after a certain number of seconds, the permissions are requested again. It's as if the webview doesn't cache the accepted permissions.
Is this normal behavior?
myCode is here
// titleScript = "document.querySelector('#\(rawValue) span')?.textContent"
guard let titleResult = try? await webView.evaluateJavaScript(type.titleScript),
let title = titleResult as? String else { return }
this code has error
Thread 1: Swift runtime failure: Unexpectedly found nil while implicitly unwrapping an Optional value
but edit Code like this
It is works Successful
do {
...
let titleResult = try await webView.evaluateJavaScript(type.titleScript)
let title = titleResult as? String
...
} catch {
LogManager.log(level: .error, self, #function, error, "title is Invalid : \(type.titleScript)")
continue
}
I don't know why guard let _ = try? is Fail
Our iOS app uses React Native Webview (based on top of WKWebView) to display content. This webview stays in memory throughtout the app's lifecycle. We are observing a high number of webview content process terminations - around 15% of our sessions. (https://developer.apple.com/documentation/webkit/wknavigationdelegate/webviewwebcontentprocessdidterminate(_:))
What could be the reasons for it? Is there a way to know for sure?
Is the 15% of sessions number something that other apps also experience, or should this be lower?
Thanks!
Topic:
Safari & Web
SubTopic:
General
Hi all,
Managing Safari usage in an enterprise environment and I’m looking for ways to disable or restrict the QUIC protocol to enforce network-level security policies (e.g., content filtering).
Does Safari offer any settings to disable QUIC, or is there a known workaround to prevent Safari from using it?
Appreciate any insights or guidance.
Topic:
Safari & Web
SubTopic:
General
Hello - we have a Mac application that uses a browser extension and the web extension JS APIs to communicate with Safari. As of macOS 15.4 / Safari 18.4 the tab OnAttached and tab onDetached events are no longer received.
After some testing we verified that the events were working properly as of macOS 15.3 / Safari 18.3 but appear to have been broken in macOS 15.4. Note a similar issue was reported previously for Safari 17.6 and was fixed in macOS 15.0 (FB14324177).
We have made a TestFlight version of our app (Tabby) available to simplify debugging via https://testflight.apple.com/join/Va8Zdv9d.
To reproduce the issue:
Install the Tabby TestFlight build on macOS 15.4 or 15.4.1
Open Safari, go to Safari settings and select the Extensions tab
Enable the Tabby extension and grant permissions to all windows all the time
Open a Safari window with at least 3 tabs
Note the open window and tabs displayed in Tabby
In Safari, perform a tab detach by dragging a tab out of the window
Expected behavior
Within Safari the detached tab should now be in it’s own window, and via the onDetached event Tabby should update to show the tab in it’s own window AND removed from the original window.
Observed
Safari fails to send the onDetached event and Tabby will continue to display the detached tab in its original window in addition to the new window.
You can also use the repro steps above to observe the onDetached event being received or not by Tabby in the Safari developer console. The same steps but re-attaching the tab to the original window can be used to observe the onAttached event being received or not.
We’ve attached two screen recordings to the Feedback ID below, one showing the events working on macOS 15.3, and one showing the events failing to be received on macOS 15.4.1. Note it also fails on macOS 15.4.
FEEDBACK ID: FB17367977