perf: extend viewport culling to updateCache and markStageDirty for off-screen blocks#7798
Closed
ssz2605 wants to merge 3 commits into
Closed
perf: extend viewport culling to updateCache and markStageDirty for off-screen blocks#7798ssz2605 wants to merge 3 commits into
ssz2605 wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7798 +/- ##
==========================================
- Coverage 59.27% 59.26% -0.01%
==========================================
Files 176 176
Lines 57975 57979 +4
==========================================
- Hits 34365 34364 -1
- Misses 23610 23615 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2e0f0b6 to
f56c038
Compare
df16f72 to
fb7add5
Compare
Gate container.updateCache() in Block.unhighlight() and markStageDirty() in logo.js highlight/unhighlight paths on block._viewportVisible. highlight() early-returns for off-screen blocks, skipping bitmap toggling and updateCache. Builds on PR sugarlabs#7738 viewport culling by eliminating the remaining per-frame overhead for off-screen blocks. Measured improvement (Crabcanon-plot, 900 blocks): - updateCache calls: ~5800 -> ~866 (85% reduction) - updateCache time: ~600ms -> ~90ms
fb7add5 to
ba310f7
Compare
… invalid refs - Fix viewport visibility checks to use Block objects instead of block IDs (blk is a number, not an object - blk._viewportVisible was always undefined) - Guard unhighlight() against undefined block references (blocks.js:3409) - Guard unhighlightQueue.pop() with null/undefined/blockList check (logo.js:2106)
ba310f7 to
7382b7f
Compare
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.
PR Category
Problem
During playback, every executed block is highlighted and then unhighlighted. Each transition performs a synchronous
container.updateCache()and triggersmarkStageDirty(), resulting in a subsequentstage.update().For large projects such as Crab Canon Plot, many blocks extend well beyond the visible viewport. However, the highlight logic only checked
container.visible(the eye icon) and not whether the block was actually within the viewport. As a result:updateCache()operations.Solution
Skip rendering work for blocks outside the viewport while preserving correct highlight state.
Changes
js/block.jsupdateCache()duringhighlight()when the block is outside the viewport.updateCache()duringunhighlight()for off-screen blocks while still updating bitmap state to prevent stale highlights when the block becomes visible again.js/logo.jsmarkStageDirty()afterhighlight()if the block is visible in the viewport.markStageDirty()after deferredunhighlight()if the block is visible.markStageDirty()after end-of-child-flowunhighlight()if the block is visible.Results
updateCache()callsupdateCache()stage.update()(best case)stage.update()(worst case)Note
-This does not affect total playback time, which is dominated by audio scheduling. The improvement is in rendering efficiency and frame consistency.
Verification