Repository navigation
Skip copying the culling context in the differ when view culling is off - #59677
Open
hryhoriiK97 wants to merge 1 commit into
Open
hryhoriiK97 wants to merge 1 commit into
hryhoriiK97 wants to merge 1 commit into
Conversation
Slicing and the differ's matched-pairs loop read `enableViewCulling` and copy a `CullingContext` (a `Rect` and a `Transform`) for every child, but without view culling `adjustCullingContextIfNeeded` returns an unchanged copy. Read the flag once per call and, when culling is off, pass the parent's context to the children instead of copying it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
javache
approved these changes
Oct 30, 2026
javache
approved these changes
Oct 30, 2026
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D128599926. |
christophpurrer
approved these changes
Oct 30, 2026
christophpurrer
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
This branch has not been deployed
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.
Summary:
In its two per-child loops (slicing a node's children, and walking matched child pairs), the differ calls
CullingContext::adjustCullingContextIfNeededfor every child and readsReactNativeFeatureFlags::enableViewCulling()each time. Each call builds aShadowViewNodePairwith a copy of the child'sShadowView(props, state and event emittershared_ptrs) and returns a newCullingContext(aRectand aTransformwith its operations vector). Without view culling, the result is always an unchanged copy of the parent's context.View culling is off by default, so every commit pays for this on every child the differ visits. This change reads the flag once per call and, when culling is off, passes the parent's context to the children instead. With culling on, the same calls run in the same order as before. The other
adjustCullingContextIfNeededcalls are in rarer paths (flattening, unflattening, deletions) and are left as they are.I found this while profiling typing in a
TextInputon Android: each keystroke commits a state update, and the differ walks the whole screen. On a low-end phone the copies were about 5% of the differ's time.Changelog:
[GENERAL] [CHANGED] - The differ no longer copies its view culling context for every child when view culling is off
Test Plan:
yarn fantomwith the tester rebuilt from this change:ScrollView-viewCulling-itest.js(runs withenableViewCulling:true): 44 passed.TextInputsuites 39 passed,ScrollViewsuites 86 passed,Mounting-itest.js56 passed.expectsnapshots), and the known flaky tester crash in one suite (polyfillArrayES2023Methods-itest.js), which passes on rerun.clang-formatclean (node scripts/clang-format.js --check).TextInputon the TextInput example page for 12 s per run, call stacks sampled at 1 kHz, 5 rounds alternating old/new. JS thread samples spent inadjustCullingContextIfNeededand the flag reads:That is about 1.3–1.5% of the JS thread while typing (the differ itself is about 30% of it). Total differ time moves by more than that between runs, so I am not claiming more.
🤖 Generated with Claude Code