Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Jan 24, 2020

Calling html.window.physicalSize with pending DOM writes triggers browser layout. This is particularly costly when we access physical size while painting (e.g. we do this when drawing text paragraphs). On some apps this costs up to 0.5ms each time it is called (e.g. once per paragraph).

This change caches a lazily-computed size in a FrameReference (which is cleared at the end of the frame). The first access that computes the initial value tends to be before we write anything to the DOM and therefore costs us nothing. Subsequent accesses, even after DOM write, use the cached value, and, again, cost nothing.

In at least one of our customer apps, this significantly dropped the frame time, reducing total amount of browser layout time from 28% per frame down to 11% per frame, with overall frame times dropping by up to ~40%.

Tests: this is purely an optimization; there is no change in functionality, so existing tests should already cover this.

@yjbanov yjbanov requested a review from ferhatb January 24, 2020 00:51
@auto-assign auto-assign bot requested a review from gw280 January 24, 2020 00:51
@yjbanov yjbanov added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 24, 2020
@yjbanov
Copy link
Contributor Author

yjbanov commented Jan 24, 2020

Landing on red. LUCI redness is Fuchsia infra failure.

@yjbanov yjbanov merged commit f430972 into flutter:master Jan 24, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 25, 2020
engine-flutter-autoroll added a commit to flutter/flutter that referenced this pull request Jan 25, 2020
flutter/engine@51a7964...4218f80

git log 51a7964..4218f80 --first-parent --oneline
2020-01-25 [email protected] Roll fuchsia/sdk/core/mac-amd64 from 7fqYj... to 35pbn... (flutter/engine#15984)
2020-01-25 [email protected] updating the versions of the browsers for flutter web engine unit tests (flutter/engine#15977)
2020-01-25 [email protected] Eliminate unused import in Android embedding (flutter/engine#15975)
2020-01-24 [email protected] Prevent duplicate plugin registration in FlutterEnginePluginRegistry. (#49365) (flutter/engine#15956)
2020-01-24 [email protected] retry logic for another cipd upload (flutter/engine#15974)
2020-01-24 [email protected] Ensure GetFixturesPath works on Fuchsia (flutter/engine#15978)
2020-01-24 [email protected] [web] Calling platform message callback after copy (flutter/engine#15950)
2020-01-24 [email protected] [fuchsia] Expose view_ref as part of dart:fuchsia initialization (flutter/engine#15958)
2020-01-24 [email protected] Refactor ShellTest to allow for different ShellTestPlatformViews (flutter/engine#15972)
2020-01-24 [email protected] Cache computed window.physicalSize in a FrameReference (flutter/engine#15955)
2020-01-24 [email protected] the the fix (flutter/engine#15973)
2020-01-24 [email protected] Optimize drawRRect to use dom_canvas (flutter/engine#15970)
2020-01-24 [email protected] Remove paint apply in draw image (flutter/engine#15969)
2020-01-24 [email protected] Roll fuchsia/sdk/core/mac-amd64 from 6_pZp... to 7fqYj... (flutter/engine#15966)


If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To report a problem with the AutoRoller itself, please file a bug:
https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+/master/autoroll/README.md
NoamDev pushed a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
NoamDev added a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
@yjbanov yjbanov deleted the optimize-physicalSize branch June 22, 2021 21:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants