Conversation
|
@sbc100 Thanks for taking the time to review this. I addressed all of your comments and did the following:
|
|
@sbc100 ping 🤞 |
tlively
left a comment
There was a problem hiding this comment.
Great, this looks a lot simpler overall, even though I agree that it's a little awkward to get the ctx into the right place. Thanks!
5aef76b to
58889f9
Compare
I am sorry I completely messed up git while trying to rebase. |
84fcbd2 to
ae2357d
Compare
|
@tlively any tips for passing all the CI tests? |
|
proxying.c looks good to me. It looks like the flake8 bot is failing because of a formatting issue. The other CI bots might be aborting early because of that issue. Merging in main to pick up any unrelated fixes could also help. |
|
The fact that flake8 is being included at all in CI makes me think that perhaps you are not up-to-date on your branch? The flake8 step was replaced with a step call |
|
Can you try rebase onto to merging with the latest changes on main? |
464bc2f to
4416f4d
Compare
d8 you can get usinfg the jsvu tool. node-canary you can you get from https://nodejs.org/download/v8-canary/ |
|
@sbc100 Thanks! I'll give it a go |
2803fc6 to
be85c88
Compare
5c1bd6b to
fd5e213
Compare
fd5e213 to
e6a8842
Compare
f59165b to
a43b9bd
Compare
|
Thanks for continuing to work on this. Apologies for the review process taking so long. I had no imagined this being such an invasive change (i.e.changing the code proxying functions). |
|
@sbc100 Thanks, I appreciate the continued work on this. I didn't have much time recently to cater to this PR. I'll hopefully get back to it soon. |
|
Sorry for the long delay on this. I've since landed a JS library feature that is kind of like this one: #26000. So I think i now have a much better understanding of the use case. Would you have time to rebase this and we can see about landing it? |
Co-authored-by: Cursor <cursoragent@cursor.com>
dfb5e54 to
7b8b384
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@sbc100 Hey, I rebased it and addressed all of your comments |
|
@guybedford WDYT of this extra macro/tool? |
| rtn.then((rtn) => __emscripten_run_js_on_main_thread_done(ctx, ctxArgs, rtn)); | ||
| rtn.then( | ||
| (rtn) => __emscripten_run_js_on_main_thread_done(ctx, ctxArgs, rtn), | ||
| () => __emscripten_run_js_on_main_thread_done(ctx, ctxArgs, 0), |
There was a problem hiding this comment.
Does this mean we always return zero on promise rejection? Is this needed? What is we have a function that uses a zero return to mean something else?
Do you need this feature? Maybe we should leave it out for the initial version?
| Inside MAIN_THREAD_EM_ASM_AWAIT: 42 3.5 | ||
| Inside asyncOp | ||
| After MAIN_THREAD_EM_ASM_AWAIT | ||
| result: 2 No newline at end of file |
|
|
||
| int main() { | ||
| emscripten_out("Before MAIN_THREAD_EM_ASM_AWAIT"); | ||
| int res = MAIN_THREAD_EM_ASM_AWAIT({ |
There was a problem hiding this comment.
Might it be nice if we could use await inside these functions?
i.e. should we mark these function snippets as async on the JS side?
| #if ASSERTIONS | ||
| assert(ENVIRONMENT_IS_PTHREAD, 'emscripten_asm_const_int_await_on_main_thread is not available on the main thread'); | ||
| #endif | ||
| return runMainThreadEmAsm(emAsmAddr, sigPtr, argbuf, 2); |
There was a problem hiding this comment.
I wonder if these is some way we can avoid the magic number here?
How about {{{ PROXY_SYNC_ASYNC }}}?
Introduce a new macro
MAIN_THREAD_EM_ASM_PROMISE_AWAITwhich is used to write JavaScript code that returns a promise and block the C code from progressing until the promise is resolved (or errors).The motivation for this was discussed before
We have multiple web workers, each of them calls javascript code which is async and has to be ran on the main thread and need to wait for the promise to be resolved.
I am open for suggestions on how to add this more elegantly