perf(app): stop overlays and long sessions from slowing the app

A dev window open for a few hours took twice as long to open the sidebar
hover card as a fresh one. Three dependencies produced the cost:

- Unistyles 3.2.4 web rewrote the whole #unistyles-web text on every class
  add or remove, so the browser restyled the entire document several times
  per hover card. Backport upstream PR jpudysz/react-native-unistyles#1354
  (3.8.0): classes become CSSOM rule inserts and deletes. A full upgrade
  changes 109 native files and needs a newer Nitro runtime.
- @gorhom/portal kept all portal state in one context value at the app
  root, so each portal add, update and remove made React search every
  mounted fiber. Move the state to a store each PortalHost subscribes to
  with useSyncExternalStore. Also backport unreleased upstream PR
  gorhom/react-native-portal#62 so closing one overlay no longer remounts
  later overlays in the same host.
- React 19.2 development builds never cleared their render timings from
  the performance timeline (millions of entries, gigabytes of memory).
  Backport the React 19.3.0 clearMeasures change; React Native 0.86 pins
  React 19.2.

The explorer resize spec counted style tag text rewrites, which are always
zero after the backport, so it now counts rules added, removed or rebuilt.
This commit is contained in:
Mohamed Boudra
2026-11-25 16:11:45 +07:00
parent 6e4f2ef8da
commit 9946c2598d
11 changed files with 3223 additions and 597 deletions
+19
View File
@@ -23,10 +23,29 @@ const patchedPackages = [
// Layout constraints: backport of https://github.com/jpudysz/react-native-unistyles/pull/1357
// (commit from the root the commit hands us, so a concurrent window-size commit is kept).
// Remove the ShadowTreeManager hunk when the installed release includes that PR.
// Web stylesheet: backport of https://github.com/jpudysz/react-native-unistyles/pull/1354
// (3.8.0). Classes are added and removed as CSSOM rules, not by rewriting the style tag, which
// made the browser restyle the whole document. Remove the web/css hunks at >= 3.8.0.
{
nodeModulesPath: "node_modules/react-native-unistyles",
patchPrefix: "react-native-unistyles+",
},
// Portal state lives in a store that each host subscribes to. As the provider's context value it
// changed on every portal add, update and remove, and React searched every fiber under the
// provider (the whole app) for consumers. No upstream fix; keep while the app uses this package.
// Keyed hosts: backport of https://github.com/gorhom/react-native-portal/pull/62, unreleased
// after 1.0.14. Remove the PortalHost hunks when an installed release includes it.
{
nodeModulesPath: "node_modules/@gorhom/portal",
patchPrefix: "@gorhom+portal+",
},
// Backport of React 19.3.0 to the development builds: clear each render timing after reporting
// it. The browser keeps every performance measure for the life of the page, so a development
// session held millions of them and gigabytes of memory. Remove when react-dom is >= 19.3.0.
{
nodeModulesPath: "node_modules/react-dom",
patchPrefix: "react-dom+",
},
// Backport of https://github.com/software-mansion/react-native-reanimated/pull/10435
// (Reanimated 4.7.1): skip synchronous Android prop updates for unmounted view tags
// instead of throwing and printing a full stack trace on the UI thread per tag per event.