-
Notifications
You must be signed in to change notification settings - Fork 168
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
atob() is missing in AudioWorkletGlobalScope #2553
Comments
A It intentionally has nothing in its interface, just what ECMAScript provides and of course the I'd like to understand the reason why Reading the thread you linked, it seems to be during initialization -- at this moment in the user's app, the audio isn't flowing, so we don't have real-time constraints. If that's the case, the preferable way to do this is to decode the data into a buffer (from the main thread or worker thread if it's large, and we don't want to block), and transfer the data using Let me know if we can help further. |
This comment was marked as off-topic.
This comment was marked as off-topic.
The intent with Wasm Audio Worklets is to provide Wasm developers a function callback entrypoint that they can implement in their same codebase as the rest of their C/C++ program. To support this, we want to load the same shared .wasm Module and Memory in the Wasm Audio Worklet as the main thread and other Workers use. This also implies that the same main .js file is loaded, since that defines the wasm imports and exports. However that causes the issues, because the same built-in JS APIs are not available in the Audio Worklet. So code sharing becomes unfeasible, or requires manually reimplementing polyfills for all these APIs. JS functions such as atob(), performance.now(), TextDecoder/Encoder and Math.*() are commonly used in the shared JS code, many only at the initial parsing state. atob() for example can be used to decode an embedded wasm data section. I think the philosophy of ”providing nothing” in the audio global scope is conflicting with the important use case of sharing code with audio worklet and other JS threads. Wouldn’t it be better to have consistency and parity in Audio Worklets with respect to the other JS computing contexts? |
@juj Wouldn't it be better from an architectural standpoint to load the wasm code only once on the main thread and transfer it to the worklet and the workers instead of loading it on the main thread, the worklet, and the workers? It's of course possible that I missed something obvious here. |
That is what Emscripten does. Wasm Module is passed to Audio Worklet and Audio Worklet instantiates the Module (or in MINIMAL_RUNTIME build mode in a more optimized fashion that reuses more JS code between audio worklet and main thread/worker thread JS) But because of the issue that Audio Worklets don't get most of the same global APIs, this JS code sharing results in ifdeffing and gating to guard against Audio Worklet scope missing things. In addition to |
@juj thanks for your response. Is Emscripten using these APIs at runtime? I always thought they are only used when preparing the binary response during compilation. That's why I thought |
They could be called either at global JS scope of the reused JS file, or as a JS library function that is called from Wasm.
Yes, it does. See AudioWorklet does not have performance.now. |
Related: #2499 |
In emscripten-core/emscripten#19845 (comment) a developer has observed that
atob()
is missing inAudioWorkletGlobalScope
, even though the function is available inWorkletGlobalScope
.The function was expected to be there since AudioWorkletGlobalScope inherits from WorkletGlobalScope ([1], [2]).
Could the function be added?
The text was updated successfully, but these errors were encountered: