fix(ui): canvas stuttering, perf improvements #6102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
We have reports of canvas "stutters" (UI-blocking GC events) on 3.7.0 and 4.0.0. I'm not sure what changed in v3.7.0, could have always been an issue and it's just a coincidence that it's popped up now.
PR introduces a few perf optimizations for canvas, benchmarked across Chrome, FF and Safari.
Related Issues / Discussions
Discord thread for canvas "stutters": https://discord.com/channels/1020123559063990373/1224446493323296809
QA Instructions
To replicate the excessively large history on
main
, draw about 50 mask lines. You can just click in the same spot over and over again rather than actually dragging the mouse to draw a line. Then pressShift + C
about 100 times, and finally draw a line. Depending on your hardware and browser, we expect some lag at this point.Run this in the JS browser console:
This prints the size of the undo history - we expect it to be around 150, which seems to be the danger zone. It'll be different depending on hardware and browser, though.
Next, switch to this PR. You'll need to stop the dev server,
pnpm i
and then start it again.You should be back to where you left of in the canvas. Draw a single line with the mask. This should reset your history - run the snippet above again, should say 100 (or less). Draw around, we expect improved performance from here on out.
Merge Plan
n/a
Checklist