-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
wasm-bindgen-futures
: use queueMicrotask
for next tick runs (#3203)
#3611
Conversation
That's fine.
The contributor experience is awful in this regard and should be improved/fixed.
Thanks, I added it to the OP.
We could use @Liamolucko what do you think of adding
Probably, but our story for |
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.
Would like to figure out first how we could cache queueMicrotask
availability first, but otherwise LGTM.
Would you mind adding a note to the changelog as well?
The specific two problems there are that the main The But yeah, those should both be either documented or fixed.
I'm fine with that too. |
maybe i'm missing part of the puzzle, but wouldn't it be enough to try executing it once (with e.g. an empty closure) in then we could do:
?
sure no problem, do you prefer i push another commit, or should i force push my branch?
thanks that worked for the first test, but running
|
That would be better indeed! Instead of calling #[wasm_bindgen]
extern "C" {
#[wasm_bindgen(getter)]
fn queueMicrotask() -> JsValue;
} Which returns
I'm assuming this needs to be called from inside some package. |
it seems that does not work, AFAICS the 'getter' property in the macro is ignored for non struct members possible alternatives i saw were using the or using something like: #[wasm_bindgen(inline_js = "export function queueMicrotaskExists() { return typeof queueMicrotask === 'function' }")]
extern "C" {
fn queueMicrotaskExists() -> bool;
} but that seems also overly complicated... (also you did not answer my question about the pull request update, should i force push or add commits?) Thanks! |
We would want to avoid that because of the overhead from the string. #[wasm_bindgen]
extern "C" {
type Global;
#[wasm_bindgen(method, getter, js_name = queueMicrotask)]
fn hasQueueMicrotask(this: &Global) -> JsValue;
}
let global: Global = js_sys::global().unchecked_into();
let has_queue_microtask = global.hasQueueMicrotask();
Apologies! |
ah thanks, the 'Global' part was what i was missing, big thanks :) i'll update my branch shortly |
…wasm#3203) but use the old `Promise.then` mechanism as a fallback. Cache the existance of `queueMicrotask` in the queue instance. Signed-off-by: Dominik Csapak <[email protected]>
0d54602
to
44126a3
Compare
Signed-off-by: Dominik Csapak <[email protected]>
only the pull request is relevant Signed-off-by: Dominik Csapak <[email protected]>
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.
Thank you!
but use
catch
to wrap it in a Result to be able to fall back to the previousPromsise.then
variant.since this is my first pull request here, i hope the code is ok this way, but a few questions remain:
the first one failed (regardless of my changes) and
cargo test -p ui-tests
also did not work (the remaining tests worked, as well as the ones directly inwasm-bindgen-futures
Fixes #2392.