[WIP] perf: defer navigation screen requires#7459
Open
janicduplessis wants to merge 2 commits into
Open
Conversation
|
π§ͺ Flashlight Performance Report (AWS Device Farm) π Commit: 02f0bc2 π View Artifacts
|
f43a180 to
f81067d
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.
Fixes APP-####
What changed (plus any additional context for devs)
At launch the app initializes ~3,400 modules, many of them screens that aren't needed until the user navigates to them. This PR defers screen module initialization by registering screens with React Navigation's
getComponentinstead ofcomponent, so a screen's module graph is only required when the screen is first rendered.Each
getComponentcallback uses an inlinerequire(...)rather than a static import, so the screen module is not pulled in at the navigator file's evaluation time.Measured on an iPhone 17 Pro simulator using a temporary local Metro require hook, 10s after the app module loads:
origin/develop)getComponent+ static imports (relying on MetroinlineRequires)getComponent+ manual inlinerequire(...)317 fewer initialized modules vs. baseline (~9.3%). TTI is not meaningfully changed; memory usage drops by ~10 MB (~2.5%).
Alternatives considered
getComponent={() => Screen}with static imports relying on Metro'sinlineRequirestransform initialized 193 more modules than manual inlinerequire, so the manual form was kept.Screen recordings / screenshots
N/A β navigation registration refactor only.
What to test