-
Notifications
You must be signed in to change notification settings - Fork 80
Description
Request for Mozilla Position on an Emerging Web Specification
- Specification Title:
Display Lockingrendersubtreesubtree-visibilitycontent-visibility - Specification or proposal URL: https://drafts.csswg.org/css-contain-2/#content-visibility
- Mozillians who can provide input: @victorporof @dbaron
Other information
We’ve identified two main problem categories with this proposal, detailed blow.
Relationship between “wip” and “live” subtrees
Display artifacts (issue 39)
We’re not convinced that painting retained “snapshots” at the old size is desirable: when layout is altered on “locking roots”, some subtrees could have unpainted areas while others would clip. This is especially evident in suggested use-cases such as “resizing multi-pane UI with complex layout within each pane” as described here.
Starving work (issue 20)
Exhausting budgets and starving cooperative updates excessively is possible, given an unbounded number of new nodes or other potential DOM operations, over an unbounded number of frames.
It’s not clear how the implementation would avoid situations where committing a lock results in long-lasting jank, by accumulating outstanding work.
Possible suggestions involve increasing priority for budgeted update phases, or switching to synchronous work.
Starving memory (issue 14)
It’s not clear how the implementation would avoid situations where excessive amounts of memory are retained in order to cache the rendering output, by locking elements much larger than the viewport.
Possible suggestions involve checkerboarding.
Event handling (spec)
It’s not clear how the implementation would handle user input targeted at subtrees which are locked for display.
Possible suggestions involve queuing up input and replaying, or ignoring input altogether. We think that both variants lead to undesirable behavior:
- Replaying input can cause unexpected interactions, since the user may be targeting an unexpected element (script could have mutated the DOM before unlocking);
- Ignoring input can lead to potential user frustration (page would appear frozen);
Forced layout (issue 21)
It’s not clear how the implementation would handle layout queries under subtrees which are locked for display. It’s difficult to determine what layout information should be returned ideally, when querying properties which otherwise normally cause reflow.
Possible suggestions involve:
- Synchronously releasing the lock, forcing reflow;
- Returning a fully computed alternative layout, which isn’t used otherwise;
- Returning a partially computed alternative layout, determined by current budgeting;
- Returning the initially snapshotted layout, stored when the lock was acquired;
- Returning bogus values or throwing an exception;
There’s a preference for aborting and synchronously committing the lock, forcing reflow.
Altering containment (issue 28)
The API requires containment for paint, style and layout for lockable subtrees, to better reason about expected behavior of the entire page. This is done with the contain: content CSS property.
It’s not clear how the implementation would handle situations where "contain" is altered while an element is locked.
Possible suggestions involve aborting by synchronously committing the lock.
Assumptions
The proposal has a risk of prematurely baking in assumptions about current browser engine designs into future web standards.
Parallelisation assumptions
Several assumptions are made which can be at odds with parallelizable browser designs: that layout and painting can synchronously access element locking information, that there is no interruptible layout, and that layout and script are serialised.
There’s a risk to alternate browser engine designs when standardising these assumptions, especially with regards to parallelizable layout. There’s sufficient prior art for how old standards are limiting modern browser design.
Reinforcing a disconnect between DOM and VDOM
Knowing what to acquire a lock on requires certain heuristics, which might not be trivial to define, or compute. This is especially true if the burden for figuring this out is given to frameworks, which are intended to be the primary users.
Possible implementations can be fairly close in nature to existing component instance tree traversals (early stages of “diffing”), or comparing previous and next presentational intent (late stages of “diffing”, or reconciliation). This can mean multiple things:
- The proposal fits in well with existing virtual DOM architectures;
- The proposal doesn’t solve impedance mismatches between the DOM and declarative modern web framework design.
If frameworks still need to do “some kind of diffing” (loosely defined) in order to talk to the browser (acquire a lock on certain subtrees), due to their declarative architecture, this could have a risk of reinforcing the current disconnect.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status