@@ -99,28 +99,29 @@ expected to be shared between separate scripts. This is similar to the <a>docume
99
99
Code Idempotency {#code-idempotency}
100
100
------------------------------------
101
101
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.
107
104
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.
110
107
111
108
As 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:
114
113
115
- The following techniques should be used in order to encourage authors to write code in an idempotent
116
- way:
117
114
- No reference to the global object, e.g. <a>self</a> on a {{DedicatedWorkerGlobalScope}} .
115
+
118
116
- Code is loaded as a <a>module script</a> which resulting in the code being executed in <a>strict
119
117
mode code</a> without a shared this. This prevents two different module scripts sharing
120
118
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.
124
125
125
126
Infrastructure {#infrastructure}
126
127
================================
@@ -366,7 +367,11 @@ When the <dfn method for=Worklet>import(|moduleURL|, |options|)</dfn> method is
366
367
367
368
2. Add the {{WorkletGlobalScope}} to <a>worklet's WorkletGlobalScopes</a> .
368
369
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.
370
375
371
376
Wait for this step to complete before continuing.
372
377
0 commit comments