@@ -1783,14 +1783,8 @@ context=] for a given |box|, |childBoxes| it <em>must</em> run the following ste
1783
1783
steps.
1784
1784
1785
1785
4. Let |workletGlobalScope| be a {{LayoutWorkletGlobalScope}} from the list of [=worklet's
1786
- WorkletGlobalScopes=] from the layout {{Worklet}} .
1787
-
1788
- The user agent <em> must</em> have, and select from at least two
1789
- {{LayoutWorkletGlobalScope}} s in the [=worklet's WorkletGlobalScopes=] [=list=] , unless the
1790
- user agent is under memory constraints.
1791
-
1792
- Note: This is to ensure that authors do not rely on being able to store state on the global
1793
- object or non-regeneratable state on the class.
1786
+ WorkletGlobalScopes=] from the layout {{Worklet}} , following the rules defined in
1787
+ [[#global-scope-selection]] .
1794
1788
1795
1789
The user agent <em> may</em> also [=create a WorkletGlobalScope=] at this time, given the
1796
1790
layout {{Worklet}} .
@@ -1902,14 +1896,8 @@ it <em>must</em> run the following steps:
1902
1896
steps.
1903
1897
1904
1898
4. Let |workletGlobalScope| be a {{LayoutWorkletGlobalScope}} from the list of [=worklet's
1905
- WorkletGlobalScopes=] from the layout {{Worklet}} .
1906
-
1907
- The user agent <em> must</em> have, and select from at least two
1908
- {{LayoutWorkletGlobalScope}} s in the [=worklet's WorkletGlobalScopes=] [=list=] , unless the
1909
- user agent is under memory constraints.
1910
-
1911
- Note: This is to ensure that authers do not rely on being able to store state on the global
1912
- object or non-regeneratable state on the class.
1899
+ WorkletGlobalScopes=] from the layout {{Worklet}} , following the rules defined in
1900
+ [[#global-scope-selection]] .
1913
1901
1914
1902
The user agent <em> may</em> also [=create a WorkletGlobalScope=] at this time, given the
1915
1903
layout {{Worklet}} .
@@ -2037,6 +2025,22 @@ following steps:
2037
2025
2038
2026
</div>
2039
2027
2028
+ ### Global Scope Selection ### {#global-scope-selection}
2029
+
2030
+ When the user agent needs to select a {{LayoutWorkletGlobalScope}} from the layout [=worklet's
2031
+ WorkletGlobalScopes=] [=list=] it <em> must</em> :
2032
+
2033
+ - Select from at <em> least</em> two {{LayoutWorkletGlobalScope}} s, unless the user agent is
2034
+ under memory constraints.
2035
+
2036
+ - <em> Not</em> re-use the same {{LayoutWorkletGlobalScope}} more than 1000 times in a row.
2037
+
2038
+ Note: The 1000 limit was picked as a high upper bound, this limit may improve (downwards)
2039
+ over time.
2040
+
2041
+ Note: These rules exist to ensure that authors do not rely on being able to store state on the
2042
+ global object or non-regeneratable state on the class. See [[worklets-1#code-idempotency]] .
2043
+
2040
2044
### Utility Algorithms ### {#utility-algorithms}
2041
2045
2042
2046
The section specifies algorithms common to the [=determine the intrinsic sizes=] and [=generate
0 commit comments