-
Notifications
You must be signed in to change notification settings - Fork 4
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
wasm32: some examples get RuntimeError
#22
Comments
Testing again after removing cube(relfast/small)[sg][error][id:5][line:8473]
cube.js:63:183
[sg][info][id:5][line:8474]
ERROR: 1:1: '' : syntax error
cube.js:63:243
[sg][error][id:5][line:8473]
cube.js:63:183
[sg][info][id:5][line:8474]
ERROR: 1:1: '' : syntax error
cube.js:63:243
onerror: RuntimeError: index out of bounds cube.html:1:1053
Uncaught RuntimeError: index out of bounds
c http://localhost:6931/cube.js:40
Qa http://localhost:6931/cube.js:40
_main http://localhost:6931/cube.js:65
a http://localhost:6931/cube.js:67
Ec http://localhost:6931/cube.js:67
setTimeout handler*Ec http://localhost:6931/cube.js:67
Dc http://localhost:6931/cube.js:66
a http://localhost:6931/cube.js:64
<anonymous> http://localhost:6931/cube.js:64
promise callback*Ba/< http://localhost:6931/cube.js:6
promise callback*Ba http://localhost:6931/cube.js:6
Z http://localhost:6931/cube.js:64
<anonymous> http://localhost:6931/cube.js:64
cube.wasm:33396:1
WebGL warning: bufferData: target: Invalid enum value 0 (Did you typo `gl.SOMETHINGG` and pass `undefined`?)
Error: Promised response from onMessage listener went out of scope ExtensionMessagingService.js:89:34 cube (relsafe)[sg][error][id:105] /home/kassane/sokol-d/src/sokol/c/sokol_gfx.h:16197:0:
VALIDATE_BUFFERDESC_DATA: immutable buffers must be initialized with data (sg_buffer_desc.data.ptr and sg_buffer_desc.data.size)
cube.js:64:160
[sg][panic][id:296] /home/kassane/sokol-d/src/sokol/c/sokol_gfx.h:16168:0:
VALIDATION_FAILED: validation layer checks failed
ABORTING because of [panic]
cube.js:64:130
Aborted() cube.html:1:906
onerror: RuntimeError: Aborted(). Build with -sASSERTIONS for more info. cube.html:1:1053
Uncaught RuntimeError: Aborted(). Build with -sASSERTIONS for more info.
ua http://localhost:6931/cube.js:4
Xa http://localhost:6931/cube.js:40
c http://localhost:6931/cube.js:41
Qa http://localhost:6931/cube.js:41
_main http://localhost:6931/cube.js:66
a http://localhost:6931/cube.js:68
Gc http://localhost:6931/cube.js:68
setTimeout handler*Gc http://localhost:6931/cube.js:68
Fc http://localhost:6931/cube.js:67
a http://localhost:6931/cube.js:65
<anonymous> http://localhost:6931/cube.js:65
promise callback*Ba/< http://localhost:6931/cube.js:6
promise callback*Ba http://localhost:6931/cube.js:6
Z http://localhost:6931/cube.js:65
<anonymous> http://localhost:6931/cube.js:65
cube.js:4:330
Error: Promised response from onMessage listener went out of scope ExtensionMessagingService.js:89:34 triangle | sql_context | blendonerror: RuntimeError: unreachable executed triangle.html:1:1053
Uncaught RuntimeError: unreachable executed
c http://localhost:6931/triangle.js:38
Na http://localhost:6931/triangle.js:38
_main http://localhost:6931/triangle.js:54
a http://localhost:6931/triangle.js:56
uc http://localhost:6931/triangle.js:56
setTimeout handler*uc http://localhost:6931/triangle.js:56
tc http://localhost:6931/triangle.js:55
a http://localhost:6931/triangle.js:53
<anonymous> http://localhost:6931/triangle.js:54
promise callback*za/< http://localhost:6931/triangle.js:6
promise callback*za http://localhost:6931/triangle.js:6
Z http://localhost:6931/triangle.js:54
<anonymous> http://localhost:6931/triangle.js:54
triangle.wasm:39269:1 mrt (relsafe)Aborted(Assertion failed: (slot_index > (0)) && (slot_index < p->attachments_pool.size), at: /home/kassane/sokol-d/src/sokol/c/sokol_gfx.h,16039,_sg_attachments_at) mrt.html:1:906
onerror: RuntimeError: Aborted(Assertion failed: (slot_index > (0)) && (slot_index < p->attachments_pool.size), at: /home/kassane/sokol-d/src/sokol/c/sokol_gfx.h,16039,_sg_attachments_at). Build with -sASSERTIONS for more info. mrt.html:1:1053
Uncaught RuntimeError: Aborted(Assertion failed: (slot_index > (0)) && (slot_index < p->attachments_pool.size), at: /home/kassane/sokol-d/src/sokol/c/sokol_gfx.h,16039,_sg_attachments_at). Build with -sASSERTIONS for more info.
va http://localhost:6931/mrt.js:4
a http://localhost:6931/mrt.js:41
c http://localhost:6931/mrt.js:42
Za http://localhost:6931/mrt.js:42
_main http://localhost:6931/mrt.js:70
a http://localhost:6931/mrt.js:73
Kc http://localhost:6931/mrt.js:73
setTimeout handler*Kc http://localhost:6931/mrt.js:73
Jc http://localhost:6931/mrt.js:72
a http://localhost:6931/mrt.js:69
<anonymous> http://localhost:6931/mrt.js:70
promise callback*Ba/< http://localhost:6931/mrt.js:6
promise callback*Ba http://localhost:6931/mrt.js:6
Z http://localhost:6931/mrt.js:70
<anonymous> http://localhost:6931/mrt.js:70
mrt.js:4:333 cc: @floooh |
Does this only happen in the web version? In sokol-zig I had to increase the Emscripten stack size recently, at one point, the Emscripten SDK reduced the default stack size to 64 KBytes, which really isn't much, especially with the 'stack heavy' init code in the sokol samples. ...maybe it's the same issue - in general, "anything can happen" on such a stack overflow, so that would be the first thing I would try. |
Yeah!
applied: ae22c87 |
...and did it fix the issue? :) |
The error still persists after commit. |
All those different errors look like there's a problem with passing data Doesn't quite explain why it only happens in WASM though... unless it's some sort of ABI incompatibility that only happens on the WASM compilation target... PS: e.g. if the only difference is the added bounds checking I would expect to see more D bounds checking errors, but the errors are all over the place instead (shader compilation doesn't work, nullptrs are provided where a pointer to data is expected etc... One way to approach the bug would be printf-debugging, e.g. logging content of desc structs that go into the creation functions both on the D side (for instance here: Line 1353 in e0e0596
sokol-d/src/sokol/c/sokol_gfx.h Line 18185 in e0e0596
|
libsokol + cube - wasm32 llvm-ir (relfast): |
LLVM-IR (
|
Crazy enough it seems to be related to WebGL vs WebGL2 shaders... In the mrt-emsc sample (in sokol-samples) I can trigger the problem by replacing the vertex or fragment shader in This is very, very weird. Maybe something corrupts the stack in the WebGL2 shader case which then causes those strange problems in the followup calls. I'll try to investigate as far as possible today, but will be on a 4-day vacation trip until Thursday where I'll be offline. PS: same in that other broken sample (bufferoffsets-emsc), going back to WebGL1 shaders makes it work. PPS: so out of those 16 Emscripten samples in https://github.com/floooh/sokol-samples/tree/master/html5, 2 have that weird behaviour that they crash with mysterious errors when I replace the WebGL1 shaders with WebGL2 shaders (bufferoffsets-emsc and offscreen-emsc). I will next try to figger out what's different about those two samples. At first glance they don't seem to share anything significant. |
Wrote a reminder ticket here: ...my theory that the stack corruption somehow happens inside sokol_gfx.h and then affects followup calls also can't be right, because in the bufferoffsets-emsc sample, there's only a single call to I'll try to find out more after I return from my little vacation trip. |
...ok, so in my case the reason was a little innocent comma in the shader code string. It's still interesting how that could cause such absolutely weird errors. And it also doesn't explain the sokol-d problems because the sokol-d samples use code-generated shaders. But since the errors look similar, maybe the problems are still somehow related...? |
DGC (BoehmGC ported to D) is useless unless the druntime library is involved. Especially when Druntime does not have wasm support! explicit malloc/free for C++ class in D: https://d.godbolt.org/z/n34nY61b8
According to the issue opened on ldc-developers (this issue is cited). It's more likely that the struct alignment causes this error (still debated in the D community). However, we can't say that D doesn't fully support wasm32, because the other examples work. Maybe I'm still trying to figure out how to work around it manually by tweaking the implementation of these examples and shaders. I tried some tests with emcc-debug and also by removing the "-preview" features flag from D (requires refactoring), enabling sanitize-c from zig and got the same result. My question is at what point does the problem occur? In this project, I haven't tried auto-generating C++ code from D yet (it's possible - it requires customization and the addition of e.g.: D to C++ (works on dmd & ldc2/ldmd2, gdc no): https://godbolt.org/z/q6cxs4d38 - ( |
https://godbolt.org/z/1KqGcWGjq (generated test) - see my comment-lines in full-code |
Fixed by: |
Awesome. Good to see that sokol-gfx somehow and indirectly contributes to improving the D toolchains ;) If alignment was the issue then I guess that the reason why some demos worked while others didn't was that the alignment might have been accidentially right in some of the demos. |
shaded examples not working in wasm32 target. Black screen!
e.g.:
Cube
firefox - output console
Triangle
chromium - output console
The text was updated successfully, but these errors were encountered: