Skip to content

Commit d447129

Browse files
authored
gh-128627: Fix iPad detection in wasm-gc (#135388)
On some iPad versions, Safari reports as "macOS". Modifies the GC trampoline detection to add a feature-based check to detect this case.
1 parent 71f5faf commit d447129

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Python/emscripten_trampoline.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ EM_JS(CountArgsFunc, _PyEM_GetCountArgsPtr, (), {
7171
// )
7272

7373
function getPyEMCountArgsPtr() {
74-
let isIOS = globalThis.navigator && /iPad|iPhone|iPod/.test(navigator.platform);
74+
// Starting with iOS 18.3.1, WebKit on iOS has an issue with the garbage
75+
// collector that breaks the call trampoline. See #130418 and
76+
// https://bugs.webkit.org/show_bug.cgi?id=293113 for details.
77+
let isIOS = globalThis.navigator && (
78+
/iPad|iPhone|iPod/.test(navigator.userAgent) ||
79+
// Starting with iPadOS 13, iPads might send a platform string that looks like a desktop Mac.
80+
// To differentiate, we check if the platform is 'MacIntel' (common for Macs and newer iPads)
81+
// AND if the device has multi-touch capabilities (navigator.maxTouchPoints > 1)
82+
(navigator.platform === 'MacIntel' && typeof navigator.maxTouchPoints !== 'undefined' && navigator.maxTouchPoints > 1)
83+
)
7584
if (isIOS) {
7685
return 0;
7786
}

0 commit comments

Comments
 (0)