WebKit JS

RSS for tag

Access and modify DOM elements within a webpage, including touch events and visual effects, using WebKit JS.

WebKit JS Documentation

Posts under WebKit JS tag

49 Posts
Sort by:
Post not yet marked as solved
9 Replies
5.5k Views
Hi, I am trying out push notification for IOS 16.4 beta Simulator using Xcode 14.3 beta (14E5197f). Inside my JS code I have the following: Notification.requestPermission((permission) => { console.log(permission); }).catch((error) => { deviceNotSupported(); }); } Unfortunately "permission" always returns "denied". Please kindly assist
Posted
by lukel2023.
Last updated
.
Post not yet marked as solved
1 Replies
1.1k Views
I ran a series of CPU-intensive tests, with code written in JavaScript on my iPad. I can execute the JavaScript code using either JavaScriptCore, or by using a WkWebView and making it load and execute the JavaScript. I found that JavaScriptCore is 12 to 15 times slower than WKWebView (18.3 s instead of 1.1 s). That seems huge. Is there any way to speed it up? Is there any reason why it's so slow? While we're at it, are there differences between the WebAssembly engine in JavaScriptCore and the one in WkWebView?
Posted Last updated
.
Post not yet marked as solved
4 Replies
985 Views
I need to prepare an object when the user navigates to a new page in WKWebView and refresh UI. I run a WKUserScript on behalf of the user to do this. I'm using the readystatechange event listener to detect initial page load. I'm also listening to the visibilitychange event to refresh UI if the DOM is already loaded on a "Go back" or "Go Forward" action. document.addEventListener('visibilitychange', () => { //do whatever if the DOM is already loaded and if we are visible. }); document.addEventListener('readystatechange', (event) => { //do whatever when page is loaded }); On certain websites however I noticed that neither of these events are being fired when I navigate -goForward: and -goBack: I'm not sure why. My WKUserScript is in WKContentWorld.defaultClientWorld so it shouldn't be interfering with the javascript of the page. Is there another JS event I'm missing? I could pick up the changed URL on the native code side but it would be nice to keep this all contained within the WKUserScript as this UI is for the "webview" and the native code shouldn't have to be bothered with having to patch in the additional glue. Is there another DOM event I need to listen to? I tried listening to window's pageshow but that didn't work. Also experimented a bit with the window's popstate event but no luck.
Posted Last updated
.
Post not yet marked as solved
0 Replies
496 Views
For many mid and large-size iOS apps, startup time is delayed by 100+ milliseconds due to 1 or more WKWebViews being created. This is usually due to 0-1 WKWebViews being created by first-party code and 1 or more different SDKs each creating their own WKWebView (IIRC for them to use a JS VM). Although SDK providers may not be willing (or able) to defer the creation of these WKWebViews past startup, I'm hopeful that there are still some ways to improve WKWebView creation time, and that I can share those ideas with them. Note that much of the time spent under the hood for WKWebView initialization seems to be on process pool creation and management. My ideas so far are: Defer WKWebView creation. This is an obvious one, but I generally want to look past it because SDKs are often unwilling to defer work like that and because it's going to cause frame drops whenever it does get loaded, even if not at startup. Use a shared WKProcessPool. Many companies wouldn't care all that much about sharing the same process space, so this would be a nice win Create the WKProcessPool or the WKWebViewConfiguration on a background thread (is this even safe to do?) Use some sort of lower-level API to run a JS VM, e.g. through WebKit2 directly, if such a public and stable API exists. Use JavaScriptCore. However, for reasons I can't recall, I believe this was a non-starter. It may have been JavaScriptCore's far slower performance, or the need to render actual web content. What are people's thoughts on these ideas? Does anyone have any other ideas?
Posted
by meiselsc.
Last updated
.
Post not yet marked as solved
1 Replies
1.6k Views
I am creating a react app and am making use of Webauthn to use TouchID or FaceID for user authentication. I have built my app so that when the button is clicked, navigator.credentials.create is the only call made. With attestation set to none, there are no issues however as soon as I set attestation to direct I get an alert saying 'The operation can't be completed' and 'NotAllowedError: This request has been cancelled by the user.' is logged to console. The issue only presents itself on Safari and iOS devices however works perfectly on other browsers like Chrome. Has anyone encountered a similar issue and possibly know how to resolve it? Thanks Shay
Posted
by shay_.
Last updated
.
Post not yet marked as solved
0 Replies
805 Views
I'd like to add some image to clipboard from my web browser(Chrome, Safari) on iPhone. For example: I have canvas element with some picture. I get from the canvas element Blob type of data Create "ClipboardItem" with correct type and data Add to ClipboardItem to clipboard using write And on the MacBook, Windows laptops, Android devices, in chrome all correct work, but on iPhones nope (( Help me please, my code example here 👇🏻 canvasEl.toBlob((blob) => { if (!blob) return; navigator.clipboard.write([ new ClipboardItem({ "image/png": new Promise(async (resolve) => { resolve(new Blob([blob!], { type: "image/png" })); }), }), ]); });
Posted Last updated
.