[Bug]: Android launch spends ~2 s in formatjs polyfill checks before the first render
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- android, react-native, typescript
调研方向
从 apps/mobile/src/i18n/intl-polyfills.ts 开始,该文件从默认入口导入 DisplayNames 和 PluralRules 的 polyfill。该问题报告称,强制入口(polyfill-force)安装相同的 API,但缺少会拖慢启动的 locale 匹配检查。请切换导入方式,并确认 Intl.DisplayNames.polyfilled 为 true,PluralRules('en').select(1) 返回 'one',且 'fr' 的 DisplayNames 返回 'French'。在 Android 发布版构建上,用 am start -W 测得导入的求值时间下降,即为完成。
由索引模型根据 Issue 内容生成。
描述
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/mobile
Steps to reproduce
- Install a release Android build.
- Force-stop the app, then launch it (
adb shell am start -W -n <package>/.MainActivity). - Time the splash screen.
Expected behavior
The splash hides within about a second or two of the first JS line on a current phone.
Actual behavior
On a Pixel 9 Pro the splash stays up 5.3 to 6.1 s. Timing logs in a release build show about 3.0 s spent evaluating the JS import graph before App renders anything.
Timing each module's first evaluation (a profiling polyfill around Metro's __d) puts the two largest costs in apps/mobile/src/i18n/intl-polyfills.ts:
| Module | Self time (emulator, production bundle) |
|---|---|
@formatjs/intl-displaynames/polyfill.js |
619 ms |
@formatjs/intl-pluralrules/polyfill.js |
243 ms |
Both default entries call shouldPolyfill() at import. With no native Intl.DisplayNames or Intl.PluralRules (Hermes has neither), that runs @formatjs/intl-localematcher's match(['en'], <~700 supported locales>, 'en'). Every comparison goes through the JS getCanonicalLocales polyfill, and the result is always "polyfill".
Importing the forced entries instead (@formatjs/intl-displaynames/polyfill-force and @formatjs/intl-pluralrules/polyfill-force) installs the same polyfills without the check. Measured on the same phone:
| Default entries | polyfill-force |
|
|---|---|---|
| JS import evaluation | 2.98 to 3.08 s | 0.75 to 0.96 s |
Tap to splash gone (am start -W) |
5.3 to 6.1 s | 1.7 s warm, 2.5 to 3.6 s cold |
Both APIs still install and work afterwards (Intl.DisplayNames.polyfilled === true, new Intl.PluralRules('en').select(1) === 'one', new Intl.DisplayNames(['en'], { type: 'language' }).of('fr') === 'French').
Impact
Major degradation or frequent failure
Version or commit
apps/mobile/src/i18n/intl-polyfills.ts as of c3a330d834 (unchanged in the fork build measured)
Environment
Pixel 9 Pro, Android 17 (GrapheneOS), Battery Saver on, release build; module timings from a production bundle on an Android 17 emulator
Logs or stack traces
Next-largest import costs after the change: React Native's BridgelessUIManager collecting legacy view-manager constants (~400 ms on the emulator), global.css, and Effect / packages/contracts schema setup.
- 主要语言
- TypeScript
- 星标
- 24.8k
- 派生
- 6.4k
- 平均合并
- 2 小时 18 分钟
- 30 天内合并 PR
- 448
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pingdotgg/t3code 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
pingdotgg/t3code#40678 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
维护者通常 1 天内回复
-
[Bug]: Gitea/Forgejo mergeable:false maps to unknown, so PR watch never reports merge conflicts可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[Bug]: Link dialog copy uses "here"/"there" instead of host names, so the access direction is ambiguous可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
相似的 Issue
-
[Docs] CONTRIBUTING points the Backend Remake milestone at a branch that does not exist可能已有人在做 @franpts2 今天认领。 未关闭docs
难度 1/5 1 小时以内 新手友好度 90/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
ever-co/ever-teams#5741 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
melgarafael/DeskcommCRM#5142 ·
维护者通常 1 天内回复
-
bug size:medium
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复