Skip to content

[WIP] perf: defer navigation screen requires#7459

Open
janicduplessis wants to merge 2 commits into
developfrom
perf/navigation-getcomponent
Open

[WIP] perf: defer navigation screen requires#7459
janicduplessis wants to merge 2 commits into
developfrom
perf/navigation-getcomponent

Conversation

@janicduplessis

@janicduplessis janicduplessis commented May 11, 2026

Copy link
Copy Markdown
Contributor

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 getComponent instead of component, so a screen's module graph is only required when the screen is first rendered.

Each getComponent callback uses an inline require(...) 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:

Approach Modules initialized
Baseline (origin/develop) 3425
getComponent + static imports (relying on Metro inlineRequires) 3301
getComponent + manual inline require(...) 3108

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's inlineRequires transform initialized 193 more modules than manual inline require, so the manual form was kept.

Screen recordings / screenshots

N/A β€” navigation registration refactor only.

What to test

  • Smoke test via e2e tests
  • Re-run perf tests a few times to make sure it leads to improvements

@github-actions

Copy link
Copy Markdown

Launch in simulator or device for 7eddb06

@github-actions

github-actions Bot commented May 11, 2026

Copy link
Copy Markdown

πŸ§ͺ Flashlight Performance Report (AWS Device Farm)

πŸ”€ Commit: 02f0bc2

πŸ“Ž View Artifacts

Metric Current Ξ” vs Baseline
Time to Interactive (TTI) 5608 ms βšͺ +48.9 ms (+0.9%)
Average FPS 56.86 βšͺ +0.1 (+0.2%)
Average RAM 397.5 MB βšͺ -0.3 MB (-0.1%)

@janicduplessis janicduplessis changed the title perf: defer navigation screen requires [WIP] perf: defer navigation screen requires May 11, 2026
@janicduplessis janicduplessis force-pushed the perf/navigation-getcomponent branch from f43a180 to f81067d Compare May 11, 2026 14:55
@github-actions

Copy link
Copy Markdown

Launch in simulator or device for 02f0bc2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant