-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Slow module initialization time on low-end devices #4463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
yeah best fit matching is non-trivial. The algorithm is in LDML here. At a high level it has to calculate the distance between the requested locale and the dataset, taken into account some special regional grouping & preference like Latin America, then take the shortest one. We've already put in some shortcuts wrt local distance calculation, but overall it's quite heavy. Getting this to match icu4j is pretty tricky. I can take another look, but no promises. |
Cool, thanks. Would it be possible to offer a version of the polyfill that does Also, in general, something feels pathological about, say, passing |
yeah because the 1st thing it tries to do is detect whether this platform needs polyfilling, which checks for a specific Chrome bug. If you're running on a platform that you know definitely needs polyfilling, you can import The |
Fantastic, this hasn't even occurred to me but it's exactly what I needed. |
It would be still be great to somehow get this fixed upstream because I bet it's affecting a lot of RN apps that use |
Actually nvm, I guess developers do include the polyfill itself manually so this was probably our mistake. Would be good to call it out in docs maybe. |
Thanks a lot for holding my hand through this, the last insight let me cut off a few hundred more ms. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We improved our app start time by 3x by just replacing all polyfill imports with their |
…e app by seconds Let's at least make this visible. Relates to: - bluesky-social/social-app#4554 - formatjs#4463 (comment) - formatjs#4369
Might be dicey but seems like a good moment to kick off a discussion on how to avoid this slowing down more apps. It sucks that many apps will add this polyfill without testing perf and the users will be stuck with bad startup perf as a result. |
…own the app by seconds Let's at least make this visible. Relates to: - bluesky-social/social-app#4554 - #4463 (comment) - #4369
We rely on `notation: „compact“`, but it is not available in Hermes yet. We can use some polyfills from formatjs to do the trick for us. fix(mobile): use the -force polyfill formatjs/formatjs#4463 (comment)
We rely on `notation: „compact“`, but it is not available in Hermes yet. We can use some polyfills from formatjs to do the trick for us. fix(mobile): use the -force polyfill formatjs/formatjs#4463 (comment)
* fix(mobile): use polyfills for Intl.formatNumber (#5362) We rely on `notation: „compact“`, but it is not available in Hermes yet. We can use some polyfills from formatjs to do the trick for us. formatjs/formatjs#4463 (comment) --------- Co-authored-by: Daniel Dimitrov <[email protected]>
Which package?
@formatjs/intl-pluralrules/polyfill
Describe the bug
While not a bug per se, merely importing
@formatjs/intl-pluralrules/polyfill
causes a one second stall on a low-end Android device in a React Native project. For context, this is ~1s out of ~3.5s of our startup time, i.e. this polyfill is almost a third of the entire app's initialization time (which uses many other libraries including RN core itself).I'm not sure what's special about this polyfill in particular. Maybe it's hitting some bad case. From inspecting the code, one thing that jumps out to me is that it pulls in the entirety of
@formatjs/ecma402-abstract
because it targets CJS, so a bunch of code gets initialized just to getinvariant
,FormatNumericToString
, andToNumber
. Maybe publishing an ESM version would avoid that.To Reproduce
This is reproducible with the Bluesky app (fully open source) on Samsung Galaxy A12. If there is interest, I can give more detailed instructions, but it's essentially about installing it, running
yarn
, thenyarn android
to run it on an Android simulator (assuming you have one set up).The text was updated successfully, but these errors were encountered: