JavaScript

RSS for tag

Discuss the JavaScript programing language.

Posts under JavaScript tag

40 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

WKWebView gpuProcessExited IdleExit Code=18
I'm injecting some javascript into a WKWebview on iOS. At a certain point the web view spits out these warnings into the console and the javascript execution stops. 0x109018c40 - [PID=778] WebProcessProxy::gpuProcessExited: reason=IdleExit 0x109019200 - [PID=779] WebProcessProxy::gpuProcessExited: reason=IdleExit Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 "(null)" UserInfo={NSUnderlyingError=0x303c3c060 {Error Domain=RBSRequestErrorDomain Code=3 "No such process found" UserInfo={NSLocalizedFailureReason=No such process found}}} I can't find any solution for this so am looking if anyone has any idea of what to try. None of the WKWebview delegate functions trigger when this occurs so I can't attempt to reload the webview at this stage
0
0
195
2w
EventSource: event 'error' not fired in iOS18
Hi, I noticed that event 'error' from EventSource is not fired in latest iOS 18, when web application is minimized and then re-activated. This was working in previous versions, so it is probably regression bug. Behavior in iOS 17: PWA application has active SSE/EventSource connection with server. Then some other application becomes active for more then ≈20 sec, so that SSE connection is closed. After SSE connection is closed, application is opened again. When application becomes visible, 'error' event is fired. This is expected behavior and this way also works on other non-iOS systems. Behavior in iOS 18: Following same steps as before it looks like that error event is not fired. Also,readyState of EventSource is 1 (EventSource.OPEN ), even if SSE connection is closed. If connection is interrupted when application is in foreground, then error event is fired on both iOS versions. This is quite problematic, because previously you could rely on 'error' event to trigger reconnection, when application becomes visible, but now this is not possible. Also EventSource readyState is 1, even if there is no connection to the server, so it is in wrong state. Any thoughts?
1
1
229
Oct ’24
FetchEvent.respondWith is terminated in 70 seconds in ServiceWorker
Hi, there. I am trying to use ServiceWorker on iPad to retry a request that has a communication error. However, I am having trouble with the process being terminated after 70 seconds. Occurs at least on iPadOS 17.6.1 and 16.3. The following is the service worker code to reproduce the problem: self.addEventListener('fetch', (event) => { if (event.request.url.includes('test.html')) { event.respondWith(longRunFetch()); } }); async function longRunFetch(request) { await new Promise(resolve => setTimeout(resolve, 75000)); return new Response('Fetch completed'); } When this code is executed on an iPad and a request is made to test.html, the service worker stops after about 70 seconds. When it stops, it falls back to the network request and the contents of test.html are displayed. The service worker thread appears to be killed and is unavailable until the browser is restarted. If timeout is set to 65000, 'Fetch completed' is displayed as expected. Why is the process terminated in 70 seconds? Is there any way to continue processing beyond 70 seconds?
0
0
170
Sep ’24
Cannot Play mp3 File via AudioContext in iOS 18 Safari
I have a Safari extension that plays audio via the javascript AudioContext API. It was working fine under iOS 17 and is now broken under iOS 18. It does not play audio at all. I've tried in both the iOS 18 public beta and the iOS 18.1 developer beta. It is broken in both of them. I've also created Feedback item FB15170620 which has a url attached to a page I created which demonstrates the issue.
0
0
276
Sep ’24
Trouble Generating Client Secret for Apple Sign-In Migration
We're preparing to migrate our Apple Sign-In users for an upcoming app transfer. Following this guide, we're currently stuck on the first curl command: curl -v POST "https://appleid.apple.com/auth/token" \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'grant_type=client_credentials' \ -d 'scope=user.migration' \ -d 'client_id=CLIENT_ID' \ -d 'client_secret=CLIENT_SECRET_ISSUED_BY_TEAM_A' Specifically, we're having issues generating the client secret, specified here. We're using a Node.js script to generate the script; initially I realized that the private key I was signing the JWT with was wrong (I was using the App Store Connect API team key instead of a private key for use with Account & Organization Data Sharing). Every time we try entering this curl command: curl -v POST "https://appleid.apple.com/auth/token" \ -H 'Content-Type: application/x-www-form-urlencoded' \ -d 'grant_type=client_credentials' \ -d 'scope=user.migration' \ -d 'client_id=com.jumbofungames.platMaker' \ -d 'client_secret=$(node clientsecret_jwt2.js)' Where $(node clientsecret_jwt2.js) is the command to generate the client secret; we get this error: < HTTP/1.1 400 Bad Request < Server: Apple < Date: Mon, 19 Aug 2024 15:41:31 GMT < Content-Type: application/json;charset=UTF-8 < Content-Length: 49 < Connection: keep-alive < Pragma: no-cache < Cache-Control: no-store < * Connection #1 to host appleid.apple.com left intact {"error":"invalid_client","email_verified":false}% Here is the script we are using to generate the Client Secret (JWT), with some variables using placeholders for privacy: const fs = require('fs'); const jwt = require('jsonwebtoken'); // npm i jsonwebtoken // You get privateKey, keyId, and teamId from your Apple Developer account const privateKey = fs.readFileSync("./AuthKey_ABCDEFG123.p8") // ENTER THE PATH TO THE TEAM KEY HERE (private key file) const keyId = "API_KEY"; // ENTER YOUR API KEY ID HERE const teamId = "TEAM_ID"; // ENTER YOUR TEAM ID HERE const clientId = "com.companyname.appname"; // ENTER YOUR APP ID OR SERVICES ID HERE (This is the client_id) // Time settings (in seconds) let now = Math.round((new Date()).getTime() / 1000); // Current time (seconds since epoch) let nowPlus6Months = now + 15776999; // 6 months from now (maximum expiration time) let payload = { "iss": teamId, // The Team ID associated with your developer account "iat": now, // Issued at time "exp": nowPlus6Months, // Expiration time (up to 6 months) "aud": "https://appleid.apple.com", // Audience "sub": clientId // The App ID or Services ID } let signOptions = { "algorithm": "ES256", // Algorithm for signing (ECDSA with P-256 curve and SHA-256 hash algorithm) header : { "alg": "ES256", // Algorithm in the header "kid": keyId, // Key ID in the header "typ": "JWT" // JWT type } }; // Generate the JWT (client_secret) let clientSecret = jwt.sign(payload, privateKey, signOptions); console.log(clientSecret); module.exports = clientSecret; If anyone has run into similar issues using this API or could shed some light on what could be going wrong, please let us know — we're at a bit of a loss here.
1
0
482
Aug ’24
First iOS release crashes on opening
Hello everyone, I'm releasing an Expo React Native app for Android and iOS. The Android release went well, but the iOS build crashes when opening in Testflight and the submission to Appstore crashes as per the review feedback. When I run it locally with ExpoGo it works as expected. Im not experienced in iOS development and my research didn't give me any concrete answers, a hint may be that on the JS code somewhere an object is being used as a boolean in a condition. Can someone point me to the nature of this issue so I can continue debugging? This is the crash log on Xcode when i create a new release: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryM boolValue]: unrecognized selector sent to instance 0x600000230300' *** First throw call stack: (   0   CoreFoundation                      0x00000001804ae138 __exceptionPreprocess + 172   1   libobjc.A.dylib                     0x0000000180087db4 objc_exception_throw + 56   2   CoreFoundation                      0x00000001804c2f88 +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0   3   CoreFoundation                      0x00000001804b2288 forwarding + 1280   4   CoreFoundation                      0x00000001804b45ac _CF_forwarding_prep_0 + 92   5   ColineleTransilvaniei               0x0000000104e6abbc __41-[RCTModuleMethod processMethodSignature]_block_invoke_12 + 68   6   ColineleTransilvaniei               0x0000000104e6bd88 -[RCTModuleMethod invokeWithBridge:module:arguments:] + 292   7   ColineleTransilvaniei               0x0000000104e6ded0 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicEiN12_GLOBAL__N_117SchedulingContextE + 456   8   ColineleTransilvaniei               0x0000000104e6db28 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 112   9   libdispatch.dylib                   0x00000001070d7ec4 _dispatch_call_block_and_release + 24   10  libdispatch.dylib                   0x00000001070d973c _dispatch_client_callout + 16   11  libdispatch.dylib                   0x00000001070e1a30 _dispatch_lane_serial_drain + 916   12  libdispatch.dylib                   0x00000001070e2774 _dispatch_lane_invoke + 420   13  libdispatch.dylib                   0x00000001070ef1a8 _dispatch_root_queue_drain_deferred_wlh + 324   14  libdispatch.dylib                   0x00000001070ee604 _dispatch_workloop_worker_thread + 488   15  libsystem_pthread.dylib             0x0000000105b1b814 _pthread_wqthread + 284   16  libsystem_pthread.dylib             0x0000000105b1a5d4 start_wqthread + 8 ) libc++abi: terminating due to uncaught exception of type NSException PS: I failed to Symbolicate the crash logs as well, but will try again
1
0
293
Aug ’24
contenteditable + getBoundingClientRect() does not return the correct result.
If a sufficiently long text in an HTML tag leads to a text wrap, the calculated values (y and width) of getBoundingClientRect for characters or words directly after the wrap are not correct, if the element or one of a parent is contenteditable="true" the y value has the value as if it were still before the break the width value spans the entire width, Here a code that reproduces this failure: https://stackblitz.com/edit/vitejs-vite-jwghts?file=src%2Fmain.ts,src%2FcalcLetterRects.ts,src%2Fstyle.css
1
0
288
Aug ’24
Dynamic Loading Javascript
Hi, Is it possible to publish an app to the app store which has functionality to download a javascript package that handles UI? I want to have an application that uses a framework such as Capacitor to dynamically download and load a javascript package and to provide updates for bug fixes and improvements on a regular basis. The package will be based off an app we currently use in house. Thanks Nate
0
0
276
Jul ’24
The width and height in MediaStreamTrack.getSettings are incorrect
I run the following code on iOS Safari: const stream = await navigator.mediaDevices.getUserMedia({ video: { width: 960, height: 540, }, }); const { width, height } = stream.getVideoTracks()[0].getSettings(); console.log(`${width} * ${height}`); // 960 * 540 setTimeout(() => { const { width, height } = stream.getVideoTracks()[0].getSettings(); console.log(`setTimeout: ${width} * ${height}`); // setTimeout: 540 * 960 }, 600); The width and height of width and height of the video track obtained by synchronously are different from those obtained by asynchronously. This is my test result and userAgent: Can someone help with this issue?
0
0
401
Jun ’24
JavaScript Not Executing in WebView When Modally Presenting UIViewController on iOS 17.5.1
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.
3
0
943
Jun ’24
Webview localStorage gets cleared if navigate away from page on iOS
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.
1
0
1.1k
May ’24
Increase in app crashes on iOS 17.4
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
5
0
1k
May ’24
Passkey and Safari
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 ?
2
0
663
Apr ’24
Camera stops when the path of our SPA changes
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?
2
0
899
Apr ’24
navigator.language returns system language only from iOS 17.4
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?
3
0
1.2k
Apr ’24
WebRTC App doesn't work while an iPhone or MacBook is connected.
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'); } };
0
0
915
Apr ’24
Safari App Extension: JavaScript script is responding to phantom messages
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.
1
0
626
Mar ’24
SFSafariViewController will sometimes ignore redirects to non-https URLs if no user interaction occurs
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
1
0
748
Mar ’24