Skip to content
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

[worklets] Make "Code Idempotency" section normative and stronger #308

Closed
SimonSapin opened this issue Sep 19, 2016 · 4 comments
Closed
Assignees

Comments

@SimonSapin
Copy link

https://drafts.css-houdini.org/worklets/#code-idempotency is a non-normative section that starts with:

Multiple instances of WorkletGlobalScope can be created for each Worklet that they belong to. User agents may choose to do this in order to parallelize work over multiple threads, or to move work between threads as required.

In order to help make that possible, it goes on with content such as:

authors […] should make their code idempotent.

User agents may choose to always have at least two WorkletGlobalScopes per Worklet

I think this is not enough. If one major implementation ships for example CSS Layout API without these "may" precautions, it is likely that many websites will rely and worklet methods being executing in a certain order and in the same global scope. This might effectively make parallelization web-incompatible.

I’d like to make this section normative, and have it specify "must" requirements for user-agents. The details can be discussed, but one idea is to use JavaScript Frozen Realms to make the global scope immutable (or have an immutable prototype so that creating a new global scope with that same prototype is cheap and could be done for every call).

CC @tschneidereit

@RByers
Copy link
Contributor

RByers commented Sep 22, 2016

Note that some uses cases (eg. animationworklet) absolutely need some way to pass state from one invocation to the next in a serial fashion. But this can be explicit according to some contract, not depending on the global object.

@SimonSapin
Copy link
Author

From today’s meeting:

RESOLVED: Paint/Layout specs will have normative section that implementations must have at least 2 globals with an opt-out for memory constraints.

@RByers when such state needs to be passed around, I think it should be explicit though parameters and return values rather than implicit side effects.

@RByers
Copy link
Contributor

RByers commented Sep 22, 2016

@RByers when such state needs to be passed around, I think it should be explicit though parameters and return values rather than implicit side effects.

Absolutely. See the above issue for one example of how we're doing this in a demo.

@esprehn
Copy link

esprehn commented Sep 23, 2016

re FrozenRealms they require freezing all of the globals and all of prototypes of everything which means you can't use polyfills or work around API bugs easily. They also have some serious restrictions:
https://github.com/FUDCo/proposal-frozen-realms#date-and-math It's also not clear how they interact with ES modules, for example I think modules can do "default export []" and export a mutable array, and modules are de-duplicated, so now you have global state to deal with.

bfgeek added a commit that referenced this issue Apr 13, 2017
Fixes #384.

Fixes #308. (There is a separate issue for adding the 2
    WorkletGlobalScopes requirement for css-paint-api).
bfgeek added a commit that referenced this issue Apr 14, 2017
Fixes #384.

Fixes #308. (There is a separate issue for adding the 2
    WorkletGlobalScopes requirement for css-paint-api).
@tabatkins tabatkins removed the ready label Apr 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants