Re: [csswg-drafts] [css-view-transitions-2] Allow synchronous snapshots (#9400)

If I understand the problem, is that between the event and the next render opportunity the framework has a gap of time where it could potentially run some operations to prepare for the next state.

The problem with the proposed solution is that snapshotting in itself would become an expensive synchronous operation, so it would delay updating the state and this won't add much value...

Also the frameworks are often not the only pieces of code that update the DOM on the page, there are 3p libraries, extensions etc. A synchronous DOM render is a radical solution to a problem that can be solved in other ways.

The solution we should strive towards is the alternative, something like

```js
   framework.startViewTransition = () => {
      const donePreparing = framework.prepareState();
      document.startViewTransition(() => {
        await donePreparing;
        await framework.commitToDOM()
     });
   }
```

And yes, frameworks might have to adjust to this, and potentially do something like this internally - likely on the router level, if they want this optimization of "let's start preparing before the render opportunity".
I'm not sure that producing a sync snapshot mechanism would magically solve this for multiple frameworks.

-- 
GitHub Notification of comment by noamr
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9400#issuecomment-1732259972 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Saturday, 23 September 2023 09:02:30 UTC