perf: Cache camera render closures instead of allocating per frame - #3979
Merged
Conversation
This was referenced Aug 5, 2026
spydon
force-pushed
the
perf/render-closure-caching
branch
from
August 5, 2026 20:18
a984917 to
f549bd5
Compare
luanpotter
reviewed
Aug 7, 2026
luanpotter
reviewed
Aug 7, 2026
luanpotter
reviewed
Aug 7, 2026
luanpotter
reviewed
Aug 7, 2026
spydon
force-pushed
the
perf/render-closure-caching
branch
from
August 16, 2026 13:25
f549bd5 to
add80f5
Compare
spydon
force-pushed
the
perf/render-closure-caching
branch
from
August 16, 2026 13:43
add80f5 to
302f920
Compare
…per-frame allocation benchmark The Decorator-internal chained-draw cache only helped chained decorators, which are rare, and complicated the class, so Decorator is back to its version on main. The caller-side tear-off caching and the empty-queue lifecycle early-out remain, now backed by a benchmark that isolates the fixed per-frame overhead they remove.
spydon
force-pushed
the
perf/render-closure-caching
branch
from
August 16, 2026 14:39
9bf97d0 to
955aed8
Compare
spydon
added a commit
that referenced
this pull request
Aug 16, 2026
# Description <!-- End of exclude from commit message --> Every `Component` eagerly allocated a `QueueList` for render contexts plus two debug-paint `ValueCache`s. The context stack is now a lazily created plain list (most components never provide or receive a render context) and the debug caches are `late final`, so plain components allocate none of them. Extracted from #3960 so the data-structure change there stands alone (as requested in [this comment](#3957 (comment))). Stacked on #3979.
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.
Description
CameraComponent.renderdeclared a localrenderWorldfunction and, on the post-processing path, an inline context-setter closure. Both were allocated on every frame for every camera. This PR turns them into the instance methods_renderWorldand_updatePostProcessContext, so the render pass no longer allocates closures per camera per frame and the tear-offs passed toPostProcess.renderstay stable.There is no behavior change, only where the functions live.
Checklist
docsand added dartdoc comments with///.examplesordocs.Breaking Change?
Related Issues