Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib doesn’t work on mobile Safari #44

Open
kennethcassel opened this issue Sep 25, 2021 · 6 comments
Open

Matplotlib doesn’t work on mobile Safari #44

kennethcassel opened this issue Sep 25, 2021 · 6 comments
Labels
bug Something isn't working Hacktoberfest

Comments

@kennethcassel
Copy link
Contributor

image

Need to add some styling and figure out why graph isn't appearing when ran on mobile safari.

Haven't tested other mobile browsers

@mcintyre94
Copy link
Contributor

I suspect this one's going to be tricky, looks like the same issue in desktop Safari:

Screenshot 2021-09-25 at 20 49 22

@kennethcassel
Copy link
Contributor Author

I suspect this one's going to be tricky, looks like the same issue in desktop Safari:

Screenshot 2021-09-25 at 20 49 22

Tricky sounds fun :) knowing this is an issue on safari in general narrows it down a lot.

@mcintyre94
Copy link
Contributor

mcintyre94 commented Sep 25, 2021

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

@mcintyre94
Copy link
Contributor

mcintyre94 commented Sep 25, 2021

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. :)

@kennethcassel
Copy link
Contributor Author

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

@mcintyre94
Copy link
Contributor

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.

@kennethcassel kennethcassel added bug Something isn't working Hacktoberfest labels Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Hacktoberfest
Projects
None yet
Development

No branches or pull requests

2 participants