@@ -99,28 +99,29 @@ expected to be shared between separate scripts. This is similar to the <a>docume
9999Code Idempotency {#code-idempotency}
100100------------------------------------
101101
102- <em> This section is not normative.</em>
103-
104- Multiple instances of {{WorkletGlobalScope}} can be created for each {{Worklet}} that they belong
105- to. User agents may choose to do this in order to parallelize work over multiple threads, or to move
106- work between threads as required.
102+ Some specifications which use worklets ([[css-paint-api-1]] ), allow user agents to parallelize work
103+ over multiple threads, or to move work between threads as required.
107104
108- Additionally different user agents may invoke a method on a class in a different order to other user
109- agents.
105+ In these specifications user agents might invoke methods on a class in a different order to other
106+ user agents.
110107
111108As a result of this, to prevent this compatibility risk between user agents, authors who register
112- classes on the global scope should make their code idempotent. That is, a method or set of methods
113- on a class should produce the same output given a particular input.
109+ classes on the global scope using these APIs, should make their code idempotent. That is, a method
110+ or set of methods on a class should produce the same output given a particular input.
111+
112+ The following techniques are used in order to encourage authors to write code in an idempotent way:
114113
115- The following techniques should be used in order to encourage authors to write code in an idempotent
116- way:
117114 - No reference to the global object, e.g. <a>self</a> on a {{DedicatedWorkerGlobalScope}} .
115+
118116 - Code is loaded as a <a>module script</a> which resulting in the code being executed in <a>strict
119117 mode code</a> without a shared this. This prevents two different module scripts sharing
120118 state be referencing shared objects on the global scope.
121- - User agents may choose to always have at least two {{WorkletGlobalScope}} s per {{Worklet}} and
122- randomly assign a method or set of methods on a class to a particular global scope.
123- - User agents may create and destroy {{WorkletGlobalScope}} s at any time.
119+
120+ - These specifications must require user agents to always have at least two {{WorkletGlobalScope}} s
121+ per {{Worklet}} and randomly assign a method or set of methods on a class to a particular
122+ global scope. These specifications can provide an opt-out under memory constraints.
123+
124+ - User agents can create and destroy {{WorkletGlobalScope}} s at any time for these specifications.
124125
125126Infrastructure {#infrastructure}
126127================================
@@ -366,7 +367,11 @@ When the <dfn method for=Worklet>import(|moduleURL|, |options|)</dfn> method is
366367
367368 2. Add the {{WorkletGlobalScope}} to <a>worklet's WorkletGlobalScopes</a> .
368369
369- The user agent may also create additional {{WorkletGlobalScope}} s at this time.
370+ Depending on the type of worklet the user agent may create additional
371+ {{WorkletGlobalScope}} s at this time.
372+
373+ Note: Specifically the [[css-paint-api-1]] allows for multiple global scopes, while the
374+ [[webaudio]] API does not.
370375
371376 Wait for this step to complete before continuing.
372377
0 commit comments