Skip to content

Commit 92b90bd

Browse files
tdresserdomenic
authored andcommitted
Integrate with the Paint Timing spec
This eliminates Paint Timing's monkey patching, and fixes some minor issues with when we mark paint timing. It does so by introducing the new concept of "rendering opportunity", which roughly maps to frame rate, but in a model-agnostic way. This also lays the groundwork necessary to correctly report event duration for the Event Timing spec, per the issue at w3c/event-timing#6.
1 parent 34cc15a commit 92b90bd

File tree

1 file changed

+64
-36
lines changed

1 file changed

+64
-36
lines changed

source

Lines changed: 64 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,6 +2880,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
28802880
<li><dfn data-x-href="https://w3c.github.io/webappsec-mixed-content/#a-priori-authenticated-url"><i>a priori</i> authenticated URL</dfn></li>
28812881
</ul>
28822882

2883+
<p>The following terms are defined in <cite>Paint Timing</cite>: <ref spec=PAINTTIMING></p>
2884+
2885+
<ul class="brief">
2886+
<li><dfn data-x-href="https://w3c.github.io/paint-timing/#mark-paint-timing">mark paint timing</dfn></li>
2887+
</ul>
2888+
28832889
</dd>
28842890

28852891

@@ -89134,45 +89140,63 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
8913489140
</li>
8913589141

8913689142
<li>
89137-
<p>If there are <span data-x="top-level browsing context">top-level browsing contexts</span>
89138-
<var>B</var> that the user agent believes would not benefit from having their rendering
89139-
updated at this time, then remove from <var>docs</var> all <code>Document</code> objects whose
89140-
<span data-x="concept-document-bc">browsing context</span>'s <span>top-level browsing
89141-
context</span> is in <var>B</var>.</p>
89142-
89143-
<div class="note">
89144-
<p>Whether a <span>top-level browsing context</span> would benefit from having its rendering
89145-
updated depends on various factors, such as the update frequency. For example, if the browser
89146-
is attempting to achieve a 60Hz refresh rate, then these steps are only necessary every 60th
89147-
of a second (about 16.7ms). If the browser finds that a <span>top-level browsing
89148-
context</span> is not able to sustain this rate, it might drop to a more sustainable 30Hz for
89149-
that set of <code>Document</code>s, rather than occasionally dropping frames. (This
89150-
specification does not mandate any particular model for when to update the rendering.)
89151-
Similarly, if a <span>top-level browsing context</span> is in the background, the user agent
89152-
might decide to drop that page to a much slower 4Hz, or even less.</p>
89153-
89154-
<p>Another example of why a browser might skip updating the rendering is to ensure certain
89155-
<span data-x="concept-task">tasks</span> are executed immediately after each other, with only
89156-
<span data-x="perform a microtask checkpoint">microtask checkpoints</span> interleaved (and
89157-
without, e.g., <span data-x="run the animation frame callbacks">animation frame
89158-
callbacks</span> interleaved). For example, a user agent might wish to coalesce timer
89159-
callbacks together, with no intermediate rendering updates.</p>
89160-
</div>
89143+
<p><i>Rendering opportunites</i>: If there are <span data-x="browsing context">browsing
89144+
contexts</span> <var>browsingContexts</var> that do not have a <span>rendering
89145+
opportunity</span>, then remove from <var>docs</var> all <code>Document</code> objects whose
89146+
<span data-x="concept-document-bc">browsing context</span> is in
89147+
<var>browsingContexts</var>.</p>
89148+
89149+
<p>A <span>browsing context</span> has a <dfn>rendering opportunity</dfn> if the user agent is
89150+
currently able to present the contents of the <span>browsing context</span> to the user,
89151+
accounting for hardware refresh rate constraints and user agent throttling for performance
89152+
reasons, but considering content presentable even if it's outside the viewport.</p>
89153+
89154+
<p><span>Browsing context</span> <span data-x="rendering opportunity">rendering
89155+
opportunities</span> are determined based on hardware constraints such as display refresh
89156+
rates and other factors such as page performance or whether the page is in the background.
89157+
Rendering opportunities typically occur at regular intervals.</p>
89158+
89159+
<p class="note">This specification does not mandate any particular model for selecting
89160+
rendering opportunities. But for example, if the browser is attempting to achieve a 60Hz
89161+
refresh rate, then rendering opportunities occur at a maximum of every 60th of a second (about
89162+
16.7ms). If the browser finds that a <span>browsing context</span> is not able to sustain this
89163+
rate, it might drop to a more sustainable 30 rendering opportunities per second for that
89164+
<span>browsing context</span>, rather than occasionally dropping frames. Similarly, if a
89165+
<span>browsing context</span> is not visible, the user agent might decide to drop that page to
89166+
a much slower 4 rendering opportunities per second, or even less.</p>
8916189167
</li>
8916289168

