Skip to content
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

wasm64: bufferSubData fails after heap grows beyond 4 GB #20517

Open
jspanchu opened this issue Oct 23, 2023 · 4 comments
Open

wasm64: bufferSubData fails after heap grows beyond 4 GB #20517

jspanchu opened this issue Oct 23, 2023 · 4 comments

Comments

@jspanchu
Copy link
Contributor

jspanchu commented Oct 23, 2023

Version of emscripten/emsdk:

|-> $ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.47 (431685f05c67f0424c11473cc16798b9587bb536)
clang version 18.0.0 (https://github.com/llvm/llvm-project 21030b9ab4487d845e29792063f5666d8c4b8e09)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/local/KHQ/jaswant.panchumarti/Documents/code/ansys/vtk-wasm-memory-branch/emsdk/upstream/bin

Error:

Uncaught (in promise) TypeError: Failed to execute 'bufferSubData' on 'WebGL2RenderingContext': parameter 3 is not of type 'ArrayBufferView'.
    at _glBufferSubData (vtkWasmRendererApplication.js:7581:17)

From debugger, it looks like HEAPU8 is a proxy object due to changes introduced by #19737. What is the approach to make the proxy recognizable by bufferSubData?

heap-beyond-4gb-in-buffer-sub-data

@jspanchu
Copy link
Contributor Author

I've found a solution that works, but seems silly. Wonder if we can do better?

-GLctx.bufferSubData(target, offset, HEAPU8, data, data+size);
+GLctx.bufferSubData(target, offset, HEAPU8.subarray(data, data + size), 0, size);

@sbc100
Copy link
Collaborator

sbc100 commented Oct 23, 2023

That seems like a reasonable patch for now (at least until we can remove proxy object, which should be very soon now)

I'm not sure we can make the proxy object appear as a real ArrayBufferView (but I'm not sure about this).

@jspanchu
Copy link
Contributor Author

Okay! if the proxy objects are going to get removed soon, I've no issue waiting till then.

@sbc100
Copy link
Collaborator

sbc100 commented Oct 23, 2023

Yeah, the proxy objects are a workaround for a chrome bug that IIUC has already been fixed upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants