Skip to content

Eliminate paint timing monkey patching #3923

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

Merged
merged 12 commits into from
Aug 16, 2018
97 changes: 61 additions & 36 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2877,6 +2877,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li><dfn data-x-href="https://w3c.github.io/webappsec-mixed-content/#a-priori-authenticated-url"><i>a priori</i> authenticated URL</dfn></li>
</ul>

<p>The following terms are defined in <cite>Paint Timing</cite>: <ref spec=PAINTTIMING></p>

<ul class="brief">
<li><dfn data-x-href="https://w3c.github.io/paint-timing/#mark-paint-timing">mark paint timing</dfn></li>
</ul>

</dd>


Expand Down Expand Up @@ -88993,45 +88999,60 @@ dictionary <dfn>PromiseRejectionEventInit</dfn> : <span>EventInit</span> {
</li>

<li>
<p>If there are <span data-x="top-level browsing context">top-level browsing contexts</span>
<var>B</var> that the user agent believes would not benefit from having their rendering
updated at this time, then remove from <var>docs</var> all <code>Document</code> objects whose
<span data-x="concept-document-bc">browsing context</span>'s <span>top-level browsing
context</span> is in <var>B</var>.</p>

<div class="note">
<p>Whether a <span>top-level browsing context</span> would benefit from having its rendering
updated depends on various factors, such as the update frequency. For example, if the browser
is attempting to achieve a 60Hz refresh rate, then these steps are only necessary every 60th
of a second (about 16.7ms). If the browser finds that a <span>top-level browsing
context</span> is not able to sustain this rate, it might drop to a more sustainable 30Hz for
that set of <code>Document</code>s, rather than occasionally dropping frames. (This
specification does not mandate any particular model for when to update the rendering.)
Similarly, if a <span>top-level browsing context</span> is in the background, the user agent
might decide to drop that page to a much slower 4Hz, or even less.</p>

<p>Another example of why a browser might skip updating the rendering is to ensure certain
<span data-x="concept-task">tasks</span> are executed immediately after each other, with only
<span data-x="perform a microtask checkpoint">microtask checkpoints</span> interleaved (and
without, e.g., <span data-x="run the animation frame callbacks">animation frame
callbacks</span> interleaved). For example, a user agent might wish to coalesce timer
callbacks together, with no intermediate rendering updates.</p>
</div>
<p><i>Rendering opportunites</i>: If there are <span data-x="browsing context">browsing
contexts</span> <var>B</var> that do not have a <span>rendering opportunity</span>, then
remove from <var>docs</var> all <code>Document</code> objects whose <span
data-x="concept-document-bc">browsing context</span> is <var>B</var>.</p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this context, B is a list of browsing contexts, so I think this was correct previously?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, great catch. I'll rename to "browsingContexts" for clarity. (There is also a "B" up in step 7.2, which technically doesn't collide.)


<p>A <span>browsing context</span> has a <dfn>rendering opportunity</dfn> if the user agent is
currently able to present the contents of the <span>browsing context</span> to the user,
accounting for hardware refresh rate constraints and user agent throttling for performance
reasons, but considering content presentable even if it's outside the viewport.</p>

<p class="note"><span>Browsing context</span> <span data-x="rendering opportunity">rendering
opportunities</span> are determined based on hardware constraints such as display refresh
rates and other factors such as page performance or whether the page is in the background.
Rendering opportunities typically occur at regular intervals. For example, if the browser is
attempting to achieve a 60Hz refresh rate, then rendering opportunities occur at a maximum of
every 60th of a second (about 16.7ms). If the browser finds that a <span>browsing
context</span> is not able to sustain this rate, it might drop to a more sustainable 30
rendering opportunities per second for that <span>browsing context</span>, rather than
occasionally dropping frames. (This specification does not mandate any particular model for
selecting rendering opportunities.) Similarly, if a <span>browsing context</span> is not
visible, the user agent might decide to drop that page to a much slower 4 rendering
opportunities per second, or even less.</p>
</li>

<li><p><i>Unnecessary rendering</i>: If there are <span data-x="browsing context">browsing
contexts</span> <var>B</var> for which the user agent believes updating the rendering would
have no visible effect and which possess no <code>Document</code> objects with a non-empty
<span>list of animation frame callbacks</span>, then remove from <var>docs</var> all
<code>Document</code> objects whose <span data-x="concept-document-bc">browsing context</span>
is in <var>B</var>. Invoke the <span>mark paint timing</span> algorithm for each
<code>Document</code> object removed.</p></li>

<li>
<p>If there are a <span data-x="nested browsing context">nested browsing contexts</span>
<var>B</var> that the user agent believes would not benefit from having their rendering
updated at this time, then remove from <var>docs</var> all <code>Document</code> objects whose
<span data-x="concept-document-bc">browsing context</span> is in <var>B</var>.</p>

<p class="note">As with <span data-x="top-level browsing context">top-level browsing
contexts</span>, a variety of factors can influence whether it is profitable for a browser to
update the rendering of <span data-x="nested browsing context">nested browsing
contexts</span>. For example, a user agent might wish to spend less resources rendering
third-party content, especially if it is not currently visible to the user or if resources are
constrained. In such cases, the browser could decide to update the rendering for such content
infrequently or never.</p>
<p>If there are <span data-x="browsing context">browsing contexts</span> <var>B</var> for
which the user agent believes it's preferrable to skip updating the rendering for other
reasons, then remove from <var>docs</var> all <code>Document</code> objects whose <span
data-x="concept-document-bc">browsing context</span> is in <var>B</var>.</p>

<div class="note">
<p>The step labeled <i>Rendering opportunities</i> prevents the user agent from updating the
rendering when it is unable to present new content to the user (there's no <span>rendering
opportunity</span>).</p>

<p>The step labeled <i>Unnecessary rendering</i> prevents the user agent from updating the
rendering when there's no new content to draw.</p>

<p>This step enables the user agent to prevent the steps below from running for other
reasons, for example, to ensure certain <span data-x="concept-task">tasks</span> are executed
immediately after each other, with only <span data-x="perform a microtask
checkpoint">microtask checkpoints</span> interleaved (and without, e.g., <span data-x="run
the animation frame callbacks">animation frame callbacks</span> interleaved). Concretely, a
user agent might wish to coalesce timer callbacks together, with no intermediate rendering
updates.</p>
</div>
</li>

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

<li><p>Invoke the <span>mark paint timing</span> algorithm for each <code>Document</code>
object in <var>docs</var>.</p></li>

<li><p>For each <span>fully active</span> <code>Document</code> in <var>docs</var>, update the
rendering or user interface of that <code>Document</code> and its <span
data-x="concept-document-bc">browsing context</span> to reflect the current state.</p></li>
Expand Down Expand Up @@ -121407,6 +121431,7 @@ INSERT INTERFACES HERE
Thomas Koetter,
Thomas O'Connor,
Tim Altman,
Tim Dresser,
Tim Johansson,
Tim Perry,
Tim van der Lippe,
Expand Down