run-wasm
run-wasm copied to clipboard
Matplotlib doesn’t work on mobile Safari

Need to add some styling and figure out why graph isn't appearing when ran on mobile safari.
Haven't tested other mobile browsers
I suspect this one's going to be tricky, looks like the same issue in desktop Safari:
I suspect this one's going to be tricky, looks like the same issue in desktop Safari:
![]()
Tricky sounds fun :) knowing this is an issue on safari in general narrows it down a lot.
Indeed! These are the console errors when running the default plt code:
[Error] Recursive call to fatal_error. Inner error was:
(anonymous function) (pyodide.js:1:27994)
(anonymous function) (pyodide.js:1:10551)
(anonymous function)
[Error] TypeError: Invalid argument type in ToBigInt operation — pyodide.asm.js:14:2026049
(anonymous function) (pyodide.js:1:28064)
(anonymous function) (pyodide.js:1:10551)
(anonymous function)
[Error] Internal error: Argument 'undefined' to hiwire.get_value is falsy (but error indicator is not set).
(anonymous function) (pyodide.asm.js:14:234444)
(anonymous function) (pyodide.asm.js:14:234986)
(anonymous function)
[Error] Error: Internal error: Argument 'undefined' to hiwire.get_value is falsy (but error indicator is not set).
(anonymous function) (pyodide.asm.js:14:234670)
(anonymous function) (pyodide.asm.js:14:234986)
(anonymous function)
[Error] Unhandled Promise Rejection: TypeError: Invalid argument type in ToBigInt operation
dispatchException (main-c4f2541b93e4ae8b71f8.js:1:75462)
(anonymous function) (main-c4f2541b93e4ae8b71f8.js:1:71659)
r (688-5ecc4d12a9763f21465d.js:1:26179)
c (688-5ecc4d12a9763f21465d.js:1:26419)
promiseReactionJob
Invalid argument type in ToBigInt operation is probably our best clue
Actually a bit further up the stack it identifies that error too:
[Error] Pyodide has suffered a fatal error. Please report this to the Pyodide maintainers.
(anonymous function) (pyodide.js:1:28105)
(anonymous function) (pyodide.js:1:10551)
(anonymous function)
runPython (pyodide.js:1:23213)
(anonymous function) (matplotlib-0c50e29ec216d394ae8e.js:1:9410)
(anonymous function) (matplotlib-0c50e29ec216d394ae8e.js:1:8763)
o (matplotlib-0c50e29ec216d394ae8e.js:1:7605)
promiseReactionJob
[Error] The cause of the fatal error was:
(anonymous function) (pyodide.js:1:28205)
(anonymous function) (pyodide.js:1:10551)
(anonymous function)
runPython (pyodide.js:1:23213)
(anonymous function) (matplotlib-0c50e29ec216d394ae8e.js:1:9410)
(anonymous function) (matplotlib-0c50e29ec216d394ae8e.js:1:8763)
o (matplotlib-0c50e29ec216d394ae8e.js:1:7605)
promiseReactionJob
[Error] TypeError: Invalid argument type in ToBigInt operation — pyodide.asm.js:14:2026049
(anonymous function) (pyodide.js:1:28328)
(anonymous function) (pyodide.js:1:10551)
(anonymous function)
runPython (pyodide.js:1:23213)
(anonymous function) (matplotlib-0c50e29ec216d394ae8e.js:1:9410)
(anonymous function) (matplotlib-0c50e29ec216d394ae8e.js:1:8763)
o (matplotlib-0c50e29ec216d394ae8e.js:1:7605)
promiseReactionJob
Throwing a breakpoint in at [Error] TypeError: Invalid argument type in ToBigInt operation — pyodide.asm.js:54990
Function is:
function invoke_viiii(index, a1, a2, a3, a4) {
var sp = stackSave();
try {
dynCall("viiii", index, [a1, a2, a3, a4]) // <-- this is line 54990
} catch (e) {
stackRestore(sp);
if (e !== e + 0 && e !== "longjmp")
throw e;
_setThrew(1, 0)
}
}
It gets hit first with these local variables:
a1: 8494200
a2: 33341996
a3: 33347822
a4: 0
index: 5568
sp: 8494192
this: undefined
And then it throws that error. That function might mean more to you than it does to me because I don't yet know anything about wasm :)
dynCall jumps into here:
function dynCall(sig, ptr, args) {
if (sig.indexOf("j") != -1) {
return dynCallLegacy(sig, ptr, args)
}
if (ptr in dyncallInvokeMap) {
ptr = dyncallInvokeMap[ptr]
}
return wasmTable.get(ptr).apply(null, args)
}
with sig viiii, ptr 5568 and args being [a1, a2, a3, a4]
dyncallInvokeMap is empty so ptr doesn't get updated. wasmTable is a table of length 47239, and wasmTable.get(5568) just shows [native code].
I can get the same error calling wasmTable.get(5568).apply(null, [1,1,1,1])
Also 5568 doesn't seem to appear in the pyodide repo, so that's.. tricky. :)
Great info! I'll try to dive more into this tomorrow also :)
Thanks for all the details.
Another good place to look is issues in the pyodide repo talking about safari
I did take a look at their issues and couldn't find anything that looked super close to this. Might have missed it though, seems weird if we're the first to hit this.
There are fixed Safari issues in previous versions though, so hopefully worst case we can get a fix upstream there. Eg. If you've tried the iodide notebooks in Safari they're on version 0.15.0 and fail when you try to import any package - that's been fixed in the version we're on.