Restricted JS Execution Contexts
Various Web platform features have a need for script to run in "restricted contexts", where some features accessible to regular main-thread page JS are not available.
Contents
Audio Workers
Web Audio wants an "audio worker" --- processing audio samples on a real-time audio thread. Hopefully small snippets of code doing small amounts of work on each callback (e.g. processing 128 audio samples).
Vertex Shaders
For CSS Filter-ish use-cases, we want to be able to generate meshes by applying a JS function to vertices of a grid, mapping 2D points to 2D points.
UI Workers
When the compositor is rendering a frame, it might want to call into a "UI worker" to apply Web-author generated effects that can't be implemented efficiently/smoothly on the main thread, e.g. computing new transform offsets for the rendering of particular elements.
CSS Style Callbacks
To extend the CSS style system, we want to provide callbacks that run during style computation to parse values and generate computed style values.
CSS Layout Callbacks
To extend CSS layout, we want to provide callbacks that run during layout, to layout the contents of container elements.
CSS Painting Callbacks
To extend CSS painting, we want to provide callbacks that run during painting, to paint the contents of elements.
API | Work per callback | Retain state between callbacks? | Isolated worlds per page | Impose time limit | Send/receive messages | Other Web platform APIs needed | Need to prevent access to other APIs |
Audio workers | Very little | Yes | dozens | Yes | Yes | Minimal | No |
Vertex shaders | Very little | No | flexible | Maybe | No | Minimal | Maybe |
UI workers | Little | Yes | Few | Yes | Yes | Canvas, maybe others | No |
CSS style extensions | Very little | No | lots | No | No | Minimal | Yes |
CSS layout extensions | Lots (e.g. constraint solving) | Yes (caching) | potentially lots | No | No | Minimal | Yes |
CSS painting extensions | Potentially a lot | probably not | dozens | No | No | Canvas | Yes |