-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[AUDIO_WORKLET] Support locateFile when loading audio worklet js file #20318
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] Support locateFile when loading audio worklet js file #20318
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.
I'm running into this issue as well. The fix looks correct IMO.
Needs rebase & conflict fix. |
src/library_webaudio.js
Outdated
@@ -169,7 +169,7 @@ let LibraryWebAudio = { | |||
} | |||
|
|||
// TODO: In MINIMAL_RUNTIME builds, read this file off of a preloaded Blob, and/or embed from a string like with WASM_WORKERS==2 mode. | |||
audioWorklet.addModule('{{{ TARGET_BASENAME }}}.aw.js').then(() => { | |||
audioWorklet.addModule(locateFile('{{{ TARGET_BASENAME }}}.aw.js')).then(() => { |
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.
Does locateFile
exist under MINIMAL_RUNTIME
?
Can we get a test for this?
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.
That too, yeah.
Ideally, I'd rather merge aw.js into main JS, just like we did for pthread workers - there's nothing stopping it, and it would result in one less tiny file to download and worry about.
For now, any fix would be great though, given how long it's been broken.
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 updated the PR, however I don't now how do you want to test this.
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.
Finally it didn't pass the existing tests anyway
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.
For testing, you could copy one of the existing audio worklet tests in test_browser.py but generate the JS in a subfolder - that should reproduce the original issue.
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.
The existing tests are already parameterised over various compile options, so should be able to check MINIMAL_RUNTIME vs MODULARIZE vs others as well.
…into audio_worklets_module_locate_file # Conflicts: # src/lib/libwebaudio.js
This change would be of great help for me! Would love to see this added <3 |
@@ -183,7 +183,7 @@ let LibraryWebAudio = { | |||
|
|||
// TODO: In MINIMAL_RUNTIME builds, read this file off of a preloaded Blob, | |||
// and/or embed from a string like with WASM_WORKERS==2 mode. | |||
audioWorklet.addModule('{{{ TARGET_BASENAME }}}.aw.js').then(() => { | |||
audioWorklet.addModule(locateFile('{{{ TARGET_BASENAME }}}.aw.js')).then(() => { |
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.
How about
audioWorklet.addModule(
#if MINIMAL_RUNTIME
'{{{ TARGET_BASENAME }}}.aw.js'
#else
locateFile('{{{ TARGET_BASENAME }}}.aw.js')
#endif
).then(() => {
The locateFile
function does not currently exist in MINIMAL_RUNTIME
.
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 think we also need the new URL(...)
pattern here as well for ES6 bundlers.
Essentially copy the pattern from regular ww.js workers.
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.
@sbc100 At this point, maybe this should be a parseTools macro for arbitrary resources?
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.
If you can think of way to express that that SGTM
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.
Since original PR author might not be around, I posted a PR #24044 to gate the MINIMAL_RUNTIME part, and add a test.
parseTools macro and ES6 bundlers are good ideas that can be added in later PRs.
Fixes: #20316