89169+
<li><p><i>Unnecessary rendering</i>: If there are <span data-x="browsing context">browsing
89170+
contexts</span> <var>browsingContexts</var> for which the user agent believes updating the
89171+
rendering would have no visible effect and which possess no <code>Document</code> objects with
89172+
a non-empty <span>list of animation frame callbacks</span>, then remove from <var>docs</var>
89173+
all <code>Document</code> objects whose <span data-x="concept-document-bc">browsing
89174+
context</span> is in <var>browsingContexts</var>. Invoke the <span>mark paint timing</span>
89175+
algorithm for each <code>Document</code> object removed.</p></li>
89176+
8916389177
<li>
89164-
<p>If there are a <span data-x="nested browsing context">nested browsing contexts</span>
89165-
<var>B</var> that the user agent believes would not benefit from having their rendering
89166-
updated at this time, then remove from <var>docs</var> all <code>Document</code> objects whose
89167-
<span data-x="concept-document-bc">browsing context</span> is in <var>B</var>.</p>
89168-
89169-
<p class="note">As with <span data-x="top-level browsing context">top-level browsing
89170-
contexts</span>, a variety of factors can influence whether it is profitable for a browser to
89171-
update the rendering of <span data-x="nested browsing context">nested browsing
89172-
contexts</span>. For example, a user agent might wish to spend less resources rendering
89173-
third-party content, especially if it is not currently visible to the user or if resources are
89174-
constrained. In such cases, the browser could decide to update the rendering for such content
89175-
infrequently or never.</p>
89178+
<p>If there are <span data-x="browsing context">browsing contexts</span>
89179+
<var>browsingContexts</var> for which the user agent believes it's preferrable to skip
89180+
updating the rendering for other reasons, then remove from <var>docs</var> all
89181+
<code>Document</code> objects whose <span data-x="concept-document-bc">browsing context</span>
89182+
is in <var>browsingContexts</var>.</p>
89183+
89184+
<div class="note">
89185+
<p>The step labeled <i>Rendering opportunities</i> prevents the user agent from updating the
89186+
rendering when it is unable to present new content to the user (there's no <span>rendering
89187+
opportunity</span>).</p>
89188+
89189+
<p>The step labeled <i>Unnecessary rendering</i> prevents the user agent from updating the
89190+
rendering when there's no new content to draw.</p>
89191+
89192+
<p>This step enables the user agent to prevent the steps below from running for other
89193+
reasons, for example, to ensure certain <span data-x="concept-task">tasks</span> are executed
89194+
immediately after each other, with only <span data-x="perform a microtask
89195+
checkpoint">microtask checkpoints</span> interleaved (and without, e.g., <span data-x="run
89196+
the animation frame callbacks">animation frame callbacks</span> interleaved). Concretely, a
89197+
user agent might wish to coalesce timer callbacks together, with no intermediate rendering
89198+
updates.</p>
89199+
</div>
8917689200
</li>
8917789201

8917889202
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, <span>run
@@ -89203,6 +89227,9 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
8920389227
the update intersection observations steps</span> for that <code>Document</code>, passing in
8920489228
<var>now</var> as the timestamp. <ref spec="INTERSECTIONOBSERVER"></p></li>
8920589229

89230+
<li><p>Invoke the <span>mark paint timing</span> algorithm for each <code>Document</code>
89231+
object in <var>docs</var>.</p></li>
89232+
8920689233
<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, update the
8920789234
rendering or user interface of that <code>Document</code> and its <span
8920889235
data-x="concept-document-bc">browsing context</span> to reflect the current state.</p></li>
@@ -121911,6 +121938,7 @@ INSERT INTERFACES HERE
121911121938
Thomas Koetter,
121912121939
Thomas O'Connor,
121913121940
Tim Altman,
121941+
Tim Dresser,
121914121942
Tim Johansson,
121915121943
Tim Perry,
121916121944
Tim van der Lippe,

0 commit comments

Comments
 (0)