]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-128627: Fix iPad detection in wasm-gc (#135388)
authorGyeongjae Choi <def6488@gmail.com>
Thu, 12 Jun 2025 04:04:13 +0000 (13:04 +0900)
committerGitHub <noreply@github.com>
Thu, 12 Jun 2025 04:04:13 +0000 (04:04 +0000)
On some iPad versions, Safari reports as "macOS". Modifies the GC trampoline detection
to add a feature-based check to detect this case.

Python/emscripten_trampoline.c

index cc5047d6bda2249c98162564e638bf730322e3c0..975c28eec104c6699308f863de6404ace8b9e21c 100644 (file)
@@ -71,7 +71,16 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), {
 // )
 
 function getPyEMCountArgsPtr() {
-    let isIOS = globalThis.navigator && /iPad|iPhone|iPod/.test(navigator.platform);
+    // Starting with iOS 18.3.1, WebKit on iOS has an issue with the garbage
+    // collector that breaks the call trampoline. See #130418 and
+    // https://bugs.webkit.org/show_bug.cgi?id=293113 for details.
+    let isIOS = globalThis.navigator && (
+        /iPad|iPhone|iPod/.test(navigator.userAgent) ||
+        // Starting with iPadOS 13, iPads might send a platform string that looks like a desktop Mac.
+        // To differentiate, we check if the platform is 'MacIntel' (common for Macs and newer iPads)
+        // AND if the device has multi-touch capabilities (navigator.maxTouchPoints > 1)
+        (navigator.platform === 'MacIntel' && typeof navigator.maxTouchPoints !== 'undefined' && navigator.maxTouchPoints > 1)
+    )
     if (isIOS) {
         return 0;
     }