-
Notifications
You must be signed in to change notification settings - Fork 34
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
fix: use global() to get performance API on wasm32-unknown-unknown #107
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 opening this PR!
Taking a look at the code, it seems like this is going to be somewhat inefficient, reflecting through the global scope on every single call.
Is my intuition wrong here? Could we not instead simply query for the Performance
class when constructing Monotonic
so that there's always a live reference to it to directly use?
You are right, Reflection is relatively slow since its equal to |
Updated now. I also splitted |
Hi @tobz , how's this issue going on? |
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.
Apologies: life and work have been pretty busy lately. :)
I left a common about how we caching the Performance
object, and in particular about how we're overriding the fact that it's !Send
/!Sync
.
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.
Overall, these changes seem reasonable to me. 👍🏻
Hi, when can we get this PR merged |
👋🏻 Going to merge these now, but I'll have to fix the MSRV and CI afterwards and make sure things are still green before I can cut a release. |
Released as Thanks again for your contribution! |
Currently quanta uses
window.performance
to access Performance API in browser, which will not work in WebWorkers. In WebWorkers, there is nowindow
object, butperformance
is in the global space.This PR uses
web_sys::js_sys::global()
to access the global scope, and look up forperformance
in that, which will both work on webpage and WebWorkers.See https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Functions_and_classes_available_to_workers for more details