Skip to content

Eliminate Paint Timing monkey patching #1

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 5 commits into from
Aug 15, 2018
Merged

Conversation

tdresser
Copy link
Owner

@tdresser tdresser commented Jul 5, 2018

No description provided.

source Outdated
<p>A <span>browsing context</span> has a rendering opportunity 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 presented even if it's outside the viewport.</p>
Copy link
Owner Author

Choose a reason for hiding this comment

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

This is messy, but I haven't come up with anything any better. Any thoughts?

Copy link

Choose a reason for hiding this comment

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

I'm generally quite impressed by how this is all phrased. I don't find this messy.

However, I'm unsure of the practical implications of "considering content presented even if it's outside the viewport". I guess it's saying that iframes are supposed to "have rendering opportunities" even if they're below the fold?

It seems like by this phrasing it'd be OK to throttle offscreen iframes down to 0 FPS "for performance reasons", but would not be OK to consider them to "not have a rendering opportunity" just because they're offscreen. Which is a bit weird, but maybe that's just because limiting behaviors are often weird.

Maybe it'd help to explicitly connect this to the below step, which allows removing for a wider variety of reasons. E.g. explicitly stating that this step just establishes "rendering opportunities", and the below step is where the browser decides whether to take advantage of the opportunity or not. Or maybe explicitly mentioning the term "frame rate".

Copy link
Owner Author

Choose a reason for hiding this comment

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

I've been explicitly avoiding "frame rate", as I'm worried we'd get pushback on the multi-display, or variable framerate cases (i.e. gsync)

Copy link
Owner Author

Choose a reason for hiding this comment

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

I've tried to clarify this. I also realized I was incorrectly handling the case where we coalesce tasks. We shouldn't mark paint timing in that case, but are doing so in this spec.

source Outdated
</li>

<li>
<p>If there are a <span data-x="nested browsing context">nested browsing contexts</span>
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not sure why we previously handled nested and top level browsing contexts independently. This seems clearer to me.

Copy link

Choose a reason for hiding this comment

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

It may have been incrementally added, and nobody thought to merge them.

@tdresser
Copy link
Owner Author

tdresser commented Jul 5, 2018

@domenic, can you take look at this? There are certainly rough bits, but I think this is approximately correct, based on what we discussed for event timing.

source Outdated
callbacks</span> interleaved). For example, a user agent might wish to coalesce timer
callbacks together, with no intermediate rendering updates.</p>
</div>
<p>If there are a <span data-x="browsing context">browsing contexts</span> <var>B</var> that
Copy link
Owner Author

Choose a reason for hiding this comment

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

Nit: "a browsing contexts" -> "browsing contexts"

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

Copy link

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Overall this looks quite solid. I think the more we can do to make clear the differences between the two "remove the document" steps, the better, but it's pretty reasonable already.

source Outdated
<p>A <span>browsing context</span> has a rendering opportunity 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 presented even if it's outside the viewport.</p>
Copy link

Choose a reason for hiding this comment

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

I'm generally quite impressed by how this is all phrased. I don't find this messy.

However, I'm unsure of the practical implications of "considering content presented even if it's outside the viewport". I guess it's saying that iframes are supposed to "have rendering opportunities" even if they're below the fold?

It seems like by this phrasing it'd be OK to throttle offscreen iframes down to 0 FPS "for performance reasons", but would not be OK to consider them to "not have a rendering opportunity" just because they're offscreen. Which is a bit weird, but maybe that's just because limiting behaviors are often weird.

Maybe it'd help to explicitly connect this to the below step, which allows removing for a wider variety of reasons. E.g. explicitly stating that this step just establishes "rendering opportunities", and the below step is where the browser decides whether to take advantage of the opportunity or not. Or maybe explicitly mentioning the term "frame rate".

source Outdated
</li>

<li>
<p>If there are a <span data-x="nested browsing context">nested browsing contexts</span>
<p>Invoke the <span>Mark Paint Timing</span> algorithm for each <code>Document</code> object
Copy link

Choose a reason for hiding this comment

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

Nit: lowercase algorithm names, usually.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
</li>

<li>
<p>If there are a <span data-x="nested browsing context">nested browsing contexts</span>
Copy link

Choose a reason for hiding this comment

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

It may have been incrementally added, and nobody thought to merge them.

source Outdated
<code>Document</code> objects whose <span data-x="concept-document-bc">browsing context</span>
is in <var>B</var>.</p>

