Closed khushalsagar closed 1 year ago
Always having isolation/mix-blend-mode can be a footgun since any content generated by these 2 nodes (like the developer adding background
to the wrapper) will force us off the fast path.
Summary for CSSWG:
We use mix-blend-mode: plus-lighter
on the old & new views, plus isolation: isolate
on the image-pair, in order to create a true cross-fade.
Isolation isn't free performance-wise.
Some transition groups only have an old view, or only new view. This happens when an element with a particular view-transition-name
only exists on one side of the transition. Isolation is unnecessary in these cases.
This would be observable in getComputedStyle
.
It would also result in a different rendering if the developer gives the image-pair a background color, since some contents will plus-lighter blend with that background, and others wouldn't. However, if you set a background on the image-pair, it like that you'd want to set blending to normal anyway.
We already apply lots of styles dynamically in a view transition, such as width, height, transform etc of transition groups.
getComputedStyle
would still see isolation and plus-lighter, but the rendering engine would avoid rendering to another buffer in cases where doing so would have no visual effect.
It's unclear how tricky this would be.
Discussed this offline again, the summary above is great. Adding what came up at the last discussion.
Option 2 will need to be done anyway for cases like this. In this case the author is adding view-transition-name
for elements in both the old and new DOM, since they want a size/transform animation. But they're setting opacity: 0
on the old image because the content hasn't changed. In fact they want the live animating new image instead of a cross-fade. In this case the engine will set up all the isolation and mix-blend-mode styles for cross-fade anyway and would have to detect that only image is actually being rendered so this blending can be optimized.
The worry is still that while the UA can optimize the default entry/exit transitions, authors might add styles (like background
) which will require the expensive blending without realizing it. Since it comes from rules in the UA CSS. On the flip side, if normal blending is incorrect for them, they would discover that and add the requisite blend-mode/isolation (same as the regular DOM rendering).
So the proposal is to go with option 1. This is also in the spec already here. Adding this for async resolution.
I am reluctant to resolve on this without some agreement from others who have more expertise in animations and transitions than I have. Could you solicit opinions from outside your team before we try for an async resolution?
@flackr was present in the discussion I summarized above for animations/transitions expertise. @rcabanier for compositing/blending expertise since that's what we're trying to decide here: what should be the default isolation/blending on the pseudo-DOM generated by the UA if we don't need a cross-fade as described here.
The CSS Working Group just discussed [css-view-transitions-1] Should isolation and plus-lighter blending be applied conditionally
, and agreed to the following:
RESOLVED: isolation/blending-mode properties are added conditionally, as stated in current spec
Resolution aligns with current spec, no work needed.
The default animation in shared element transitions can have either of the following trees per tag:
Cross-fade
There is visual state for an element in both outgoing and incoming DOM. The 2 have a cross-fade and need
isolation: isolate
on the wrapper andmix-blend-mode: plus-lighter
on both the images to the blending right.Enter animation
There is visual state only for an element in the incoming page which fades in.
Exit animation
There is visual state only for an element in the outgoing page which fades out.
It's unclear how best to handle
isolation
andmix-blend-mode
for the 3 cases:isolation
andmix-blend-mode
properties in enter/exit animations. These were also causing sub-optimal rendering (in Blink) because the fact that they are no-op isn't always optimized out. So we could omit adding them in these 2 modes.Option 1 is always better perf wise though it can be optimized if needed. I'd err for that unless there is a good reason to have option 2.