Title: perf(core): skip CSS work whose result cannot change by triniwiz · Pull Request #11506 · NativeScript/NativeScript · GitHub
Open Graph Title: perf(core): skip CSS work whose result cannot change by triniwiz · Pull Request #11506 · NativeScript/NativeScript
X Title: perf(core): skip CSS work whose result cannot change by triniwiz · Pull Request #11506 · NativeScript/NativeScript
Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this PR is for. To avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it. You have signed the CLA. All existing tests are passing: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/DevelopmentWorkflow.md#running-unit-tests-application. Tests for the changes are included - https://github.com/NativeScript/NativeScript/blob/master/tools/notes/WritingUnitTests.md. What is the current behavior? Every matched view collects its selector candidates from the universal, id, type and class buckets (plus every media scope), then sorts them, even when it has the same type and classes as the view before it. Every restyle rebuilds the property bag and diffs it, even when the view matched exactly the rules it already applied. A className change re-matches the view and every descendant. Each view styled with color: #1F2330 parses a new Color (and on iOS creates its own UIColor). What is the new behavior? Candidate cache. Sorted candidates are cached per style scope, keyed by type, id and classes, and cleared when the selectors version or the media epoch from #11505 changes. Each view gets a copy, so matching still filters per view. Skip unchanged applies. When the matched rules are the ones last applied, with no var() or calc() values, no keyframe animations and no local writes since, the property pass is skipped. Scoped className invalidation. Each selector scope records which classes selectors read outside their subject (ancestor and sibling compounds, functional pseudo-class arguments), and which subjects they gate. A className change restyles the view, then only descendants that are subjects of a selector reading a changed class. Scoped CSS variables reach descendants through var(), so the whole subtree is restyled below the changed view, and below any restyled descendant, that has or had scoped variables. It also falls back to the whole subtree when a [class...] attribute selector reads ancestors. Shared colors. Color converters reuse one Color per string; Color is immutable. The css: key string for each property is built once. Behavior change Descendants that are no longer restyled on a class change no longer restart their CSS keyframe animations. Before, every className change stopped and replayed the animations of the whole subtree; now only restyled views do. Numbers On its own the gain on these benchmarks is 1 to 4%, within run-to-run noise: their class toggle styles most of the views it affects, so scoped invalidation rarely skips work here. The gains are larger on top of #11507 and #11510 (all of the series together at size M: attach 0.62 to 0.76x, restyle 0.90x). Scenario (M) Painted before Painted after Attach before Attach after flex-wrap-tiles 913.1 908.0 437.7 424.1 grid-dashboard 236.4 234.2 118.0 114.7 insert-remove 916.5 899.8 438.4 421.6 nested-chain 31.3 31.1 16.7 16.3 relayout-resize 266.0 264.1 99.8 97.5 relayout-style 267.5 262.5 99.7 97.1 styled-cards 308.4 307.8 158.3 155.9 text-flow 167.6 166.5 44.9 43.2 tree-fanout 265.5 264.6 98.8 97.5 Mutation (M) Before After restyle (relayout-style) 145.9 143.6 restore (relayout-style) 145.7 145.6 insert (insert-remove) 372.6 372.2 remove (insert-remove) 240.3 245.7 shrink (relayout-resize) 115.1 117.6 grow (relayout-resize) 115.3 118.6 Resize only lays out and runs no CSS; its 2% difference is within run-to-run noise. How this was measured xplat-benchmarks ns-core app (plain core, no plugins), iPhone 17 Pro Max simulator, iOS 26.4. Each scenario mounts about 1,000 views at size M. Base and change were installed alternately for 3 rounds of 10 measured iterations, median ms, lower is better. "Attach" is assigning the built tree to a loaded parent (native view creation, CSS, native setters); "painted" ends one frame after layout. A GC is forced before each mutation, as it already is after each unmount, so a collection pause lands in the same phase for both builds. Stacked on #11505. Part of a series: #11505, #11506 (this), #11507, #11510.
Open Graph Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
X Description: PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this...
Opengraph URL: https://github.com/NativeScript/NativeScript/pull/11506
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:d929c022-76b3-cd23-70f4-02abde0ffb86 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 9638:CC1A4:15B2C71:1B98F8A:6B013052 |
| html-safe-nonce | 60ea677f84b6d241a579a0e80ca57b7ccb5576d98a2a21276e1f021e7fa3593b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NjM4OkNDMUE0OjE1QjJDNzE6MUI5OEY4QTo2QjAxMzA1MiIsInZpc2l0b3JfaWQiOiI1NTg4NDYzMzczMDM1MjM0MTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ea47387b308cb8ea5befbefb8075137d11538e87fbac58bc0f6472c432ecc874 |
| hovercard-subject-tag | pull_request:4752619492 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/NativeScript/NativeScript/pull/11506/files |
| twitter:image | https://avatars.githubusercontent.com/u/6695919?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/6695919?s=400&v=4 |
| og:image:alt | PR Checklist The PR title follows our guidelines: https://github.com/NativeScript/NativeScript/blob/master/tools/notes/CONTRIBUTING.md#commit-messages. There is an issue for the bug/feature this... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/NativeScript/NativeScript git https://github.com/NativeScript/NativeScript.git |
| octolytics-dimension-user_id | 7392261 |
| octolytics-dimension-user_login | NativeScript |
| octolytics-dimension-repository_id | 31492490 |
| octolytics-dimension-repository_nwo | NativeScript/NativeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31492490 |
| octolytics-dimension-repository_network_root_nwo | NativeScript/NativeScript |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width