Introduce an experiment to measure page jank via vsync.#7293
Introduce an experiment to measure page jank via vsync.#7293lannka merged 6 commits intoampproject:masterfrom
Conversation
lannka
commented
Feb 1, 2017
- The experiment will display a jank meter at the left bottom of the page.
- The experiment is purely opt-in based.
| } | ||
|
|
||
| if (isExperimentOn(this.win, 'measure-jank') && this.win.performance) { | ||
| this.jankRateDisplay_ = this.win.document.createElement('div'); |
There was a problem hiding this comment.
Need to set this to null in the else.
| // Schedule actual animation frame and then run tasks. | ||
| this.scheduled_ = true; | ||
| if (this.jankRateDisplay_) { | ||
| this.scheduledTime_ = this.win.performance.now(); |
There was a problem hiding this comment.
this.scheduledTime_ needs to be added in the constructor.
src/service/vsync-impl.js
Outdated
| if (paintLatency > 100) { | ||
| this.bigJankCounter_++; | ||
| } | ||
| this.jankRateDisplay_./*OK*/innerText = |
There was a problem hiding this comment.
can we use textContent instead
| visibility: hidden; | ||
| } | ||
|
|
||
| .i-amphtml-pjr { |
| if (paintLatency > 100) { | ||
| this.bigJankCounter_++; | ||
| } | ||
| this.jankRateDisplay_.textContent = |
There was a problem hiding this comment.
This could add significant jank.
There was a problem hiding this comment.
why is that? i believe textContent does not re-layout.
There was a problem hiding this comment.
That is a bit of a misunderstanding. Reading it never layouts. That is the big (and unintuitive) difference from innerText. Writing it can obviously cause layout, since changing text can change layout.
There was a problem hiding this comment.
we are already in a vsync, so the impact should be minimum? since textContext doesn't take CSS into account, and will not do a re-measure and re-flow.
I know this is like quantum mechanics, measuring simply affects the thing it measures. But since this meter is opt-in only, so should be fine?
| this.docState_.onVisibilityChanged(boundOnVisibilityChanged); | ||
| } | ||
|
|
||
| /** @private {?Element} */ |
There was a problem hiding this comment.
Please refactor this CL to isolate the jank rate specific functionality into a file or at least functions.