Open Bug 1572644 Opened 2 years ago Updated 2 months ago

Support "import" in worklet scripts

Categories

(Core :: DOM: Core & HTML, enhancement, P3)

enhancement

Tracking

()

Tracking Status
firefox70 --- affected

People

(Reporter: karlt, Unassigned, NeedInfo)

References

(Depends on 1 open bug, Blocks 2 open bugs)

Details

+++ This bug was initially created as a clone of Bug #1473463 +++

ScriptLoader supports fetching module script graphs but currently has a number of main-thread-only characteristics. The approach proposed in bug 1311726 would permit using this from worklet code.

Jon said in https://bugzilla.mozilla.org/show_bug.cgi?id=1290021#c34
"It would be really great if we could reuse some of the code in the script
loader (and would be useful for other efforts, e.g. bug 1308512). This is not
trivial unfortunately. I think it would require factoring out the module
loader into a separate class with a caller-provided a fetch interface passed
in."
This would be bug 1311726.

Andrea said in https://bugzilla.mozilla.org/show_bug.cgi?id=1472324#c1
'we must unify WorkletFetchHandler,
workerinternals::Load/LoadMainScript and mozilla::dom::ScriptLoader.'

Ben said in https://bugzilla.mozilla.org/show_bug.cgi?id=1442776#c1
"Would it not be possible to make worklets and workers completely separate?
Decoupling them seems like it would be nice for maintenance since they are
going to be fairly different."
That probably means that any shared code should be in or near ScriptLoader,
rather than in dom/worklers.

Houdini WG said in
https://github.com/w3c/css-houdini-drafts/issues/506#issuecomment-343276228
"RESOLVED: dynamic import() in worklets is a no-op that returns a rejected
promise (or equivalent after passing thru JS people)"

Web platform tests expect static import to work.
https://github.com/w3c/css-houdini-drafts/issues/506#issuecomment-342796390

Blocks: 1473176

It would be great if we could revisit priorities here. People expect imports to work in AudioWorklet, that we just enabled in Nightly (it's supposed to work per spec, and it works in Chromium). I'm seeing some websites that rely on this. AudioWorklet usage is still not widespread however.

https://superpowered.com/webbrowserlatency
https://mtg.github.io/essentia.js/examples
https://googlechromelabs.github.io/web-audio-samples/audio-worklet/

Flags: needinfo?(htsai)

(In reply to Paul Adenot (:padenot) from comment #1)

It would be great if we could revisit priorities here. People expect imports to work in AudioWorklet, that we just enabled in Nightly (it's supposed to work per spec, and it works in Chromium). I'm seeing some websites that rely on this. AudioWorklet usage is still not widespread however.

https://superpowered.com/webbrowserlatency
https://mtg.github.io/essentia.js/examples
https://googlechromelabs.github.io/web-audio-samples/audio-worklet/

Thanks for raising this. Would take to our roadmap planning discussion. :)

Flags: needinfo?(htsai)

Also bringing this to the attention of Adam and Jens.

Flags: needinfo?(jstutte)
Flags: needinfo?(astevenson)

(In reply to Hsin-Yi Tsai [:hsinyi] from comment #2)

(In reply to Paul Adenot (:padenot) from comment #1)

It would be great if we could revisit priorities here. People expect imports to work in AudioWorklet, that we just enabled in Nightly (it's supposed to work per spec, and it works in Chromium). I'm seeing some websites that rely on this. AudioWorklet usage is still not widespread however.

Here is one more Website using WASM in AudioWorklet: https://ssc.scorio.com/localtest.html

I'm part of a team using WASM in AudioWorklets, via Superpowered, and would greatly appreciate this feature! We are trying to add Mozilla support and facing complications because import is not supported.

http://samples.landr.com/

Blocks: 1636121
See Also: → 1247687
You need to log in before you can comment on or make changes to this bug.