WICG / WICG/container-timing

Consider using the layout viewport instead of the visual viewport

Open
#32 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Bikeshed
Stars
72
Forks
10
Avg merge
9d 15h
Merged PRs (30d)
3

Description

In Container Timing, we are using the same definition of intersectionRect that comes from Element Timing. For each paint, we calculate the intersection of that paint with the browser viewport.

We use that rectangle to then record the damaged area for a container timing. Anything painted offscreen is not reported. This is a limitation of Container Timing as is that is not going to report paints offscreen, that may be later visible to the user when the scroll down.

Now, checking at https://drafts.csswg.org/cssom-view/#visual-viewport there is the concept of visual viewport and layout viewport.

The proposal is:

  • Use the layout viewport for the internal damage recording and the size attribute.
  • Expose a new field layoutIntersectionRect that exposes the bounding box of the damaged areas related to the layout viewport.
  • Have a new attribute viewportIntersectionRect that is calculated when PerformanceContainerTiming is created. Make intersectionRect expose that same value, for compatibility with the current proposal. Or just directly drop intersectionRect completely and avoid exposing the viewport intersection.
  • (Optional) Should we do the same change in ElementTiming?

With this proposal we would have some advantages:

  • We could report paints that are not in the visible area for the user.
  • We would be a bit more stable in the case of viewport scrolls or zoom, as those would not affect coordinates.

Potential problems:

  • Is the layout viewport really well defined? Is that information useful for the developer to know where a paint has really happened? Will it be possible to add overlays from web using that?
  • We already have a Chromium implementation using the visual viewport. So if we change and there are assumptions on where the visual viewport is painted, those would be broken.
  • The polyfill is based on the element timing intersectionRect.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Container Timing definition of intersectionRect and the CSSOM View visual-viewport section linked in the issue. Compare the proposed layoutIntersectionRect, viewportIntersectionRect, and compatibility options with the existing Chromium implementation and Element Timing polyfill. Done means reaching a decision on the viewport model and documenting the resulting proposal.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
performance, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.