a-shell
a-shell copied to clipboard
Larger wasm modules fail silently to load
I’m on a low-end device and find whether or not I can run wasm i build within a-shell seems related to how many lines of code i compile, and to change from run to run, making it hard to troubleshoot.
When my build output is 1.4MB, it runs. When it is 1.8MB, the terminal pauses briefly and then returns to a prompt, not even executing the beginning of the code.
Is this expected? Is it possible to output an error when it happens so the user can understand what is going on?
You're raising an interesting question. First, yes, if the WebAssembly interpreter runs out of memory during launch, it will fail more or less gracefully.
The wasm
command does forward all exceptions raised to the shell, and the shell outputs them as errors (you can check that by running wasm
on something that is not a WebAssembly file). So if it fails silently on your device, it would seem that the WebAssembly interpreter did not even raise an exception when failing.
The best solution is to reduce the size of the executable, with -Oz -s
.
I’ve tried compiling for size without success, but can try further. I’m also thinking about dynamic loading of multiple modules.
Is this something I would need XCode to diagnose?
I don't think you need Xcode. The only thing the command wasm does is call executeWebAssembly
in wasm.js
(https://github.com/holzschu/a-shell/blob/master/wasm.js) with the following arguments:
-
bufferString
: the webAssembly module, encoded in base64 -
args
: the actual arguments array (argc) -
cwd
: current working directory (not used) -
tty
: is this running in a tty (who is in charge of standard input?) -
env
: environment variables (can be a few variables when testing).
You can call an edited version of wasm.js
using the command jsc
inside a-Shell and see if you get more diagnosis. You'll need to edit it in order to load the webAssembly file (instead of having it sent by the application). But as you can see from wasm.js
, if there is an exception raised, it is forwarded to the application, which will display it (see here: https://github.com/holzschu/a-shell/blob/41d76f2b61a7a3c91837532abc3b52b9b3af1ed4/a-Shell/SceneDelegate.swift#L1354)
From your problem description, it seems that there were no execptions raised, no error code set, which makes me pessimistic.