Batch canvas rendering using stageDirty flag to reduce redundant stage.update() calls#5807
Merged
walterbender merged 3 commits intosugarlabs:masterfrom Mar 15, 2026
Merged
Conversation
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Member
|
@stutijain2006 please resolve the linting issue |
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
I even did forced formatting now so that the lint error doesn't appear, but don't know why it is coming, can you guide me for the same ? |
Contributor
|
This might be because of different prettier versions used by your locals and by musicblocks. Please check the same and commit again. I believe that will solve the issue. |
Contributor
|
✅ All Jest tests passed! This PR is ready to merge. |
Contributor
Author
|
@walterbender This PR is ready for review and merge , please see to it. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR improves runtime rendering efficiency by reducing unnecessary stage.update() calls and switching to a batched rendering approach using a stageDirty flag.
Instead of triggering immediate canvas redraws from multiple event handlers (keyboard movement, resizing, idle wake-up, scrolling, etc.), we now:
This avoids redundant synchronous canvas redraws and reduces scripting overhead on the main thread.
Changes made -
Replaced direct stage.update() calls with stageDirty = true in:
This ensures one canvas redraw per frame and no redundant forced synchronous updates.
Performance Changes -
This is a runtime efficiency optimization, not a Lighthouse score booster.
Before-
After-
Result-
Functional Verification-
All core interactions were manually tested:
All functionality remains unchanged.