-
-
Notifications
You must be signed in to change notification settings - Fork 136
WebAssembly won't initialize without the debugger #1558
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
Comments
This comment was marked as abuse.
This comment was marked as abuse.
Thank you for responding so fast.
Which method did you use?
I've tried using a hardcoded |
The WebAssembly's async compile API registers some ongoing work on one of Currently the Android runtime doesn't handle this scenario properly. For this to work we need to pump the V8 message loop and run the microtasks: while (v8::platform::PumpMessageLoop(Runtime::platform, isolate, MessageLoopBehavior::kDoNotWait)) {
isolate->RunMicrotasks();
} We will investigate what would be the best approach to handle this case in the runtime. Until then you could use WebAssembly's synchronous API: let utf8ToString = (h, p) => {
let s = "";
for (let i = p; h[i]; i++) {
s += String.fromCharCode(h[i]);
}
return s;
};
let buffer;
const importObject = {
env: {
puts(index) {
console.log(utf8ToString(buffer, index));
}
}
};
const wasmCode = new Uint8Array([
0, 97, 115, 109, 1, 0, 0, 0, 1, 138, 128, 128, 128, 0, 2, 96, 1,
127, 1, 127, 96, 0, 1, 127, 2, 140, 128, 128, 128, 0, 1, 3, 101,
110, 118, 4, 112, 117, 116, 115, 0, 0, 3, 130, 128, 128, 128, 0,
1, 1, 4, 132, 128, 128, 128, 0, 1, 112, 0, 0, 5, 131, 128, 128,
128, 0, 1, 0, 1, 6, 129, 128, 128, 128, 0, 0, 7, 145, 128, 128,
128, 0, 2, 6, 109, 101, 109, 111, 114, 121, 2, 0, 4, 109, 97, 105,
110, 0, 1, 10, 143, 128, 128, 128, 0, 1, 137, 128, 128, 128, 0, 0,
65, 16, 16, 0, 26, 65, 0, 11, 11, 148, 128, 128, 128, 0, 1, 0, 65,
16, 11, 14, 104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108,
100, 33, 0
]);
const wasmModule = new WebAssembly.Module(wasmCode);
const moduleInstance = new WebAssembly.Instance(wasmModule, importObject);
buffer = new Uint8Array(moduleInstance.exports.memory.buffer);
let result = moduleInstance.exports.main();
console.log(result); |
fix: WebAssembly promise callbacks are now properly resolved (#1558)
Uh oh!
There was an error while loading. Please reload this page.
Environment
Provide version numbers for the following components (information can be retrieved by running
tns info
in your project folder or by inspecting thepackage.json
of the project):Devices:
Describe the bug
I'm not sure why, but I can't get the promise from
WebAssembly.compile(...)
orWebAssembly.instantiate(...)
to resolve without connecting the chrome debugger to my app and stepping through JavaScript.What makes this really odd, is that it doesn't matter what JS-code I step through.
To Reproduce
tns run android
But it will resolve if I use the chrome debugger:
Steps to load with the debugger.
tns debug android
Expected behavior
The promise from
WebAssembly.compile(...)
orWebAssembly.instantiate(...)
to either resolve or reject without the debugger.Sample project
Demo project here: https://github.com/m-abs/tns-wasm
WASM code is a very simple "Hello World" program.
Additional context
The text was updated successfully, but these errors were encountered: