Repository navigation
Delegate canvas operations to main thread - #8185
Conversation
__findCanvasEventTarget will throw when called from a thread.
|
I'm not sure if that fixes all the pthread/html5 issues, so I'll have a bit more of a look before taking this out of draft. |
|
Formatting change should change lines like which have misleading indentation/whitespace to Still not perfect, but in my opinion a lot more readable. |
|
OK, I figured out what's going on with the failing test. |
kripken
left a comment
There was a problem hiding this comment.
Thanks for the PR!
optimally @juj should review this. But perhaps we should add a check on if something is in a pthread inside _findCanvasEventTarget? (return null if pthread) that way all methods calling that would just work, it seems?
We should also add testing for this.
| if (canvas) return _emscripten_set_canvas_element_size_calling_thread(target, width, height); | ||
| else return _emscripten_set_canvas_element_size_main_thread(target, width, height); | ||
| if (!ENVIRONMENT_IS_PTHREAD) | ||
| var canvas = __findCanvasEventTarget(target); |
There was a problem hiding this comment.
var for the canvas should be outside the if, for clarity (as it's used later down)
The pthreads check was a bad idea as threads can be given control over the canvas. Resizing a canvas using PROXY_TO_PTHREAD will throw. This should stop that.
|
I'll add a test for this tomorrow/Monday (assuming all the tests pass). |
|
Thanks, looks good aside from the indentation issue, and adding testing. |
Apparently the correct way is to address this in jsifier.js
var domElement = __specialEventTargets[target] || document.querySelector(__maybeCStringToJsString(target)); changed to var domElement = __specialEventTargets[target] || (typeof document !== 'undefined' ? document.querySelector(__maybeCStringToJsString(target)) : undefined); so a small increase is expected.
|
I don't know why those Firefox tests are failing. They look unrelated? Also I realise I should probably add myself to the authors, but if this goes through I'll add it in a separate PR. |
|
Thanks, I think this is good (the tests are random errors). Please just fix the code size issue mentioned above, and may as well add yourself to AUTHORS in this PR while updating it. |
|
Great, thanks @VirtualTim! |
This should fix canvas operations (ie emscripten_set_canvas_element_size) working on a pthread.
Previously this was throwing
ReferenceError: document is not defined.