WebGL 2 does not work TypedArrays with a view length >=2GB
Categories
(Core :: Graphics: CanvasWebGL, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox151 | --- | fixed |
People
(Reporter: jujjyl, Assigned: jrmuizel)
References
(Blocks 1 open bug)
Details
(Keywords: parity-chrome, parity-safari)
Attachments
(3 files, 1 obsolete file)
WebAssembly has in the past years lifted its signed int32 2GB linear Memory restrictions, and is able to do up to unsigned int32 4GB maximum Memory sizes.
We are in the process of updating Unity to support up to 4GB of memory. While testing this change, it looks like the WebGL 2 implementation in Firefox is not ready for this change, but throws an exception
TypeError: WebGL2RenderingContext.uniform4fv: Float32Array branch of
(Float32Array or sequence<unrestricted float>) can't be an ArrayBuffer
or an ArrayBufferView larger than 2 GB
This prevents Firefox from being able to run newer Unity content that requires more than 2GB of RAM.
| Reporter | ||
Comment 1•2 years ago
|
||
A test case can be downloaded from http://clb.confined.space/bugs/webgl2_more_than_2gb_of_ram.zip
Comment 2•2 years ago
|
||
The severity field is not set for this bug.
:jgilbert, could you have a look please?
For more information, please visit BugBot documentation.
| Reporter | ||
Comment 3•2 years ago
|
||
Attaching a possibly smaller-to-work-with repro.
This issue is still important, all Unity content will soon be running in this mode, which would break running on Firefox.
Updated•2 years ago
|
Comment 4•2 years ago
|
||
This exception is thrown from Codegen.py-generated bindings code, and is unconditional when the length of the view is too big.
However, the workaround is to make a subview of just the range you need, and that seems to work.
Comment 5•2 years ago
|
||
I don't know what our migration path to allowing >2GB arrays through the bindings code looks like. I imagine we'll need to craft an opt-in of some sort, and piecemeal update each binding's backing implementation. (e.g. some custom [AllowLarge])
@jandem probably knows more, I hope? :)
Comment 6•2 years ago
|
||
An example of the workarounds that I did to make the demo work locally:
function _glUniformMatrix4fv(location, count, transpose, value) {
value >>>= 0;
+ if (false) {
count && GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, HEAPF32, (value >>> 2), count * 16);
+ } else {
+ const view = new Float32Array(HEAPF32.buffer, value, count*16);
+ count && GLctx.uniformMatrix4fv(webglGetUniformLocation(location), !!transpose, view);
+ }
}
Comment 7•2 years ago
|
||
Actionable next steps in my mind are to add [AllowLarge] to Codegen.py and start using it for WebGL, but I want to know if there's an actual plan for this migration already.
Comment 9•2 years ago
|
||
(In reply to Kelsey Gilbert [:jgilbert] from comment #5)
I don't know what our migration path to allowing >2GB arrays through the bindings code looks like. I imagine we'll need to craft an opt-in of some sort, and piecemeal update each binding's backing implementation. (e.g. some custom [AllowLarge])
@jandem probably knows more, I hope? :)
The problem is that dom::TypedArray_base uses uint32_t instead of size_t for mLength, so this needs a careful audit/tests of consumers to check they can handle large array buffers without truncation (or worse).
Ideally we'd support large array buffers everywhere, but the opt-in you mentioned makes sense to me and is a good incremental step I think.
Comment 10•2 years ago
|
||
This needs changes to Codegen.py that I don't want to dive into for now, given how many things I'm working on otherwise.
Updated•2 years ago
|
Updated•1 year ago
|
| Assignee | ||
Updated•2 months ago
|
| Assignee | ||
Comment 11•1 month ago
|
||
Apply [AllowLarge] alongside [AllowShared] on WebGL buffer source
parameters and list typedefs. Update C++ consumers to pass
AllowLargeTypedArrays=true to ProcessData/ProcessFixedData so that
TypedArray views backed by large WASM heaps (up to 4GB) are accepted.
Updated•1 month ago
|
| Reporter | ||
Comment 12•1 month ago
|
||
so that TypedArray views backed by large WASM heaps (up to 4GB) are accepted.
Any chance this might address support for Wasm64 (up to 16GB views) as well?
Comment 13•1 month ago
|
||
Wasm64 (up to 16GB views)
Where is this limit comes from? I could not find the value from the spec.
| Reporter | ||
Comment 14•1 month ago
|
||
Comment 15•1 month ago
|
||
Comment 16•1 month ago
|
||
Comment 17•1 month ago
|
||
Backed out for causing gl2c failures @test_2_conformance2__wasm__bufferdata-4gb-wasm-memory.html.
| Assignee | ||
Comment 18•1 month ago
|
||
Apply [AllowLarge] alongside [AllowShared] on WebGL buffer source
parameters and list typedefs. Update C++ consumers to pass
AllowLargeTypedArrays=true to ProcessData/ProcessFixedData so that
TypedArray views backed by large WASM heaps (up to 4GB) are accepted.
Updated•1 month ago
|
| Assignee | ||
Comment 19•1 month ago
|
||
Is now failing with
[task 2026-03-26T21:23:29.329+00:00] 21:23:29 INFO - PROCESS-CRASH | 5e6ebd38-ca72-a2a0-1dda-e77abb5b4f41 | MOZ_CRASH(IPC message size is too large) [@ mozilla::ipc::PortLink::SendMessage] | dom/canvas/test/webgl-conf/generated/test_2_conformance__extensions__webgl-compressed-texture-size-limit.html
| Assignee | ||
Comment 20•1 month ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #19)
Is now failing with
[task 2026-03-26T21:23:29.329+00:00] 21:23:29 INFO - PROCESS-CRASH | 5e6ebd38-ca72-a2a0-1dda-e77abb5b4f41 | MOZ_CRASH(IPC message size is too large) [@ mozilla::ipc::PortLink::SendMessage] | dom/canvas/test/webgl-conf/generated/test_2_conformance__extensions__webgl-compressed-texture-size-limit.html
This was actually caused by something else
Comment 21•1 month ago
|
||
Comment 22•1 month ago
|
||
| bugherder | ||
| Assignee | ||
Comment 23•1 month ago
|
||
(In reply to Jukka Jylänki from comment #12)
so that TypedArray views backed by large WASM heaps (up to 4GB) are accepted.
Any chance this might address support for Wasm64 (up to 16GB views) as well?
I think it doesn't but haven't had a chance to check closely
Updated•19 days ago
|
Description
•