Skip to content

perf(swipeable): mount the action rails only when a side is needed - #40

Merged
chocky335 merged 6 commits into
mainfrom
perf/lazy-action-rails
Nov 14, 2026
Merged

chocky335 merged 6 commits into
mainfrom
perf/lazy-action-rails

Conversation

@chocky335

Copy link
Copy Markdown
Owner

A closed Swipeable row mounted two empty action rails next to its content, so every recycled row cost three native views. Now src/Swipeable.tsx mounts the rails as a pair only when a side is needed and renders the native view directly. Both native views treat one child as content only and three as rails plus content.

Review focus: a lone child gets the content role only after Fabric's mount batch, because the first child of a three-child mount is the left rail.

Xiaomi Mi 11 Lite (Android 13, 90 Hz), README list benchmark, Release, one session. The first launch after each install is excluded, so each row averages 2 runs:

JS FPS avg
main 86.1
This PR 86.9
Plain rows without Swipeable 86.5

This PR is within noise of plain rows. main also measured higher here than in #37 (84.3), so this session cannot separate it from this PR. The JS cost per recycled row does separate them: in a react-test-renderer microbenchmark (2,000 recycles, 3 rounds) it drops from 73-85 µs to 40-43 µs, against 31-34 µs for a plain View. Pixel 8 Pro: 113.9 vs 113.1 for plain rows, at the 120 Hz ceiling.

🤖 Generated with Claude Code

@chocky335

Copy link
Copy Markdown
Owner Author

Verification on 856cdbe:

  • JS: 169 tests pass. npm run lint, npm run format:check, tsc --noEmit and the type fixtures pass.
  • Android: the :react-native-swipeable-actions:test Robolectric suite passes (189 tests, 145 in SwipeableViewTest).
  • iOS: swift test in ios/ passes (119 tests). The example app builds for the simulator with the changed SwipeableView.swift.
  • iOS simulator (Maestro): swipe open shows the actions, scrolling far enough to recycle the row and back restores it open, swipe closes it. seekbar-regression.yaml passes.
  • Pixel 8 Pro, Release: the actions appear mid-drag, an open row survives a recycle (scrolled to item 92 and back) and closes again.

@chocky335
chocky335 merged commit 5b1c448 into main Nov 14, 2026
9 checks passed
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