Repository navigation
perf(mobile): shrink the phone page by 198 KiB and lower its size fence - #44465
Conversation
be64452 to
3304b86
Compare
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
上游 stablyai#44465 收紧预算后纯上游仅余约 205 KB,fork 路由实测约 355 KB。上游常量保持 10.75 MiB,fork 额度 360 KiB 单列、只降不升(journal D-030);顺带登记终端粘贴测试接缝。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GvYgJTtZiP6G3CVdLZKC6C
ELI5
The phone's web page was carrying two copies of some libraries and a few pieces it never uses. This drops them, so the page is about 198 KiB smaller, and lowers the size limit by the same amount so the space doesn't fill up again.
What Changed
Nothing users see or do changes. Only the bytes the desktop hands the phone change. Measured by
verify-mobile-web-app-bundle.mjs(code bytes, without the terminal fonts and language catalogs):5a6ab25)Each cut:
react-native-reanimated/src/.... That pulled reanimated's TypeScript source tree (185 modules) into the page next to thelib/modulebuild the page already runs. A page-build plugin points that one require at thelib/modulefile. The check's answer doesn't change: neither build has_refreshComponentRefin reanimated 4.7.1, so it isfalsebefore and after.dist/cjs, beside the esm copies the page already has. They now resolve to the esm copies, which have the same default and named exports.new Map(...)encode table that esbuild can't drop. markdown-it's import now resolves toentities/lib/decode.js, the same file the root re-exports from.Bufferonly to convert base64: file media download, dictation audio and the browser frame data URI. They now use the existingbase64-byte-codec(encodeBase64Bytes/decodeBase64Bytes), which the transport already runs on both the page and Hermes. The native-onlybrowser-frame-data-uri.tskeepsBuffer.If a later upgrade moves a redirect target, the plugin fails the build rather than quietly shipping both copies again. The entry closure (the bytes loaded before the first route) is unchanged at about 1.52 MB, so first open is no slower. One script chunk fewer.
Why
The fence has gone up four times in two days (10 → 10.25 → +216 KiB → 10.5 → 11 MiB). These are the safe cuts: duplicate builds and code nothing calls. They change no screen, no text and no RPC.
The bigger items are listed below. Each one needs a product call or carries real risk, so this PR leaves them alone:
chrome74/safari15would save about 44 KB, but Metro and Hermes compile that generated file too, so it needs a native check first.Linked Issue
N/A (fleet task from Kelvin: shrink the phone page bundle)
Visual Proof
N/A: the page renders the same. Only duplicate modules and an unused encode table leave the bundle, and the base64 calls produce the same strings and bytes.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
pnpm build:mobile-web(build + verify, reproducible buildId) on main and on this branch. Numbers above.A metafile breakdown confirmed
react-native-reanimated/src/**,react-native-web/dist/cjs/**,entities/.../encode-html.jsandbufferare no longer in any output.Mobile vitest:
bridge-audio-verbs,mobile-dictation-session-outcomesandsrc/test-support/rpc-recording(122 tests) pass.build-mobile-web-app-bundle.test.mjs(shim list) andpnpm check:changedpass.No new tests: each cut is a build-resolution or call-site swap, and the verify fence already guards the size.
Risk
Level: Low
The riskiest part is the reanimated redirect, because gestures and animations run through reanimated on every page. Only the gesture-handler probe's require moves.
require('react-native-reanimated')already loads the samelib/moduletree at that point, so evaluation order doesn't change.The base64 swap is stricter on malformed input (
atobthrows whereBufferskipped bad characters). Hosts send NodeBuffer.toString('base64')output, so that can't happen on a real path.The lower fence means a phone PR that adds more than about 446 KiB fails
build:mobile-webon size and has to cut bytes or ask.Back out with a plain revert.
Review
One review round (Codex + Claude). Codex found nothing. Claude rated a first 10.5 MiB fence P2 because it would squeeze the phone parity branches still in flight, so the fence is now 10.75 MiB.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Older phone shells and hosts are unaffected. The manifest format is unchanged, and the page is only smaller.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)