Bug 1643604 Comment 5 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

I've tracked the issue down to [this line](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/gfx/layers/apz/src/AsyncPanZoomController.cpp#4558) causing an extra repaint after every first-paint of a scroll frame. This repaint appears to be unnecessary, as we're just accepting the scroll frame's layout viewport for the first time.

I don't understand the exact mechanism by which this extra repaint results in the observed performance regression, but it seems to somehow make it so that going into [`nsRefreshDriver::GetTransactionId()`](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#2330), `mOutstandingTransactionId` is always the same as `mCompletedTransaction` (whereas before the change, `mOutstandingTransactionId` would typically trail `mCompletedTransaction` by 1), causing us to avoid [setting `mWaitingForTransaction`](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#2337), which in turn causes us to [avoid this early exit](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#1872) in `Tick()` and reach the place where we [stop the refresh timer](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#1915) much more often.
I've tracked the issue down to [this line](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/gfx/layers/apz/src/AsyncPanZoomController.cpp#4558) causing an extra repaint after every first-paint of a scroll frame. This repaint appears to be unnecessary, as we're just accepting the scroll frame's layout viewport for the first time.

I don't understand the exact mechanism by which this extra repaint results in the observed performance regression, but it seems to somehow make it so that going into [`nsRefreshDriver::GetTransactionId()`](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#2330), `mOutstandingTransactionId` is always the same as `mCompletedTransaction` (whereas before the change, `mOutstandingTransactionId` would typically be ahead of `mCompletedTransaction` by 1), causing us to avoid [setting `mWaitingForTransaction`](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#2337), which in turn causes us to [avoid this early exit](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#1872) in `Tick()` and reach the place where we [stop the refresh timer](https://searchfox.org/mozilla-central/rev/4bb2401ecbfce89af06fb2b4d0ea3557682bd8ff/layout/base/nsRefreshDriver.cpp#1915) much more often.

Back to Bug 1643604 Comment 5