-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[AUDIO_WORKLET] Add compatible spinlock tests #22995
base: main
Are you sure you want to change the base?
Conversation
// Note: using emscripten_get_now() over emscripten_performance_now() to allow | ||
// compatibility with Audio Worklets (but for workers this will defer to the | ||
// performance call with its higher granularity). We keep the non-busy locks | ||
// using the performance version since they have waits, incompatible with AWs. |
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.
I'm not really sure we need this comment, and I think we we should probably just convert everything to emscripten_get_now
.
If you do go with a comment how about "Use emscripten_get_now over emscripten_performance_now since the former is available in all contexts and uses performance.now under the hood where available.".
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.
All the other lock types used waits, so it was a limited set of functions that could work. There’s no current benefit, unless I’m missing something, to changing all uses over to plain now
.
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.
I thought it useful to leave a comment in case someone later thinks to change it.
It does need docs adding in the web audio page to explain what locks can be used. I’ll do this, and finish the tests, in the next days.
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.
I guess i just don't see the point of emscripten_performance_now
at all. I'm not sure why it was ever added. Why wouldn't all callsites simply prefer emscripten_get_now
? The works in more places (i.e. all places) and lowers the same thing when performance.now
is available.
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.
I've had time to think about this: emscripten_performance_now()
when supported is very lightweight (it maps directly to the browser's call). emscripten_get_now()
has a bit of indirection, and for high performance code I'd prefer the option to know I'm avoiding indirection.
For this PR I've kept the change to the parts that need changing to prove out a set of lock calls work.
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.
FWIW emscripten_get_now() maps directly to performance.now()
whenever `performance.now() is available. See
Lines 1393 to 1396 in 7342ee8
// Modern environment where performance.now() is supported: | |
// N.B. a shorter form "_emscripten_get_now = performance.now;" is | |
// unfortunately not allowed even in current browsers (e.g. FF Nightly 75). | |
emscripten_get_now: () => {{{ getPerformanceNow() }}}(), |
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.
Good to know, thanks.
b70f88c
to
81bcaa2
Compare
cf23f0e
to
aa78b84
Compare
1c4834e
to
cbd6be7
Compare
The futex tests fails, worker spinlocks are more appropriate
(To be refined)
cbd6be7
to
2dcfb14
Compare
Fix for #22962. The fixes include:
(The
git mv
lost the old to new mapping at some point)