Issue Summary:
I have encountered an issue where JavaScript does not execute in a WebView when another UIViewController is presented modally with modalPresentationStyle.fullScreen. This problem only occurs on physical devices running iOS 17.5.1. The issue is not present on iOS 17.5 simulators or devices running iOS 17.4.1 or earlier.
Reproduction Steps:
Create a ViewController with a WebView.
Load a web page (e.g., https://apple.com) in the WebView.
Present another ViewController modally with modalPresentationStyle.fullScreen.
Verify that JavaScript execution in the initial WebView stops working.
Test Code:
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the WebView
let configuration = WKWebViewConfiguration()
let webView = WKWebView(frame: view.frame, configuration: configuration)
view.addSubview(webView)
webView.frame = view.frame
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
webView.load(URLRequest(url: URL(string: "https://apple.com")!))
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let navigationController = UINavigationController(rootViewController: TargetViewController())
navigationController.modalPresentationStyle = .fullScreen
present(navigationController, animated: true)
}
}
class TargetViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the WebView
let webView = WKWebView(frame: view.frame, configuration: WKWebViewConfiguration())
view.addSubview(webView)
webView.frame = view.frame
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
webView.load(URLRequest(url: URL(string: "https://apple.com")!))
}
}
Observations:
The JavaScript within the WebView stops executing only on physical devices running iOS 17.5.1.
This issue does not occur on the iOS 17.5 simulator.
Devices running iOS 17.4.1 or earlier do not experience this issue.
Request for Assistance:
Could you please provide any insights or potential workarounds for this issue? Additionally, if this is a known bug, any information on upcoming fixes would be highly appreciated.
Thank you.
Posts under JavaScript tag
33 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I'm experiencing an issue with WKWebView and localStorage. I've set up a standard WKWebView with the configuration:
configuration.websiteDataStore = WKWebsiteDataStore.default()
Everything works fine in the emulator (iOS 16.x, 17.0), but on my iPhone 13 running iOS 17.4, I encounter a problem. When I set a localStorage value on my local HTML page, navigate to another URL within the webview, and then return to the original page, the localStorage is cleared. This behavior is new and wasn't happening before. Has anyone else encountered this or have any suggestions on how to fix it? The localstorage should be persistent as it always has been.
We have an iOS app built using Capacitor. We are seeing a large increase in app crashes on iOS 17.4 (iPhone). Other OS versions seem to be showing significantly fewer crash numbers. We are unsure what is causing this, as our app did not go through any major releases. I have attached the crash log below. Thanks
Exception Type: EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Termination Reason: RUNNINGBOARD 0xd00d2bad
Hello,
I'm creating a pluggin fin javascript in an app called obsidian.
I'm using navigator.clipboard.read():
Everything work fine in MacOS for both text and images
on iOS it works for text but if the clipboard is an image the script just stop
Totally stuck, please help
I have registered and created passkey with credentials.create function in apple device with software 17.4.1 in Safari browser. When I clean the cache in safari and try to log in, it force me to register again and after that I had two passkeys on my device. It should be like this ? Why Safari is related to Passkeys ?
I'm not sure if I just missed a recent breaking change, but we are having an issue with the camera in our single page app on iOS 17.4.1 in Safari. We can open the camera and display it to the user using getUserMedia. However, if the path of the site changes at all (for example, the user clicks a button to opens a sidepanel which results in the path in the browser changing) the camera goes black, even if the video element is still being displayed.
I can see in the browser that the camera has stopped, and the user has to re-enable it manually by tapping "Start Using Camera".
Any idea's what could be going on here?
I am developing a web application that works on webview.
From iOS 13, users could set a specific language for each individual app, and every webview-based application knew the application language through navigator.language.
However, in iOS 17.4, this API returns the system language instead of the individual app's language in web applications.
Is this an official change in iOS 17.4 or a bug?
Good evening, I am having problems with my WebRTC application when an iPhone or Macbook is connected. This only happens when an iPhone or Macbook is connected, as tests with Windows or Android devices have shown no issues.
As can be seen in the screenshot below, it appears that the datachannel is not initialised correctly. In fact, the webcam and microphone do not work even if permissions are given by the user, and messages and the remote webcam are not sent/shown.
If I open chrome console on Windows, this is the error I get in the console
Could you please help me investigate this problem. If you want, you can have full access to my application at https://www.fourmeet.it. I attach the functions that seem to be responsible for the problems:
const configuration = {
iceServers: [...turnServers, { urls: 'stun:stun.1und1.de:3478'}],
iceTransportPolicy: 'relay'
};
peerConection = new RTCPeerConnection(configuration);
dataChannel = peerConection.createDataChannel("chat");
peerConection.ondatachannel = (event) => {
const dataChannel = event.channel;
dataChannel.onopen = () => {
console.log("peer connection is ready to receive data channel messages");
};
dataChannel.onmessage = (event) => {
console.log("message came from data channel");
const message = JSON.parse(event.data);
ui.appendMessage(message);
};
};
peerConection.onicecandidate = (event) => {
console.log("geeting ice candidates from stun server");
if (event.candidate) {
// send our ice candidates to other peer
wss.sendDataUsingWebRTCSignaling({
connectedUserSocketId: connectedUserDetails.socketId,
type: constants.webRTCSignaling.ICE_CANDIDATE,
candidate: event.candidate,
});
}
};
peerConection.onconnectionstatechange = (event) => {
if (peerConection.connectionState === "connected") {
console.log("succesfully connected with other peer");
}
};
const stringifiedMessage = JSON.stringify(message);
if (dataChannel && dataChannel.readyState === 'open') {
dataChannel.send(stringifiedMessage);
} else {
console.log('canale non aperto');
}
};
My Safari App Extension is having trouble with one website. This is typical for some other websites as well.
Navigating to that website results in 6 “Load” events. For each such event I send a “safari.extension.dispatchMessage” to my objC code.
For the first of these Load messages, my objC code sends a ‘sendMeIcons” message to “safari.self.addEventListener('message', function(event)”. The other 5 Load events are ignored by my objC code and do not send this message.
safari.self.addEventListener('message', function(event) receives sendMeIcons JUST once. Yet, the event handler for this message) is invoked 4 times. The first invocation is correct. The other 3 are spurious.
I have no idea why this is happening.
Here is my objC code
safari.self.addEventListener('message', function(event)
{
if (event.name === "Load My URL")
{
console.log('In event listener Load My URL');
...
return;
}
if (event.name === "sendMeIcons")
{
...
if (hrefs.length <1) //THIS IS ALWAYS TRUE FOR THIS TEST CASE.
{
safari.extension.dispatchMessage("js Found No Icons");
return;
}
else
{
...
safari.extension.dispatchMessage("IconsReturned",{"urls": arrayOfUrls});
return;
}
}
I don't have a clue how to proceed. Any suggestions.
We have a payment process in an app which involves loading up a Web page to allow a user to enter credit card details, and to complete a transaction. This web page may result in a 3D-Secure step up challenge. For PCI compliance purposes we launch this in a SFSafariViewController.
This 3D secure process involves a collection of redirects, with a final one back to us known as the "Merchant Page". In here, we want to do one more redirect, using a custom URL scheme, to allow the app to recognise that the process has completed, and can safely dismiss the SFSafariViewController.
In those cases where no "step up 3d challenge" occurs, the process works well, the final redirect occurs, and our app successfully dismisses the SFSafariViewController.
However, in a step up challenge, the Merchant Page loads, but any attempt to do the final custom redirect does not execute.
I believe this is a feature of Safari - What I think is going on is that enough time has passed since there was user interaction on the page, and the final redirect, which isn't a https or http link (it is a myapp:// link) simply gets ignored.
We've tried a lot of things. One thing works: If we provide a button, and when it is tapped, it sets window.location.href = 'myapp://success?', this works.
This is a clue to if it is cause by lack of user interaction.
We've tried lots of things:
Rather than a javascript redirect, we tried server side redirecting; we tried all of the HTTP 300 response codes. They were all ignored
We tried the meta refresh (which we know is kinda deprecated).
We tried window.location.href = , window.location.assign(), document.location.href, document.location.assig(), etc.
We tried issuing an Ajax XMLHttpRequest, but this failed because it isn't https or http
We even tried to suggest our non-standard URL was the source of a script, just to trigger it but it didn't work.
We've tried calling in during body onload
We've tried calling it using a timeout in case timing was relevant.
My gut feeling here is this is a feature. I've used Safari Debugging, and it literally steps over the window.location.href assignment, and doesn't produce a warning or an error. We've added try/catch, and no exception was thrown. Again, it leads me to believe this is all by design (perhaps to prevent ad fraud or something?).
I was kinda hoping that in the response, we'd be able to specify a CORS header that tells the browser that "it will be ok to use resources from myapp://", but haven't found the right one.
We may end up having to simply produce a button with a message "Your transaction has completed, please press here to dismiss", but it is terrible UX that is unnecessary.
I've seen a number of posts elsewhere suggesting that redirects without user interaction can be considered suspicious, and I've experience of this same problem on another browser.
If anyone has cracked this one, I'd love to know how
I have a wind map web application developed using HTML canvas 2D. However, after iOS 16.X (I'm not sure of the exact version), the streamlines have changed and now appear as below. They no longer disappear as they did previously.
This issue is not limited to a specific browser.
Before:
After:
I've been using Apple Script below for gathering every title & url of opening tab from browser window.
It's been works fine for a few years but it's failed recently (maybe in last two weeks).
#!/usr/bin/env osascript -l JavaScript
// url.js
function run(arg) {
arg = arg.toString()
let browser = ''
switch(arg) {
case 'chrome':
browser = 'Google Chrome'
break;
case 'edge':
browser = "Microsoft Edge"
break;
default:
browser = 'Google Chrome'
break;
}
Application(browser).windows().forEach((window) => {
console.log('\n\n')
window.tabs().forEach((tab) => {
const url = tab.url()
const name = tab.name()
console.log(`${name}\t${url}`)
})
})
}
It's been works like below (imagine that you open https://example.com on edge)
$ url.js edge
example.com https://example.com
But I found it failed today.
$ url.js edge
execution error: Error: Error: Application isn't running. (-600)
of course I'm make sure Edge browser up and running. Same error for Chrome.
I keep my environments(os, browser etc) up-to-date but I don't know which updates affects here.
Any thoughts or helps are welcome.
Settings
MacBook Pro M2
Sonoma 14.2.1
Edge 122
Chrome 122
I’m deploying a pac file through jamf using the auto global http proxy. The purpose of this file is to block some traffic on the network level. We’re deploying the pac on iPhones.
I tried to use
|| shExpMatch(url, “*.pdf”)
to block any url with .pdf but iOS seems to just skip that line without implementing it. Am I doing something wrong or is there an apple specific function that I should use?
thanks