<p>A <span>browsing context</span> has a rendering opportunity if the user agent is currently
Copy link

Choose a reason for hiding this comment

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

I think you'll want to <dfn> "rendering opportunity", and then cross-reference it where it's mentioned. It seems like a pretty useful concept.

https://github.com/whatwg/wattsi/blob/master/Syntax.md if you haven't seen it yet.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I was planning on doing this, but then couldn't figure out where to stick the definition. Any thoughts on where it should go?

Copy link

Choose a reason for hiding this comment

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

This sentence seems like a good place!

source Outdated
</li>

<li>
<p>If there are a <span data-x="nested browsing context">nested browsing contexts</span>
<p>Invoke the <span>Mark Paint Timing</span> algorithm for each <code>Document</code> object
Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
<p>A <span>browsing context</span> has a rendering opportunity 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 presented even if it's outside the viewport.</p>
Copy link
Owner Author

Choose a reason for hiding this comment

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

I've been explicitly avoiding "frame rate", as I'm worried we'd get pushback on the multi-display, or variable framerate cases (i.e. gsync)

source Outdated
callbacks</span> interleaved). For example, a user agent might wish to coalesce timer
callbacks together, with no intermediate rendering updates.</p>
</div>
<p>If there are a <span data-x="browsing context">browsing contexts</span> <var>B</var> that
Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
<code>Document</code> objects whose <span data-x="concept-document-bc">browsing context</span>
is in <var>B</var>.</p>

<p>A <span>browsing context</span> has a rendering opportunity if the user agent is currently
Copy link
Owner Author

Choose a reason for hiding this comment

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

I was planning on doing this, but then couldn't figure out where to stick the definition. Any thoughts on where it should go?

source Outdated
<p>A <span>browsing context</span> has a rendering opportunity 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 presented even if it's outside the viewport.</p>
Copy link
Owner Author

Choose a reason for hiding this comment

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

I've tried to clarify this. I also realized I was incorrectly handling the case where we coalesce tasks. We shouldn't mark paint timing in that case, but are doing so in this spec.

<code>Document</code> object removed.</p></li>

<li><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
Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm not sure how specific to be here.

I suspect that for all cases where there is a rendering opportunity and new things to render, but we choose not to rendering anyways, we don't want to mark paint timing, but the only concrete example I've got of when this could happen is for task coalescing.

The key thing we want to avoid is the presence or lack of content to draw impacting whether or not paint timing is marked, which I believe this accomplishes.

Copy link

@domenic domenic left a comment

Choose a reason for hiding this comment

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

LGTM with small suggestions. Some source formatting stuff too but I can clean that up when merging instead of doing back-and-forth.

source Outdated
constrained. In such cases, the browser could decide to update the rendering for such content
infrequently or never.</p>
</li>
<li id="step-7-3-rendering-opportunities">
Copy link

Choose a reason for hiding this comment

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

Don't bake step numbers into IDs or references; they'll change over time. You could instead use labels; search for "step labeled" in the spec to see some examples.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
visible, the user agent might decide to drop that page to a much slower 4 rendering
opportunities per second, or even less.</p>

<p>If there are <span data-x="browsing context">browsing contexts</span> <var>B</var> that do
Copy link

Choose a reason for hiding this comment

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

I think actually just putting this paragraph first would be a bit nicer. Say what you're doing, then explain it.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
(there's no <span>rendering opportunity</span>).</p>

<p><a href="#step-7-4-unnecessary-rendering">Step 7.4</a> prevents the user agent from updating
the renderingwhen there's no new content to draw.</p>
Copy link

Choose a reason for hiding this comment

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

Missing space

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

Copy link
Owner Author

@tdresser tdresser left a comment

Choose a reason for hiding this comment

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

Sorry for the massive delay.

I've addressed your feedback, and will open a PR to merge these changes to the official HTML spec.

source Outdated
visible, the user agent might decide to drop that page to a much slower 4 rendering
opportunities per second, or even less.</p>

<p>If there are <span data-x="browsing context">browsing contexts</span> <var>B</var> that do
Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
(there's no <span>rendering opportunity</span>).</p>

<p><a href="#step-7-4-unnecessary-rendering">Step 7.4</a> prevents the user agent from updating
the renderingwhen there's no new content to draw.</p>
Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

source Outdated
constrained. In such cases, the browser could decide to update the rendering for such content
infrequently or never.</p>
</li>
<li id="step-7-3-rendering-opportunities">
Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants