perf(pos-app): speed up amount entry on low-end devices - #640
ignaciosantise wants to merge 1 commit into
Conversation
- Keep the keypad's onKeyPress stable (plain useState + functional update) so the memoized NumericKeyboard no longer re-renders all 12 keys per press; drops react-hook-form, which only this screen used. - Cache decimal/group separators per locale instead of constructing three Intl.NumberFormat instances per keypress (slow on Android Hermes). - Enable Reanimated's synchronous UI-prop updates so transform/opacity animations skip the per-frame shadow-tree commit. - Render amount characters with a plain Text. Measured on a low-end Android POS terminal (MT6761): per-key JS work 77ms -> 37ms, keypress -> next frame 103ms -> 60ms. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Claude finished @ignaciosantise's task in 2m 36s —— View job Code Review
License compliance: ✅ No issues — Breaking changes: ✅ No breaking changes — all exported symbols and component contracts are unchanged; Found 2 issue(s)Issue 1: Unnecessary
|
Summary
Makes the amount screen respond faster on low-end Android POS hardware. The existing
BigAmountInputanimation and visuals are unchanged.app/amount.tsxnow uses plainuseStatewith a stableonKeyPress. Before, a new inline handler on every render stopped the memoizedNumericKeyboardfrom skipping renders, so all 12 keys re-rendered on each press. This removesreact-hook-form, which only this screen used; the lockfile change is just its own entries.formatAmount.tslooks up the decimal and group separators once per locale. Before, each key press built threeIntl.NumberFormatinstances, which is slow on Android Hermes because it goes through Java ICU.ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPSandIOS_SYNCHRONOUSLY_UPDATE_UI_PROPSare turned on inpackage.json. A Perfetto profile showed about 37% of the UI thread going to Reanimated committing the full shadow tree on every animation frame. With the flags, transform and opacity updates skip that commit.AnimatedCharacter: plainTextinstead ofAnimated.Text.Measurements
Release builds on a low-end Android POS terminal (MediaTek MT6761, 4× Cortex-A53, 1.8 GB RAM). A scripted
adbtyping sequence (1234567.89then 10 backspaces) ran ×5 per run, 3 baseline runs vs 2 final runs.The janky-frame % under rapid typing did not change (~14%).
Testing
main, and every scripted tap registeredtranslateXanchor, which broke iOS; it was reverted.npm test(309 passing), lint, type checkpod install, to confirmIOS_SYNCHRONOUSLY_UPDATE_UI_PROPSNative config changed (Reanimated static flags), so native builds need a clean prebuild or
pod install.🤖 Generated with Claude Code