Open Bug 1424537 Opened 7 years ago Updated 2 years ago

Web assembly linker errors don't appear when instantiated from web workers

Categories

(DevTools :: Console, defect, P2)

defect

Tracking

(Not tracked)

People

(Reporter: MTest31, Unassigned)

References

Details

Attachments

(3 files)

      No description provided.
Summary: Web assembly linker errors donWeb workers → Web assembly linker errors don't appear when instantiated from web workers
When you try to load web assembly and during loading there are linker errors, the linker errors are shown in the developer console when running on the main thread, but when the linking happens inside a web worker.

Just try the following: 

1. Comment out the "answer_to_life_from_js : () => { return 42; }," line to create a linker error
2. Uncomment the compute_answer(); line and comment out the line which starts the web worker

You will get an error in the web console like:

LinkError: import object field 'answer_to_life_from_js' is not a Function

Then reproduce the linker error from inside a web worker:

1. Keep the "answer_to_life_from_js : () => { return 42; }," line commented out
2. Comment out the compute_answer(); line and uncomment the line which starts the web worker

You won't see any error in the web console even though there is still a failure happening!
If you are stumbling across this issue accidentially, you have no idea what's going on.
That's not nice :).

In chromium, you are getting an error message in both cases. So this should get a chrome parity label.

Edge has the same buggy behaviour as Firefox here: error message in the console when run from the main thread,
but no error message for the linker error when run from the web worker.
I can confirm this with a simpler test case, which I will attach.  The problem is around the use of WebAssembly.instantiate: if it fails there is no error messge in the console if the code runs in a worker, but there is an error message if the code runs on the main thread.

Presumably this is somehow related to how rejected promises are handled in workers.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attached file linkerr.tar
Simple test case.  linkerr-main.html loads linkerr.js on the main thread; linkerr-worker.html loads it in a worker.  Observe output in the console.

As comments in linkerr.js make it plain, if the module is instantiated using 'new WebAssembly.Instance' then the error message appears correctly, even in a worker.  It is the use of the promise-based WebAssembly.instantiate that eats the error message.
Blocks: wasm
If one registers a `.catch()` handler for the returned Promise of WebAssembly.instantiate, is it correctly called with the WebAssembly.LinkError?  If so, then this is a devtools, not semantic, bug and I expect it's not specific to WebAssembly, but all Promise-returning functions.  Is someone able to test that with, e.g., fetch()?
> If one registers a `.catch()` handler for the returned Promise of WebAssembly.instantiate, is it correctly called with the WebAssembly.LinkError?

Yes, one gets a linker error here.

> I expect it's not specific to WebAssembly, but all Promise-returning functions. Is someone able to test that with, e.g., fetch()?

fetch has a similar behaviour, so it is indeed a general issue of Promise-returning functions.
Component: DOM: Workers → Developer Tools
Product: Core → Firefox
Is this a console bug, I can't tell so far. Moving there for now for more investigation.
Component: Developer Tools → Developer Tools: Console
Yes, this sounds like a general devtools+workers issue.
Product: Firefox → DevTools
Priority: -- → P2
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: