Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement CSS Houdini Worklets #16206
Comments
|
This came up in the context of discussions about the embedding API, as a standards-aligned way to provide strong consistency guarantees between embedding JS code, layout and webrender. |
|
On irc, @tschneidereit pointed out the code idempotence requirement: https://drafts.css-houdini.org/worklets/#code-idempotency, which is not actually statelessness, but is very close. In particular, a UA is allowed to generate a fresh global for each execution. Not sure what this would do for efficiency though, as scripts might assume that fresh globals aren't allocated very often, e.g. to perform some script initialization. |
|
Fresh globals are reportedly too expensive to actually do this, so there is language about modified designs (ie, rotating two pre-allocated globals) added. If the implementation does nothing to preserve idempotency, we are likely to lose it, and any potential for parallelism along with it. |
|
My current thinking of how to implement this is to provide a per-process thread pool for executing worklets. The main challenge would be to try to avoid GC during worklet execution, which we could do by monitoring their memory use, and removing high-memory-usage executors from the pool while they gc. |
|
@metajack yes, generating a fresh global on every execution might be too expensive, but possibly we could freshen the global periodically, e.g. when the executor is GC'ing? |
|
IRC chat with @tschneidereit and @metajack: http://logs.glob.uno/?c=mozilla%23servo&s=31+Mar+2017&e=31+Mar+2017#c643173 TL;DR we'd like to get to an API where there's an explicit initialization phase, during which script has r/w access to the realm, followed by execution, which is in a frozen realm (https://github.com/FUDCo/proposal-frozen-realms). But we can't block worklets on frozen realms, so we're left with just spec language, which doesn't help if webcompat ends up just being everyone assumes stateful worklets. |
|
IRC chat with @jdm: http://logs.glob.uno/?c=mozilla%23servo&s=3+Apr+2017&e=3+Apr+2017#c644051 TL;DR: worklets are based on ES6 modules, which aren't in SM yet. |
|
IRC chat with @SimonSapin: http://logs.glob.uno/?c=mozilla%23servo&s=5+Apr+2017&e=5+Apr+2017#c645966 TL;DR: stylo shouldn't be a big factor. |
Implement Houdini worklets <!-- Please describe your changes on the following line: --> This PR implements the current draft Houdini Worklets specification (https://drafts.css-houdini.org/worklets/). The implementation is intended to provide a responsive environment for worklet execution, and in particular to ensure that the primary worklet executor does not garbage collect, and does not block loading module code. The implementation does this by providing a thread pool, and performing GC and module loading in a backup thread, not in the primary thread. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #16206 - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16814) <!-- Reviewable:end -->
Implement Houdini worklets <!-- Please describe your changes on the following line: --> This PR implements the current draft Houdini Worklets specification (https://drafts.css-houdini.org/worklets/). The implementation is intended to provide a responsive environment for worklet execution, and in particular to ensure that the primary worklet executor does not garbage collect, and does not block loading module code. The implementation does this by providing a thread pool, and performing GC and module loading in a backup thread, not in the primary thread. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #16206 - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16814) <!-- Reviewable:end -->
Draft spec: https://drafts.css-houdini.org/worklets/
Houdini CSS issue for servo: #13557
cc @tschneidereit @metajack @jdm @SimonSapin