Skip to content

perf(mobile): cut 173 KB from the phone page so its size fence has headroom again - #46183

Merged
nwparker merged 1 commit into
mainfrom
AmethystLiang/mobile-bundle-headroom
Nov 21, 2026
Merged

nwparker merged 1 commit into
mainfrom
AmethystLiang/mobile-bundle-headroom

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

The phone's web page hit its size limit, so every new mobile change failed CI. This PR makes the page 173 KB smaller without changing anything people see, and leaves the limit where it is.

Files Added Deleted Net
Test 0 0 0 0
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​25 $\color{#cf222e}{\Huge{\mathbf{−}}}$​24 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1

What Changed

Gated bytes as verify-mobile-web-app-bundle.mjs counts them (all page bytes except the approved terminal fonts and the language catalogs). The budget is 11,272,192 and stays unchanged:

gated bytes headroom
main a60d999 11,271,825 367
this branch 11,098,686 173,506
  • Bot mascots: −138 KB of images. The page shipped the 512 px WebPs, which desktop's picture carousel still needs. Mobile draws a mascot at most 88 pt, and the rim drawn under it on dark tiles is already 256 px. The page now gets 256 px renders of the same art (q85 lossy color, lossless alpha) from mobile/assets/bot-mascots/. Desktop's files and the rims are untouched.
  • Mermaid page engine: −35 KB. The prebundled engine was lowered for chrome74, safari15. The page that imports it already ships es2022, so Chrome 74 could not run that page anyway, and the lowering only added bytes. The target is now safari15. The terminal WebView engines keep chrome74.

What grew since the last fence change (#44465, which measures 11,023,326 once merged): +248 KB, about 200 KB of it bot features. That breaks down as native-chat bot cards (Google setup, Composio) +62 KB, shared bot code +56 KB, mobile/src/bots +95 KB (webhooks, tools, items), and hand-to-bot workspace actions +12 KB. No npm package grew.

Fence design note: the fence counts total page bytes, not first-load bytes, so lazy-loading screens cannot help it. Only shipping fewer bytes moves it. First open has its own 3 MiB entry fence, and this PR leaves the entry unchanged at 1,526,464 bytes.

Follow-ups, deliberately left out: dedupe @react-native/normalize-colors, the page's only duplicate package version (~7.5 KB). Trimming Mermaid diagram types (up to ~1 MB) would be a product call. This is mechanical bundle work, so no comparable product applies.

Why

This unblocks main. PR #46160 was 1,587 bytes over after merging main. Raising the fence again was ruled out, and these two cuts are the largest that change no screen.

Linked Issue

None. Maintainer fix for the mobile web bundle budget on main.

Visual Proof

Mockup, not a product screenshot: a standalone page that draws only the repo's mascot image files at 88 pt, the way MobileBotAvatar layers them, rendered in headless Playwright WebKit at deviceScaleFactor: 3. It contains no app UI and no real data. Each mascot appears on a light tile and on a dark tile with the rim. Top row: the old 512 px set. Bottom row: the new 256 px set.

avatars-88pt-3x-before-after.png

Testing

  • pnpm run build:mobile-web (build + verify): main 11,271,825 → branch 11,098,686 gated bytes. The buildId is reproducible, and route, chunk and asset counts are unchanged (18 / 88 / 215).
  • Real-build browser checks pass in Chromium and in Playwright WebKit (11/11): mobile-web-app-mermaid-render.test.mjs, which renders a Mermaid diagram plus the broken-source fallback through the regenerated engine, and mobile-web-app-bots-render.test.mjs, which draws bot rows with their mascot assets from the built page. WebKit here is a desktop Playwright build, not an iOS 15 device.
  • pnpm check:changed: 16 checks passed. CI carries the full suites.

Performance

Fewer bytes only: −138 KB of mascot images and −35 KB of the deferred Mermaid chunk. No code path runs more often.

Review / platform

These are build-config and asset changes for the mobile page only; the native app also picks up the smaller mascots. Desktop, SSH and Windows are unaffected.

Risk

The riskiest part is the Mermaid engine target: a WebView older than Safari 15 or Chrome 80 would now fail to parse the Mermaid chunk. Such a WebView already fails on the es2022 page, so nothing that works today breaks. Mascots look slightly softer only above 85 pt at 3x, and no current screen draws them that large. Back out with a plain revert.

…adroom again

- Ship 256 px bot mascot renders for mobile instead of desktop's 512 px set (-138 KB of
  images). Mobile draws them at most 88 pt, the same resolution as their rims.
- Build the page's Mermaid engine for Safari 15 only; the page that imports it is already
  es2022, so the Chrome 74 lowering only added bytes (-35 KB).

Gated page bytes 11,271,825 -> 11,098,686 of 11,272,192. The fence is unchanged.
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Mermaid page-engine build now targets Safari 15 instead of Chrome 74 and Safari 15. The mobile mascot lookup keeps the same mascot IDs and literal require calls, but points to mobile/assets/bot-mascots/. Its comment now describes the 256 px images and their maximum 88 pt display size.

Merge Risk: Minimal · up to 4c0d0

This change shrinks the mobile bundle by replacing mascot images with 256 px renders and narrowing the Mermaid build target. No concrete regression was identified, and the change is low risk to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: cutting 173 KB from the mobile phone page so its size fence has headroom. The changeset matches this. It replaces the bot mascot images with 256 px renders and lowers …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is thorough and covers every template section: ELI5, What Changed (before/after gated bytes with mechanism), Why, Linked Issue, Visual Proof (mockup with before/after image), Testing, …
Full details: Title check

Explanation

The title names the main change: cutting 173 KB from the mobile phone page so its size fence has headroom. The changeset matches this. It replaces the bot mascot images with 256 px renders and lowers the Mermaid page-engine target to safari15, which reduces gated page bytes.

Full details: Description check

Explanation

The description is thorough and covers every template section: ELI5, What Changed (before/after gated bytes with mechanism), Why, Linked Issue, Visual Proof (mockup with before/after image), Testing, Performance, Risk with revert method, and Review/platform notes. Two sections are weak. The Linked Issue section says 'None' with a maintainer-fix rationale, while the template says an issue should always exist for outside contributors. The AI Disclosure section and the Agent skill upstream boundary checkbox are not addressed. The Testing checklist boxes are not ticked, and the description does not say whether unit tests were added or explained as unnecessary. The Visual Proof is a mockup rather than a real product before/after, which the template may not accept for UI changes. The Level field in Risk is not filled in. These gaps are non-critical for a build-config PR, so the description is mostly complete.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 433de4b5-249b-459d-a137-b6bbadcd3f4d
Commits

Reviewing files that changed from the base of the PR and between 6607b6a and 4c0d0b3.

Files selected for processing: 22

  • mobile/assets/bot-mascots/A1.webp
  • mobile/assets/bot-mascots/B1.webp
  • mobile/assets/bot-mascots/D1.webp
  • mobile/assets/bot-mascots/E1.webp
  • mobile/assets/bot-mascots/F1.webp
  • mobile/assets/bot-mascots/G1.webp
  • mobile/assets/bot-mascots/H1.webp
  • mobile/assets/bot-mascots/H2.webp
  • mobile/assets/bot-mascots/I1.webp
  • mobile/assets/bot-mascots/J1.webp
  • mobile/assets/bot-mascots/K2.webp
  • mobile/assets/bot-mascots/L2.webp
  • mobile/assets/bot-mascots/M1.webp
  • mobile/assets/bot-mascots/N1.webp
  • mobile/assets/bot-mascots/O1.webp
  • mobile/assets/bot-mascots/P3.webp
  • mobile/assets/bot-mascots/Q1.webp
  • mobile/assets/bot-mascots/R3.webp
  • mobile/assets/bot-mascots/S2.webp
  • mobile/assets/bot-mascots/T1.webp
  • mobile/scripts/build-mermaid-page-engine.mjs
  • mobile/src/bots/mobile-bot-mascot-assets.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

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.

2 participants