-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
check for valid buffer and program #23658
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, but I'm not sure this change works correctly.
In particular I don't really understand how things could get into a state where this is a problem. For example for prevVB
: if the buffer was already deleted before the state was saved, then nothing will be bound, so getParameter(gl.ARRAY_BUFFER)
(line 1004) returns null
, so prevVB == null
. When we restore the state we'll call gl.bindBuffer(gl.ARRAY_BUFFER, null)
, which is correct - it unbinds the temporary array buffer. We don't want to leave a buffer bound if there wasn't one previously, which I think this PR would do.
Obviously there is some sequence of events that triggers the error you provided in the bug report, I'm just not sure what it could be. If you could provide a repro case or at least a step-by-step of how it happens, that would be really useful to understanding what the correct fix is here. Thanks!
I attempted to make a sample, but could not make one that duplicated the situation. @kainino0x ,I can give you credentials (in a private channel) on our sandbox server so you can see the log yourself |
A threading issue [in the middle of this code] shouldn't be possible. WebGL itself is single-threaded, so if you're using multi-threaded GL in your program that's achieved by Emscripten's GL proxying feature. When that's used, all WebGL calls still happen on the same JS thread. All of the code in this function happens at once in a single JS task, which can't be preempted by any other JS code. It's possible there's a browser bug that causes It's also possible there's some way GL can get into this state that I'm not aware of. I'm rusty on knowledge of the GL state machine. You could try capturing the actual sequence of WebGL calls using SpectorJS and that might give some insight into how this happens. You can feel free to email me at kainino@google.com but I won't be able to take much time to look at it. Hopefully these pointers help you find out what's going on. |
I tested on Firefox, and the same Warning occurred. according to copilot: The
I don't think it's the context loss, but it could any of the others. |
Blocking operations could cause the JS/Wasm VM to stall waiting for the browser, however they can't cause it to yield and allow other VM code to execute because JS tasks are not preemptible. Only explicit pauses ( (aside: Some of the things Copilot listed would be blocking in JS, others would not be because they'd block in the browser's GPU process instead) |
Sorry I didn't get a chance to look at your link. (I think the link isn't working anymore.) The screenshot you sent me does confirm that you're using Emscripten's proxying (though if I'd looked at the stack in the bug you'd filed, I would have seen this). But that shouldn't really matter; it's still the case that this function can't be interrupted even with proxying.
I just decided to try a standalone test of this. I realized that I tested the buffer case, but I did not test the program case. It turns out that
I did not know about this, but it is the specified behavior:
But of course we do take it out of the current state, so then it gets deleted. This seems to make it impossible to fully restore the previous GL state. However, we can at least avoid this error. Hopefully the application is not still relying on the deleted program being usable. For buffers, I'm not aware of any such logic, however. Can you confirm whether you've actually seen the crash on |
See comment for explanation. Fixes 23654. See the other PR for additional discussion: emscripten-core#23658 (comment)
I have a proposed fix for If you're still able to test it, please try this. Also please let me know about |
See comment for explanation. Fixes 23654. See the other PR for additional discussion: emscripten-core#23658 (comment)
See comment for explanation. Fixes 23654. See the other PR for additional discussion: emscripten-core#23658 (comment)
I was able to try the fix and it does remove the warning for me. |
Thank you for confirming! I will land that soon, then. |
#23654