WebKit JS

RSS for tag

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

Posts under WebKit JS tag

200 Posts

Post

Replies

Boosts

Views

Activity

Script not able to modify window location within WebView on iOS 15.5+
Hi team, I'm troubleshooting some weird authentication issues within my website where I offer Signin with Apple option. Basically, after the user does Apple login, I have this script to update the location URI of the window opener back to my origin domain. But this line of the script is working correctly when login is launched in a browser such as Safari or Chrome, and it just got ignored when launched from a WebView within an application, and it can only be reproduced since iOS 15.5+. Here is some more context for comparison: Request from Safari: POST /callbackApple HTTP/1.1 Host: signin.example.com Content-Type: application/x-www-form-urlencoded Origin: https://appleid.apple.com Accept-Encoding: gzip, deflate, br Cookie: _ga=GA1.3.1679051778.1669664368; _gat=1; _gid=GA1.3.1808016405.1669664368; signin-cookie="5ce93a47904daa5e"; _abck=F930E04300E8E8AB552C14541A40AD3C~0~YAAQmZTYF7CO3fCBAQAAZkOmHQha0qNYdbsfcZ4zEtwsjoRST+T+DNTMb5+E9uL8OvEL3YA0K0Tn7xS+OKoGPGib5rmpBOZVQq1+XoPEFJOij8Ao8mMKrvztGMN0HgNBmldcy3BCpTLgWFgckVzF/MOLhHL87yVOhCnsKqJEG8WwuH9I1G6xb2k4R6CfX9qzCfh9pexN2KBbE/FW7KtrP5KkRq2Y2a6AlQA3hr068J426LBkRAiHhj7mrAjIZHPXVlAq9PLKSO/LOxvovAbh6bOUP6EZHk1De4IvPU5DqwdA2yQMtyrz/K+MHE5NA0oaLTjhiSmTNUFOckcmQAl+9PRuXYpgVa5UukkSztNLlbn4xOi2ZvZ4B0jtSg57AeXsl56j36NSCmBqioEdA7N54V3IiwOz~-1~-1~-1 Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 Safari/604.1 Referer: https://appleid.apple.com/ Content-Length: 1293 Accept-Language: en-US,en;q=0.9 Same request sent from WebView in another App POST /callbackApple HTTP/1.1 Host: signin.example.com Content-Type: application/x-www-form-urlencoded Origin: https://appleid.apple.com Accept-Encoding: gzip, deflate, br Cookie: ga=GA1.3.439982965.1669661343; _gat=1; _gid=GA1.3.712268364.1669661343; signin-cookie="39fd5b51e0350b24" Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 Safari/604.1 Referer: https://appleid.apple.com/ Content-Length: 1448 Accept-Language: en-US,en;q=0.9 And the response to the requests above is always the same, a blank HTML page as shown below with some scripts to update the opener and redirect user back to my website. Note that the script self.close() always works, but window.opener.location.replace(redirectUri) only works when it's inside of Safari or Chrome browser but not in Webview opened by some other application. Response body content: ... <script type="text/javascript"> var redirectUri = 'https://example.com'; redirectUri = redirectUri + "access_token=" + "${accessToken?no_esc}" + "&token_type=apple"; [#if nickName??] redirectUri = redirectUri + "&nickName=" + "${nickName?no_esc}"; [/#if] redirectUri = redirectUri + "&_eventId=loginFromApple" + "&execution=" + "${execution?no_esc}"; if ( window.opener ) { window.opener.location.replace(redirectUri); self.close(); } </script> ... I'm not sure could it be related to some security update within Webkit https://support.apple.com/en-us/HT213412 but we started to see this issue after the iOS version mentioned in the post. Any help would be much appreciated, thanks.
0
0
2.6k
Nov ’22
Extract images loaded in a WKWebView
Related: https://developer.apple.com/forums/thread/47176 Hey all, I have a WKWebView running in the background of a SwiftUI app which loads webpages that have images in them: <img src="…" /> and would like to extract those image data from the WKWebView for using in my SwiftUI app. The app is supposed to run on iOS and macOS (sandboxed). I have a working solution of this, where I use WKWebView's evaluateJavaScript() to get the URL in the src attribute of the img-tag and then download that url in Swift to a Data object for further processing. While this solution works, it requires fetching the image a second time, which at best adds network load and at worst returns a different image. There is the option of re-rendering the img element to a canvas, extracting the ImageData from there using Javascript, and returning the blob to Swift. According to SO, rendering an img element to a canvas can disturb the image and this seems like an unstable workaround at best, so I have been looking for alternatives of directly getting the image from WKWebView. Are any of the following ideas feasible to extract image data from a WKWebView? Cache: Use WKWebsiteDataStore to fetch a WKWWebsiteDataRecord including the cached images (see here). Or could the image be showing on the WKWebView but not be saved in cache? Webarchive: Create a webarchive of the WKWebView (see here) and extract the image from there. Is there any documentation on parsing .webarchive files? Intercept network requests and responses: When using Safari web inspector's Network monitor, I can see all network requests and responses (including images). However, when using WKNavigationDelegate's method for intercepting WKNavigationActions (see here), I do not see image requests. Is there a way to see all network requests of a WKWebView including requests that load images into an img-element? Thank you! Cheers, Anton
0
2
1.7k
Oct ’22
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable returns false in iOS 15.4+
I have a mobile app which is uses Web authentication PublickKeyCredential api provided by WebKit to authenticate users and use oauth token from the response to login to the app. Since iOS 15.4 released this following snippet is returning false window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable Please provide a workaround or let me know when this will get fix in WebKit
1
0
1.3k
Oct ’22
Segmentation fault 11 when implementing WKScriptMessageHandlerWithReply
Hi, I'm trying to implement the async handler of WKScriptMessageHandlerWithReply -> see yellow box in this reference. This is the method signature: func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?) But I end up with a Segmentation fault: 11 compilation error. I'm compiling with Xcode 13.4.1 (13F100). Did anybody successfully use this API or now a solution to fix it?
1
0
1.5k
Oct ’22
Using WKScriptMessageHandler to receive sensitive data
My MacOS application has a webview and I've been subclassing WKScriptMessageHandler to handle several messages received from the javascript code. For a new feature I would like to save user's password in the Keychain, to do so I need to send the password from the Javascript to the Swift codebase. The javascript code would be something like this: window.webkit.messageHandlers.loginData.postMessage({username: 'john', password: 'p@ss!123'}) Before implementing this approach I would like to know if there are any security vulnerabilities that I should know about. The sensitive data is being sent from the Javascript to the Swift code, so I wonder if it would be possible for someone to intercept it or getting the sensitive data somehow.
0
0
973
Oct ’22
WKWebView JS Execution in test target
My team has a set of XCTestCases which create a new instance of WKWebView, execute some javascript with it, then assert some conditions afterward. Beginning with iOS 16, these tests never succeed because it seems like the WKWebView is experiencing some sort of crash or malfunction in its content process. When executing a single test of the type above, the following is present in the console: [Process] 0x142481000 - [PID=0] WebProcessProxy::didFinishLaunching: Invalid connection identifier (web process failed to launch) [Process] 0x142481000 - [PID=0] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash [Process] 0x7f7d86008220 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::processDidTerminate: (pid 0), reason=Crash [Loading] 0x7f7d86008220 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::dispatchProcessDidTerminate: reason=Crash [Loading] 0x7f7d86008220 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::dispatchProcessDidTerminate: Not eagerly reloading the view because it is not currently visible I've tried ensuring that an app host is present for the test target these tests execute in and that had no effect. I've tried adding the webview to the apps view hierarchy and that had no effect. In iOS 15 and prior these same tests execute and pass fine. Was there some change in iOS 16 that may have caused this or any ideas on how to rectify this?
3
3
1.9k
Sep ’22
Safari 15 prompts the beforeunload alert, but does not block navigation
Using the example provided by MDN, the beforeunload event is working in my Safari browser: const beforeUnloadListener = (event) => { event.preventDefault(); return event.returnValue = "Are you sure you want to exit?"; }; addEventListener('beforeunload', beforeUnloadListener, { capture: true }); (I first must click into the window to make sure the browser detects interaction.) if I close the browser window, the alert blocks the window from being closed If I navigate to another page, the alert is shown However, when I navigate to another page, the alert does not block navigation. I am taken to the new page with the alert still being displayed. The alert is then "useless" in the sense that pressing the affirmative or negative buttons dismisses the alert, but has no other effect. This is not the expected behavior in Chrome or Firefox. In these, the page will not navigate or cancel navigation until an alert option is clicked. Is there any work-around? It seems it would be better to not show the alert at all than to show the alert while asynchronously unloading the current page and loading another page. I need to use this event to inform a user they may want to save changes to a document before leaving the page. This was the original use case for beforeunload.
4
1
4.7k
Sep ’22
M1 M2 webgl.ALIASED_POINT_SIZE_RANGE
I'm currently using gl.points to render sprites (lens flares, explosions, etc) looks like M1 / M2 hardware (ipad, macbook pro) limits the point size to 64. Every other device has minimum of 512, usually 1024, and many even provide 2048. wondering if this is a was a choice or oversight? Also, not sure where to file this type of bug/request as its specific to M1/M2 hardware that affects multiple devices? many thanks, -Dm
1
0
1.1k
Sep ’22
problem of application execution speed
We've created an webview style hybrid app, using framework based on PHP Compared to Android, it takes twice as much time to load the app on the iphone We've packaged the app using wk webview which based on Safari. Is there any issue that we can check in order to solve such slow running problem on iphone? Best regards, Son Seung Hee ICT Department, Apartners Co.
0
0
766
Sep ’22
music webkit MusicKit.getInstance(); return undefined
we need to play songs auto play but const music = MusicKit.getInstance(); return undefined try { MusicKit.configure({ developerToken: DEVELOPER_TOKEN, app: { name: 'ReflexRadioDev', build: '1978.4.1', }, }); } catch (err) { console.log("my : " + err); } // MusicKit instance is available const music = MusicKit.getInstance(); console.log(music); we use version 3 from apple music kit "https://js-cdn.music.apple.com/musickit/v3/musickit.js" browser console error :- Uncaught (in promise) TypeError: music is undefined https://dev2.api.app.reflex-radio.com/index.html:78 dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 setTimeout handler*dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1 index.html:78:7 https://dev2.api.app.reflex-radio.com/index.html:185 dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 (Async: setTimeout handler) dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1
1
0
821
Jul ’22
WKWebview insdie UITableviewcell with dynamic height
Hello, I have used WKWebview inside my tableview cell and given constraint inside my xib file. I am loading html text in webview which i get from server side in api and i have taken webview height constraint property for update height on did finish delegate method. It's not working proper and not giving proper height and on scroll every-time it's rendering with different height. My requirement is i want to display math equations and html content on webview with dynamic height of cell. I have done research and tried everything but it's not working. I am using below code for update webview height. func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {     webView.evaluateJavaScript("document.readyState", completionHandler: { (ready, error) in       if ready != nil {         DispatchQueue.main.asyncAfter(deadline: .now()) {           webView.evaluateJavaScript("document.body.scrollHeight") { [weak self] (result, _) in             guard let self = self, let result = result as? Double else { return }             self.webViewHeightConstraint.constant = CGFloat(result)             self.webView.updateConstraints()            }         }       }     })   }     Please help me to solve this issue. Thank you
0
0
1.6k
Jul ’22
[bug] iPad Safari fullscreen error when triggered following a pointerdown event
When triggering a webkitRequestFullscreen event in response to a pointerdown event, the result is a fullscreen error. Using a pointerup event instead of pointerdown works fine. I'm using a <button> element to receive the event and in the event listener callback I'm attempting to call webkitRequestFullscreen() on a div. Is this expected behavior? note: this was observed using MacOS Simulator: iPad 9th Generation - iOS 15.4
0
0
987
Jun ’22
My account seems to be registered under a apple business management account... and it seems the MDM is preventing me from having ful access of my original Apple ID (“the user you entered is invalid”) ... spoke with a apple representative last week
The original Apple ID according to the representative is still “active” however she did hang up in my face when she used my Government name and that name wasn’t initially registered to the original Apple ID.. anyways the restrictions that correspond with a MDM from an apple business management account on my iPhone also the analytics and improvements keep showing activity of another device having access or “remote” capabilities. I copied this portion of some crash reports from the analytics data Heaviest stack for the target process: 10 ??? (libsystempthread.dylib + 6976) [0x1e79aab40] 10 ??? (QuartzCore + 1891396) [0x1a1a14c44] 7 ??? (QuartzCore + 1833980) [0x1a1a06bfc] 7 ??? (CoreFoundation + 635644) [0x19e50a2fc] 7 ??? (CoreFoundation + 631324) [0x19e50921c] 7 ??? (CoreFoundation + 635020) [0x19e50a08c] 7 ??? (CoreFoundation + 660344) [0x19e510378] 7 ??? (CoreFoundation + 663528) [0x19e510fe8] 7 ??? (CoreFoundation + 511440) [0x19e4ebdd0] 7 ??? (QuartzCore + 971636) [0x1a1934374] 7 ??? (QuartzCore + 1833040) [0x1a1a06850] 3 ??? (QuartzCore + 1774248) [0x1a19f82a8] 3 ??? (QuartzCore + 2141416) [0x1a1a51ce8] 2 ??? (QuartzCore + 1043980) [0x1a1945e0c] 2 ??? (Metal + 702968) [0x1b42c39f8] 2 ??? (libdispatch.dylib + 75840) [0x19e197840] 2 ??? (libdispatch.dylib + 15792) [0x19e188db0] 2 ??? (Metal + 703044) [0x1b42c3a44] 2 ??? (Metal + 701656) [0x1b42c34d8] 2 ??? (IOGPU + 23412) [0x1da745b74] 2 ??? (IOGPU + 24252) [0x1da745ebc] 2 ??? (IOGPU + 71780) [0x1da751864] 2 ??? (IOKit + 33612) [0x1a929734c] 2 ??? (IOKit + 531692) [0x1a9310cec] 2 ??? (libsystemkernel.dylib + 17104) [0x1cb46f2d0] Also here’s a log of some activity from a MDMiosagent. If anyone had any answers as to how to remove my account from a MDM (unenroll). My device was added to a management account without my consent or authorization.. and this “crime” needs to be reported immediately. I’ll post that on another question bold
2
0
2.2k
Jun ’22
Memory leak occurs when using WKWebView in swiftui
When I learned to use webview in my app, just added a webview and detected a memory leak, import SwiftUI import WebKit struct SWKWebView: UIViewRepresentable { @Binding var url: String? func makeUIView(context: Context) -> WKWebView { let webview = WKWebView() webview.navigationDelegate = context.coordinator return webview } func updateUIView(_ uiView: WKWebView, context: Context) { if let url = url, let requetURL = URL(string: url) { uiView.load(URLRequest(url: requetURL)) } } func makeCoordinator() -> Coordinator { Coordinator() } class Coordinator: NSObject,WKNavigationDelegate { func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { webView.evaluateJavaScript("document.title") { (result, error) in print("didFinish:\(String(describing: result ?? ""))") } } } } struct TTTest: View { @State var url: String? = "https://www.google.com" var body: some View { SWKW ![]("https://developer.apple.com/forums/content/attachment/d4b6a729-f217-4b1a-9ec4-1372643e14b4" "title=WeChatc57286e9fa2eb9bc5d59b7410d876c33.png;width=1788;height=660") ebView(url: $url) } }
0
1
1.7k
May ’22
WKWebview websocket compression is broken
I have the websocket server which enables permessage-deflate to compress massive data. The problem is when I try to use it in webview, the connection was closed. I learned from other discussion that it can be solved by disabling Setting safari =>Advanced=>Experimental Features=>NSURLSession WebSocket, but only for Safari. How can I solve the problem in WKWebview? Or when will the problem be solved?
0
0
912
May ’22
I there a way to disable audioSession for particular website?
I want to disable a widget Now playing for a specific website. Can this be done with an injected script or with the standard macOS libraries?
Replies
0
Boosts
0
Views
862
Activity
Dec ’22
Script not able to modify window location within WebView on iOS 15.5+
Hi team, I'm troubleshooting some weird authentication issues within my website where I offer Signin with Apple option. Basically, after the user does Apple login, I have this script to update the location URI of the window opener back to my origin domain. But this line of the script is working correctly when login is launched in a browser such as Safari or Chrome, and it just got ignored when launched from a WebView within an application, and it can only be reproduced since iOS 15.5+. Here is some more context for comparison: Request from Safari: POST /callbackApple HTTP/1.1 Host: signin.example.com Content-Type: application/x-www-form-urlencoded Origin: https://appleid.apple.com Accept-Encoding: gzip, deflate, br Cookie: _ga=GA1.3.1679051778.1669664368; _gat=1; _gid=GA1.3.1808016405.1669664368; signin-cookie="5ce93a47904daa5e"; _abck=F930E04300E8E8AB552C14541A40AD3C~0~YAAQmZTYF7CO3fCBAQAAZkOmHQha0qNYdbsfcZ4zEtwsjoRST+T+DNTMb5+E9uL8OvEL3YA0K0Tn7xS+OKoGPGib5rmpBOZVQq1+XoPEFJOij8Ao8mMKrvztGMN0HgNBmldcy3BCpTLgWFgckVzF/MOLhHL87yVOhCnsKqJEG8WwuH9I1G6xb2k4R6CfX9qzCfh9pexN2KBbE/FW7KtrP5KkRq2Y2a6AlQA3hr068J426LBkRAiHhj7mrAjIZHPXVlAq9PLKSO/LOxvovAbh6bOUP6EZHk1De4IvPU5DqwdA2yQMtyrz/K+MHE5NA0oaLTjhiSmTNUFOckcmQAl+9PRuXYpgVa5UukkSztNLlbn4xOi2ZvZ4B0jtSg57AeXsl56j36NSCmBqioEdA7N54V3IiwOz~-1~-1~-1 Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 Safari/604.1 Referer: https://appleid.apple.com/ Content-Length: 1293 Accept-Language: en-US,en;q=0.9 Same request sent from WebView in another App POST /callbackApple HTTP/1.1 Host: signin.example.com Content-Type: application/x-www-form-urlencoded Origin: https://appleid.apple.com Accept-Encoding: gzip, deflate, br Cookie: ga=GA1.3.439982965.1669661343; _gat=1; _gid=GA1.3.712268364.1669661343; signin-cookie="39fd5b51e0350b24" Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 16_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Mobile/15E148 Safari/604.1 Referer: https://appleid.apple.com/ Content-Length: 1448 Accept-Language: en-US,en;q=0.9 And the response to the requests above is always the same, a blank HTML page as shown below with some scripts to update the opener and redirect user back to my website. Note that the script self.close() always works, but window.opener.location.replace(redirectUri) only works when it's inside of Safari or Chrome browser but not in Webview opened by some other application. Response body content: ... <script type="text/javascript"> var redirectUri = 'https://example.com'; redirectUri = redirectUri + "access_token=" + "${accessToken?no_esc}" + "&token_type=apple"; [#if nickName??] redirectUri = redirectUri + "&nickName=" + "${nickName?no_esc}"; [/#if] redirectUri = redirectUri + "&_eventId=loginFromApple" + "&execution=" + "${execution?no_esc}"; if ( window.opener ) { window.opener.location.replace(redirectUri); self.close(); } </script> ... I'm not sure could it be related to some security update within Webkit https://support.apple.com/en-us/HT213412 but we started to see this issue after the iOS version mentioned in the post. Any help would be much appreciated, thanks.
Replies
0
Boosts
0
Views
2.6k
Activity
Nov ’22
Extract images loaded in a WKWebView
Related: https://developer.apple.com/forums/thread/47176 Hey all, I have a WKWebView running in the background of a SwiftUI app which loads webpages that have images in them: <img src="…" /> and would like to extract those image data from the WKWebView for using in my SwiftUI app. The app is supposed to run on iOS and macOS (sandboxed). I have a working solution of this, where I use WKWebView's evaluateJavaScript() to get the URL in the src attribute of the img-tag and then download that url in Swift to a Data object for further processing. While this solution works, it requires fetching the image a second time, which at best adds network load and at worst returns a different image. There is the option of re-rendering the img element to a canvas, extracting the ImageData from there using Javascript, and returning the blob to Swift. According to SO, rendering an img element to a canvas can disturb the image and this seems like an unstable workaround at best, so I have been looking for alternatives of directly getting the image from WKWebView. Are any of the following ideas feasible to extract image data from a WKWebView? Cache: Use WKWebsiteDataStore to fetch a WKWWebsiteDataRecord including the cached images (see here). Or could the image be showing on the WKWebView but not be saved in cache? Webarchive: Create a webarchive of the WKWebView (see here) and extract the image from there. Is there any documentation on parsing .webarchive files? Intercept network requests and responses: When using Safari web inspector's Network monitor, I can see all network requests and responses (including images). However, when using WKNavigationDelegate's method for intercepting WKNavigationActions (see here), I do not see image requests. Is there a way to see all network requests of a WKWebView including requests that load images into an img-element? Thank you! Cheers, Anton
Replies
0
Boosts
2
Views
1.7k
Activity
Oct ’22
JavascriptCore
let req_url = new URL('http://xxxxxx') Javascript execution is interrupted when creating an address via new URL in JavascriptCore
Replies
0
Boosts
0
Views
702
Activity
Oct ’22
window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable returns false in iOS 15.4+
I have a mobile app which is uses Web authentication PublickKeyCredential api provided by WebKit to authenticate users and use oauth token from the response to login to the app. Since iOS 15.4 released this following snippet is returning false window.PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable Please provide a workaround or let me know when this will get fix in WebKit
Replies
1
Boosts
0
Views
1.3k
Activity
Oct ’22
Segmentation fault 11 when implementing WKScriptMessageHandlerWithReply
Hi, I'm trying to implement the async handler of WKScriptMessageHandlerWithReply -> see yellow box in this reference. This is the method signature: func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) async -> (Any?, String?) But I end up with a Segmentation fault: 11 compilation error. I'm compiling with Xcode 13.4.1 (13F100). Did anybody successfully use this API or now a solution to fix it?
Replies
1
Boosts
0
Views
1.5k
Activity
Oct ’22
Using WKScriptMessageHandler to receive sensitive data
My MacOS application has a webview and I've been subclassing WKScriptMessageHandler to handle several messages received from the javascript code. For a new feature I would like to save user's password in the Keychain, to do so I need to send the password from the Javascript to the Swift codebase. The javascript code would be something like this: window.webkit.messageHandlers.loginData.postMessage({username: 'john', password: 'p@ss!123'}) Before implementing this approach I would like to know if there are any security vulnerabilities that I should know about. The sensitive data is being sent from the Javascript to the Swift code, so I wonder if it would be possible for someone to intercept it or getting the sensitive data somehow.
Replies
0
Boosts
0
Views
973
Activity
Oct ’22
WKWebView JS Execution in test target
My team has a set of XCTestCases which create a new instance of WKWebView, execute some javascript with it, then assert some conditions afterward. Beginning with iOS 16, these tests never succeed because it seems like the WKWebView is experiencing some sort of crash or malfunction in its content process. When executing a single test of the type above, the following is present in the console: [Process] 0x142481000 - [PID=0] WebProcessProxy::didFinishLaunching: Invalid connection identifier (web process failed to launch) [Process] 0x142481000 - [PID=0] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash [Process] 0x7f7d86008220 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::processDidTerminate: (pid 0), reason=Crash [Loading] 0x7f7d86008220 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::dispatchProcessDidTerminate: reason=Crash [Loading] 0x7f7d86008220 - [pageProxyID=6, webPageID=7, PID=0] WebPageProxy::dispatchProcessDidTerminate: Not eagerly reloading the view because it is not currently visible I've tried ensuring that an app host is present for the test target these tests execute in and that had no effect. I've tried adding the webview to the apps view hierarchy and that had no effect. In iOS 15 and prior these same tests execute and pass fine. Was there some change in iOS 16 that may have caused this or any ideas on how to rectify this?
Replies
3
Boosts
3
Views
1.9k
Activity
Sep ’22
Disable iOS safari three-finger tap menu
I'm creating a web-based game that has multi-touch support -- users will frequently be using three-fingers (or more) to interact with it. There is no editable text on the page. Is there any way to disable the three-finger tap menu that appears (with cut/paste and undo) in iOS safari? It is pretty distracting and does not provide any value to the user.
Replies
0
Boosts
0
Views
1.5k
Activity
Sep ’22
Safari 15 prompts the beforeunload alert, but does not block navigation
Using the example provided by MDN, the beforeunload event is working in my Safari browser: const beforeUnloadListener = (event) => { event.preventDefault(); return event.returnValue = "Are you sure you want to exit?"; }; addEventListener('beforeunload', beforeUnloadListener, { capture: true }); (I first must click into the window to make sure the browser detects interaction.) if I close the browser window, the alert blocks the window from being closed If I navigate to another page, the alert is shown However, when I navigate to another page, the alert does not block navigation. I am taken to the new page with the alert still being displayed. The alert is then "useless" in the sense that pressing the affirmative or negative buttons dismisses the alert, but has no other effect. This is not the expected behavior in Chrome or Firefox. In these, the page will not navigate or cancel navigation until an alert option is clicked. Is there any work-around? It seems it would be better to not show the alert at all than to show the alert while asynchronously unloading the current page and loading another page. I need to use this event to inform a user they may want to save changes to a document before leaving the page. This was the original use case for beforeunload.
Replies
4
Boosts
1
Views
4.7k
Activity
Sep ’22
M1 M2 webgl.ALIASED_POINT_SIZE_RANGE
I'm currently using gl.points to render sprites (lens flares, explosions, etc) looks like M1 / M2 hardware (ipad, macbook pro) limits the point size to 64. Every other device has minimum of 512, usually 1024, and many even provide 2048. wondering if this is a was a choice or oversight? Also, not sure where to file this type of bug/request as its specific to M1/M2 hardware that affects multiple devices? many thanks, -Dm
Replies
1
Boosts
0
Views
1.1k
Activity
Sep ’22
problem of application execution speed
We've created an webview style hybrid app, using framework based on PHP Compared to Android, it takes twice as much time to load the app on the iphone We've packaged the app using wk webview which based on Safari. Is there any issue that we can check in order to solve such slow running problem on iphone? Best regards, Son Seung Hee ICT Department, Apartners Co.
Replies
0
Boosts
0
Views
766
Activity
Sep ’22
music webkit MusicKit.getInstance(); return undefined
we need to play songs auto play but const music = MusicKit.getInstance(); return undefined try { MusicKit.configure({ developerToken: DEVELOPER_TOKEN, app: { name: 'ReflexRadioDev', build: '1978.4.1', }, }); } catch (err) { console.log("my : " + err); } // MusicKit instance is available const music = MusicKit.getInstance(); console.log(music); we use version 3 from apple music kit "https://js-cdn.music.apple.com/musickit/v3/musickit.js" browser console error :- Uncaught (in promise) TypeError: music is undefined https://dev2.api.app.reflex-radio.com/index.html:78 dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 setTimeout handler*dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1 index.html:78:7 https://dev2.api.app.reflex-radio.com/index.html:185 dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 (Async: setTimeout handler) dispatchDocumentEvent https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:44 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1 https://js-cdn.music.apple.com/musickit/v3/musickit.js:1
Replies
1
Boosts
0
Views
821
Activity
Jul ’22
WKWebview insdie UITableviewcell with dynamic height
Hello, I have used WKWebview inside my tableview cell and given constraint inside my xib file. I am loading html text in webview which i get from server side in api and i have taken webview height constraint property for update height on did finish delegate method. It's not working proper and not giving proper height and on scroll every-time it's rendering with different height. My requirement is i want to display math equations and html content on webview with dynamic height of cell. I have done research and tried everything but it's not working. I am using below code for update webview height. func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {     webView.evaluateJavaScript("document.readyState", completionHandler: { (ready, error) in       if ready != nil {         DispatchQueue.main.asyncAfter(deadline: .now()) {           webView.evaluateJavaScript("document.body.scrollHeight") { [weak self] (result, _) in             guard let self = self, let result = result as? Double else { return }             self.webViewHeightConstraint.constant = CGFloat(result)             self.webView.updateConstraints()            }         }       }     })   }     Please help me to solve this issue. Thank you
Replies
0
Boosts
0
Views
1.6k
Activity
Jul ’22
[bug] iPad Safari fullscreen error when triggered following a pointerdown event
When triggering a webkitRequestFullscreen event in response to a pointerdown event, the result is a fullscreen error. Using a pointerup event instead of pointerdown works fine. I'm using a <button> element to receive the event and in the event listener callback I'm attempting to call webkitRequestFullscreen() on a div. Is this expected behavior? note: this was observed using MacOS Simulator: iPad 9th Generation - iOS 15.4
Replies
0
Boosts
0
Views
987
Activity
Jun ’22
WKWebView javascript execution when app is in background
hello. Switch the app to background when loading a webpage in webview, webpage's JavaScript will stop working. Resume the app webpage fails to load and the screen is not drawn. Any solution?
Replies
0
Boosts
0
Views
698
Activity
Jun ’22
My account seems to be registered under a apple business management account... and it seems the MDM is preventing me from having ful access of my original Apple ID (“the user you entered is invalid”) ... spoke with a apple representative last week
The original Apple ID according to the representative is still “active” however she did hang up in my face when she used my Government name and that name wasn’t initially registered to the original Apple ID.. anyways the restrictions that correspond with a MDM from an apple business management account on my iPhone also the analytics and improvements keep showing activity of another device having access or “remote” capabilities. I copied this portion of some crash reports from the analytics data Heaviest stack for the target process: 10 ??? (libsystempthread.dylib + 6976) [0x1e79aab40] 10 ??? (QuartzCore + 1891396) [0x1a1a14c44] 7 ??? (QuartzCore + 1833980) [0x1a1a06bfc] 7 ??? (CoreFoundation + 635644) [0x19e50a2fc] 7 ??? (CoreFoundation + 631324) [0x19e50921c] 7 ??? (CoreFoundation + 635020) [0x19e50a08c] 7 ??? (CoreFoundation + 660344) [0x19e510378] 7 ??? (CoreFoundation + 663528) [0x19e510fe8] 7 ??? (CoreFoundation + 511440) [0x19e4ebdd0] 7 ??? (QuartzCore + 971636) [0x1a1934374] 7 ??? (QuartzCore + 1833040) [0x1a1a06850] 3 ??? (QuartzCore + 1774248) [0x1a19f82a8] 3 ??? (QuartzCore + 2141416) [0x1a1a51ce8] 2 ??? (QuartzCore + 1043980) [0x1a1945e0c] 2 ??? (Metal + 702968) [0x1b42c39f8] 2 ??? (libdispatch.dylib + 75840) [0x19e197840] 2 ??? (libdispatch.dylib + 15792) [0x19e188db0] 2 ??? (Metal + 703044) [0x1b42c3a44] 2 ??? (Metal + 701656) [0x1b42c34d8] 2 ??? (IOGPU + 23412) [0x1da745b74] 2 ??? (IOGPU + 24252) [0x1da745ebc] 2 ??? (IOGPU + 71780) [0x1da751864] 2 ??? (IOKit + 33612) [0x1a929734c] 2 ??? (IOKit + 531692) [0x1a9310cec] 2 ??? (libsystemkernel.dylib + 17104) [0x1cb46f2d0] Also here’s a log of some activity from a MDMiosagent. If anyone had any answers as to how to remove my account from a MDM (unenroll). My device was added to a management account without my consent or authorization.. and this “crime” needs to be reported immediately. I’ll post that on another question bold
Replies
2
Boosts
0
Views
2.2k
Activity
Jun ’22
BeforeUnLoad event not working in wkwebview
unload, pagehide event works in wkwebview. However, when i try to add beforeunload event listener, it won't get called in wkwebview.
Replies
0
Boosts
0
Views
1.6k
Activity
Jun ’22
Memory leak occurs when using WKWebView in swiftui
When I learned to use webview in my app, just added a webview and detected a memory leak, import SwiftUI import WebKit struct SWKWebView: UIViewRepresentable { @Binding var url: String? func makeUIView(context: Context) -> WKWebView { let webview = WKWebView() webview.navigationDelegate = context.coordinator return webview } func updateUIView(_ uiView: WKWebView, context: Context) { if let url = url, let requetURL = URL(string: url) { uiView.load(URLRequest(url: requetURL)) } } func makeCoordinator() -> Coordinator { Coordinator() } class Coordinator: NSObject,WKNavigationDelegate { func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) { webView.evaluateJavaScript("document.title") { (result, error) in print("didFinish:\(String(describing: result ?? ""))") } } } } struct TTTest: View { @State var url: String? = "https://www.google.com" var body: some View { SWKW ![]("https://developer.apple.com/forums/content/attachment/d4b6a729-f217-4b1a-9ec4-1372643e14b4" "title=WeChatc57286e9fa2eb9bc5d59b7410d876c33.png;width=1788;height=660") ebView(url: $url) } }
Replies
0
Boosts
1
Views
1.7k
Activity
May ’22
WKWebview websocket compression is broken
I have the websocket server which enables permessage-deflate to compress massive data. The problem is when I try to use it in webview, the connection was closed. I learned from other discussion that it can be solved by disabling Setting safari =>Advanced=>Experimental Features=>NSURLSession WebSocket, but only for Safari. How can I solve the problem in WKWebview? Or when will the problem be solved?
Replies
0
Boosts
0
Views
912
Activity
May ’22