-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't render when code ahead (#6069)
**Problem:** When making code changes, we'll cause the canvas to re-render twice: once when the code is changed; and then a second time once the parsed model has caught up. **Fix:** Specifically check if any code is ahead before triggering a canvas render. To do this I used the existing `shouldRerender` in `editor.tsx`, but realised that was actually a bit of a misnomer, and was gating logic that it shouldn't be. So I have explicitly used the relevant boolean checks around the individual parts of the code called after a dispatch. Note that I have completely removed the check around `editorDispatchClosingOut`. I'm very much certain that we should never have been gating that with a check that something had changed, as the internal logic of that function is already checking that something actually changed before e.g. triggering a save. My only concern with this was that if you are typing fast enough it would prevent the canvas from rendering until you paused briefly, because we don't change the revisions state following a parser-printer update if the update is stale here: <https://github.com/concrete-utopia/utopia/blob/67abcdd1d9fa11c0bf42be255cf655bba45a5a38/editor/src/core/shared/parser-projectcontents-utils.ts#L100-L109> However, in practice, even on the hydrogen project this never happened, because the IndexedDB polling part which forms the code-editor-to-utopia communication channel is slower than parsing the code. So I then added a 600ms pause in the parsing to force the code updates to come through faster, which meant updating the canvas only happened when you stopped typing, and even in that forced case it actually didn't feel bad. **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Preview mode --------- Co-authored-by: Sean Parsons <[email protected]>
- Loading branch information
Showing
2 changed files
with
119 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters