mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Fixes https://github.com/flutter/flutter/issues/173097 The semantics flush is ~200 μs slower with the shortcuircut removed + #177477 (which reduces the time increase by ~ 100 μs, from 876 μs to 773 μs) I tried to introduce caching in [a different patch](https://github.com/flutter/flutter/compare/master...LongCatIsLooong:semantics-geometry?expand=1) but that patch is more risky and still needs a cleanup. 773 μs doesn't seem bad considering there were little to no geometry updates between frames before the fix. Introducing cache currently only improves `Semantics.ensureGeometry` by less than 100 μs and is much more risky / harder to ensure the correctness. ### BEFORE ``` [bench_material3_scroll_semantics] name: bench_material3_scroll_semantics SEMANTICS: (samples: 98 clean/2 outliers/100 measured/300 total) | average: 567.0510204081633 μs | outlier average: 799 μs | outlier/clean ratio: 1.4090442856885785x | noise: 13.95% Semantics.updateChildren: (samples: 91 clean/9 outliers/100 measured/300 total) | average: 58.9010989010989 μs | outlier average: 199.88888888888889 μs | outlier/clean ratio: 3.3936359867330017x | noise: 82.78% Semantics.ensureGeometry: (samples: 95 clean/5 outliers/100 measured/300 total) | average: 95.46315789473684 μs | outlier average: 299 μs | outlier/clean ratio: 3.1320983570404675x | noise: 64.29% Semantics.ensureSemanticsNode: (samples: 100 clean/0 outliers/100 measured/300 total) | average: 78.59 μs | outlier average: 78.59 μs | outlier/clean ratio: 1x | noise: 80.86% drawFrameDuration: (samples: 98 clean/2 outliers/100 measured/300 total) | average: 1685.6938775510205 μs | outlier average: 2000 μs | outlier/clean ratio: 1.1864550418285935x | noise: 7.77%``` ``` ### AFTER (with this and https://github.com/flutter/flutter/pull/177477) ``` [bench_material3_scroll_semantics] name: bench_material3_scroll_semantics SEMANTICS: (samples: 91 clean/9 outliers/100 measured/300 total) | average: 773.1098901098901 μs | outlier average: 1000 μs | outlier/clean ratio: 1.2934771793669069x | noise: 10.65% Semantics.updateChildren: (samples: 94 clean/6 outliers/100 measured/300 total) | average: 48.648936170212764 μs | outlier average: 200 μs | outlier/clean ratio: 4.111086813907719x | noise: 102.15% Semantics.ensureGeometry: (samples: 95 clean/5 outliers/100 measured/300 total) | average: 239.55789473684212 μs | outlier average: 399.6 μs | outlier/clean ratio: 1.6680727656208807x | noise: 22.05% Semantics.ensureSemanticsNode: (samples: 99 clean/1 outliers/100 measured/300 total) | average: 194.5151515151515 μs | outlier average: 400 μs | outlier/clean ratio: 2.0563950771148156x | noise: 31.31% drawFrameDuration: (samples: 95 clean/5 outliers/100 measured/300 total) | average: 1775.8315789473684 μs | outlier average: 2099.6 μs | outlier/clean ratio: 1.1823193285280729x | noise: 7.56% ``` ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md