From 486bd2be7f86dfd55f33bba5e74164c0fd3583de Mon Sep 17 00:00:00 2001 From: ryanking13 Date: Wed, 11 Jun 2025 08:56:24 +0000 Subject: [PATCH 1/2] Fix iPad detection in wasm-gc --- Python/emscripten_trampoline.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Python/emscripten_trampoline.c b/Python/emscripten_trampoline.c index cc5047d6bda224..4a3926caeb0a59 100644 --- a/Python/emscripten_trampoline.c +++ b/Python/emscripten_trampoline.c @@ -71,7 +71,13 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), { // ) function getPyEMCountArgsPtr() { - let isIOS = globalThis.navigator && /iPad|iPhone|iPod/.test(navigator.platform); + 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; } From 35b6c64490061e003dd43d1e05734c6ff7627a66 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Thu, 12 Jun 2025 11:36:29 +0800 Subject: [PATCH 2/2] Add a comment about why this special case is needed. --- Python/emscripten_trampoline.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Python/emscripten_trampoline.c b/Python/emscripten_trampoline.c index 4a3926caeb0a59..975c28eec104c6 100644 --- a/Python/emscripten_trampoline.c +++ b/Python/emscripten_trampoline.c @@ -71,6 +71,9 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), { // ) function getPyEMCountArgsPtr() { + // 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.