toResizableBuffer is not working with WasmWorkers in Firefox 148.0 (64-bit)
Categories
(Core :: JavaScript: WebAssembly, defect, P2)
Tracking
()
People
(Reporter: arepko, Assigned: jpages)
Details
Attachments
(3 files, 2 obsolete files)
Steps to reproduce:
- new WebAssembly.Memory({ initial: 1, maximum: 10, shared: true })
- Call .toResizableBuffer() — succeeds, returns buffer with resizable = undefined
- postMessage({ memory }) to a Worker — succeeds on the sender side
- Worker never receives the message — no error, no message error, complete silence
Without step 2, everything works perfectly
Logs for example:
[10:17:33 PM] \n=== Test: WITHOUT toResizableBuffer ===
[10:17:33 PM] Created WebAssembly.Memory (shared): buffer.byteLength = 65536
[10:17:33 PM] typeof memory.toResizableBuffer = function
[10:17:33 PM] Posting memory to worker...
[10:17:33 PM] postMessage succeeded (main thread side)
[10:17:33 PM] Worker result (WITHOUT toResizableBuffer):
[10:17:33 PM] received keys = memory, label
[10:17:33 PM] typeof memory = object
[10:17:33 PM] isUndefined = false
[10:17:33 PM] isNull = false
[10:17:33 PM] constructor = Memory
[10:17:33 PM] buffer.byteLength = 65536
[10:17:33 PM] buffer.constructor = SharedArrayBuffer
[10:17:33 PM] buffer.resizable = false
[10:17:33 PM] >>> PASS: memory is defined in worker <<<
[10:17:34 PM] \n=== Test: WITH toResizableBuffer ===
[10:17:34 PM] Created WebAssembly.Memory (shared): buffer.byteLength = 65536
[10:17:34 PM] typeof memory.toResizableBuffer = function
[10:17:34 PM] Called toResizableBuffer() — returned buffer byteLength = 65536, resizable = undefined, maxByteLength = 655360
[10:17:34 PM] memory.buffer after conversion: byteLength = 65536
[10:17:34 PM] Posting memory to worker...
[10:17:34 PM] postMessage succeeded (main thread side)
[10:17:37 PM] >>> TIMEOUT: Worker never responded after 3s (WITH toResizableBuffer) <<<
In a real project, the WASM is built with emscripten, and it crashes if a ResizableBuffer is present in the code/scope (not even called!), with the " wasmMemory is not defined error.
Actual results:
The worker never receives the message — no error, no message error, complete silence
Expected results:
Worker receives the message or toResizableBuffer is not available.
Comment 1•6 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::JavaScript: WebAssembly' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Updated•6 months ago
|
Comment 2•6 months ago
|
||
It is a StructureClone+shared resizable buffer defect. In this case it fails to de-serialize a growable memory. It is probably just a simple fix to remove the payload.toObject().as<SharedArrayBufferObject>().isGrowable() check at https://searchfox.org/firefox-main/source/js/src/vm/StructuredClone.cpp#3027
Comment 3•6 months ago
|
||
We just came across the exact same bug in emscripten: https://github.com/emscripten-core/emscripten/issues/27118
Would be great to get this fixed, although it sounds like we will likely need to have a userAgent probe in there for the foreseeable to avoid using this feature on certain shipping firefox versions?
| Assignee | ||
Updated•3 months ago
|
| Assignee | ||
Comment 5•3 months ago
|
||
| Assignee | ||
Comment 6•3 months ago
|
||
Updated•3 months ago
|
Updated•3 months ago
|
Updated•3 months ago
|
| Assignee | ||
Comment 9•2 months ago
|
||
This is now in Firefox 154 (nightly), but after discussions with the team, it would be good to uplift this into 153 (ESR).
This bug was blocking an external project, emscripten.
Comment 10•2 months ago
|
||
firefox-beta Uplift Approval Request
- User impact if declined/Reason for urgency: toResizableBuffer() was not working with wasm workers. This was an issue for an external project (emscripten).
To avoid them having to use some userAgent probe in the future, it would be good to have this patch in an ESR release.
- Code covered by automated testing?: yes
- Fix verified in Nightly?: yes
- Needs manual QE testing?: no
- Steps to reproduce for manual QE testing:
- Risk associated with taking this patch: low
- Explanation of risk level: Small and contained patch which is updating an old assert to allow the usage of growable wasm SharedArrayBuffers with workers.
- String changes made/needed?: None
- Is Android affected?: yes
| Assignee | ||
Comment 11•2 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D307849
Updated•2 months ago
|
Updated•2 months ago
|
Comment 12•2 months ago
|
||
| uplift | ||
Description
•