| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Every CSS state change re-evaluated each @media selector scope through the native screen and application property getters and re-parsed the query string, so a view tree with many media-scoped rules paid thousands of native calls per class change. Match results are now cached and cleared on orientation and system appearance changes, parsed queries are memoized, and application event listeners requested before the platform installs its handler are replayed once it arrives so the invalidation hook is never lost.
|
View your CI Pipeline Execution ↗ for commit a243425
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at 2026-10-07 18:36:11 UTC |
Sorry, something went wrong.
npm i https://pkg.pr.new/@nativescript/core@11512 npm i https://pkg.pr.new/@nativescript/vite@11512 npm i https://pkg.pr.new/@nativescript/webpack@11512 commit: a243425 |
Sorry, something went wrong.
A media query that fails to parse or names a feature the runtime does not evaluate (color-gamut, hover, prefers-reduced-motion, ...) can never match, so its rules are now dropped when the stylesheet is built instead of being re-checked on every style pass. For the queries that remain, device state is read only when a feature asks for it: a width query no longer reads the orientation and appearance, an orientation query no longer resolves the screen, and the screen is resolved once per evaluation rather than once per feature.
| Back | FazBrowse Home | New Git URL |
PR Checklist
What is the current behavior?
Every CSS state change on a view (a class added or removed, a pseudo-class toggled) re-collects selector candidates, and for each @media selector scope in the stylesheet that means calling checkIfMediaQueryMatches. That function reads Screen.mainScreen.widthPixels / heightPixels, the orientation and the system appearance through native getters, and re-parses the media query string with regexes, on every call, before it even looks at which features the query uses.
collectCandidates only remembers queries that matched, in an array created fresh per view, so a query that does not match is re-evaluated for every scope that uses it, on every view, on every style pass. A query that uses a feature core does not evaluate at all (for example the @media (color-gamut: p3) blocks that Tailwind 4 and postcss-preset-env emit as fallbacks) is treated the same way: it returns false, so it is never cached, and it is re-checked forever even though it can never become true.
In a profile of a screen with ~500 labels whose classes change together, with 52 such media scopes in the stylesheet, ~80% of the main-thread time of each interaction was inside checkIfMediaQueryMatches (native screen/appearance getters plus parseQuery); the actual selector matching was under 2%.
What is the new behavior?
Two commits:
1. Cache match results between device changes
2. Drop unevaluable media scopes and read device state lazily
Unit tests cover: cache reuse and invalidation on device change, MediaQueryList notifications staying in sync with the cache, the pending-listener replay, isEvaluableMediaQuery accept/reject cases, zero device reads for unevaluable queries, feature-driven reads for evaluable ones, and scope dropping (top-level and nested) in _populateRules.
Not covered: a change in Screen.mainScreen metrics that is not accompanied by an orientation or appearance event (an external display connecting, for example). Previously such a change was picked up on the next style pass; now it is picked up on the next orientation or appearance change.