Commit Graph

819 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
d4cd5b3261 Bug 1897752 - Clean up layout telemetry. r=smaug
This telemetry was trying to measure three things:

 * The time spent during style / layout in a tick. This is useful.
 * The times SetNeed{Style,Layout} flush have been called. This is not a
   particularly useful metric, there's not much to learn or change from
   it. Any call is basically free as long as they're consecutive /
   there's no flush in between.
 * The number of times layout / style has been flushed during a tick.
   This is more useful than the above but, similarly, there's not too
   much to be learned here. Number of flushes can be completely
   orthogonal to how expensive it has been.

It also had a number of flaws:

 * It is recorded per-PresShell, so we get multiple pings per tick.
 * Similarly, if a sub-frame dies before the tick, we just never report
   that time.

Instead, refactor it to make it simpler, and just record the first
metric reliably. This simplifies the code substantially, and I don't
think we're losing much.

The histograms are also expired. We might want to renew this, I'll file
a follow-up to either properly renew this if we plan to look at it, or
remove the code entirely from the tree.

Differential Revision: https://phabricator.services.mozilla.com/D210907
2024-05-20 14:30:08 +00:00
Emilio Cobos Álvarez
fc159ff851 Bug 1896762 - Make animation timing match the spec. r=smaug,firefox-animation-reviewers,boris
Differential Revision: https://phabricator.services.mozilla.com/D210658
2024-05-17 16:33:06 +00:00
Natalia Csoregi
2646ae722f Backed out changeset afcc70a5e871 (bug 1896762) for causing failures on css-transition-cross-document.html CLOSED TREE 2024-05-17 18:50:54 +03:00
Emilio Cobos Álvarez
d554a723e9 Bug 1897322 - More consistently deal with pres shell style observers. r=smaug
Much like we deal with resize events.

Differential Revision: https://phabricator.services.mozilla.com/D210776
2024-05-17 11:56:36 +00:00
Stanca Serban
4edbdf3b0d Backed out changeset 0328321272d7 (bug 1897322) for causing multiple failures. CLOSED TREE 2024-05-17 14:09:21 +03:00
Emilio Cobos Álvarez
9bae74fae2 Bug 1897322 - More consistently deal with pres shell style observers. r=smaug
Much like we deal with resize events.

Differential Revision: https://phabricator.services.mozilla.com/D210776
2024-05-17 10:25:31 +00:00
Emilio Cobos Álvarez
c54d301d5e Bug 1896762 - Make animation timing match the spec. r=smaug,firefox-animation-reviewers,boris
Differential Revision: https://phabricator.services.mozilla.com/D210658
2024-05-17 08:33:36 +00:00
Emilio Cobos Álvarez
2844cddbc3 Bug 1896760 - Make resize event timing match the spec. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D210383
2024-05-15 16:22:13 +00:00
Jamie Nicol
16b72880b4 Bug 1896024 - Ensure PerformanceHintSession is valid before reporting work duration. r=jesup,smaug
Differential Revision: https://phabricator.services.mozilla.com/D210042
2024-05-15 14:11:57 +00:00
Emilio Cobos Álvarez
1b4fb09397 Bug 1896593 - Fix a devtools frequent intermittent.
We should be more consistent about what stuff runs and what doesn't when
the pres context is getting torn down...

MANUAL PUSH: Trivialish orange fix CLOSED TREE
2024-05-15 18:05:11 +02:00
Tamas Szentpeteri
898fdb920e Backed out changeset 2894ff06108e (bug 1896024) for causing almost perma crashes on browser_webconsole_filter_buttons_overflow.js. 2024-05-15 15:09:05 +03:00
Emilio Cobos Álvarez
c4b2292488 Bug 1896763 - Make display observer timing happen after all layout changes are possibly done. r=smaug,Jamie
Not sure how testable this is, for a11y purposes. The other consumer is
some XRSession stuff which doesn't seem to care too much about the
timing of this.

Differential Revision: https://phabricator.services.mozilla.com/D210384
2024-05-15 09:36:52 +00:00
Jamie Nicol
821133c3a8 Bug 1896024 - Ensure PerformanceHintSession is valid before reporting work duration. r=jesup,smaug
Differential Revision: https://phabricator.services.mozilla.com/D210042
2024-05-15 08:38:27 +00:00
Emilio Cobos Álvarez
85204e6099 Bug 1896593 - Make our refresh driver tick match the HTML spec more closely. r=smaug
This doesn't change behavior intentionally, though it annotates places
where our code doesn't match the spec right now, and adds comments and
quotes the HTML spec in the relevant places.

Some things that this highlights:

 * Resize steps are fired at the wrong time.
 * Some of our animation stuff seems sketchy / out of place too to me
   (AnimationTimeline observes the refresh driver at the style phase).
 * Focus fix-up is out of order (that's known, bug 1788741 for tests).
 * Our layout flush stuff should probably be better integrated / closer
   to the resize observer loop.
 * Display observers are run before stuff like ResizeObserver runs. That
   might be a problem for accessibility's NotificationController?

Again, these are intentionally not addressed in this patch.

Differential Revision: https://phabricator.services.mozilla.com/D210279
2024-05-14 21:55:33 +00:00
Emilio Cobos Álvarez
0a1d2b49ff Bug 1895870 - Simplify refresh driver observer set-up. r=smaug
There's no call to AddRefreshObserver(FlushType::Layout), so we don't
need to track layout flushes. The only reason we need
mLayoutFlushObservers is so that reflows triggered from the style flush
get processed. But at that point, we can just flush layout directly.

There's no really good distinction between style flushes and layout
flushes with container queries anyways, so this makes the code simpler
to reason about.

Differential Revision: https://phabricator.services.mozilla.com/D209924
2024-05-14 08:12:03 +00:00
Emilio Cobos Álvarez
46a31e3de5 Bug 1891597 - Simplify IntersectionObserver notifications. r=smaug
DOMIntersectionObserver::Update doesn't run script, so we can write this
code in a more straight-forward way.

Differential Revision: https://phabricator.services.mozilla.com/D207478
2024-04-16 02:58:10 +00:00
Dan Robertson
fc1137ebcc Bug 1881974 - RefreshDriver fires scroll events before scrollend events. r=hiro
Ensure that the RefreshDriver fires all queued scroll events before
firing scrollend events.

Differential Revision: https://phabricator.services.mozilla.com/D204385
2024-04-01 18:01:40 +00:00
Frédéric Wang
ea8819b5ee Bug 1880928 - Remove last remembered size observer, handle it in Document::DetermineProximityToViewportAndNotifyResizeObservers. r=emilio,layout-reviewers
The CSS Box Sizing specification indicates that last remembered sizes
are recorded "at the time that ResizeObserver events are determined and
delivered" [1].

In bug 1807253, we changed the implementation of when proximity to the
viewport of `content-visibility: auto` nodes are determined and of when
resize observations are broadcast, in order to align with the latest
version of the HTML specification [2]. We continue to use an internal
`Document::mLastRememberedSizeObserver` to update last remembered sizes
but it has been causing issues (e.g. bug 1867090 and bug 1880928) and
could be replaced by a direct update before broadcasting resize
observations.

This is what the current patch is doing. The elements currently observed
by `Document::mLastRememberedSizeObserver` are now stored on a
`Document::mElementsWithLastRememberedSize` hashset and a new function
`Document::UpdateLastRememberedSizes` is called before broadcasting
resize observations, and peforms the work of `LastRememberedSizeCallback`
and of `CalculateBoxSize` (with `aBox=Content_box`).

The only behavior change is in the `while(true)` loop from
`DetermineProximityToViewportAndNotifyResizeObservers`: at each step
we update the last remember sizes for elements of arbitrary depth, and
don't use these depths for calculating `shallowestTargetDepth`. This is
fine, since our `LastRememberedSizeCallback` only records current box
sizes without causing significant side effects (e.g. execution of
JavaScript code) that may require a relayout.

[1] https://drafts.csswg.org/css-sizing-4/#last-remembered
[2] https://html.spec.whatwg.org/#update-the-rendering

Differential Revision: https://phabricator.services.mozilla.com/D202571
2024-02-29 08:50:55 +00:00
Chris H-C
1c0270168b Bug 1877842 - Migrate performance GVST probes r=perry.mcmanis,denispal
Most are brought over straightforwardly, their Telemetry callsites reworded
to use Glean, with mirroring to the Telemetry probes taken care of by the Glean
Interface For Firefox Telemetry (see the telemetry_mirror property).

There were two special cases: PERF_DOM_CONTENT_LOADED_FROM_RESPONSESTART_MS,
and PERF_DOM_CONTENT_LOADED_MS. Both were removed as they were unused.

Differential Revision: https://phabricator.services.mozilla.com/D200867
2024-02-09 21:11:05 +00:00
Olli Pettay
ba689444ea Bug 1870008 - make high rate mode handling dynamic, r=farre
Differential Revision: https://phabricator.services.mozilla.com/D196591
2023-12-18 15:40:09 +00:00
Emilio Cobos Álvarez
0d34e41b89 Bug 1867042 - Don't force PresShell initialization from ResizeObserver handling. r=fredw
This is unfortunately somewhat hard to test, because paint suppression
is not really quite observable by the page.

This makes sure that we don't report resize observations etc until the
page has been laid out for other reasons.

Differential Revision: https://phabricator.services.mozilla.com/D194910
2023-11-28 22:27:59 +00:00
Frederic Wang
ddfb81b48e Bug 1807253 - unreliable timing for content-visibility:auto, r=emilio
Rewrite implementation of content-visibility: auto as defined in
https://github.com/w3c/csswg-drafts/issues/8542

Differential Revision: https://phabricator.services.mozilla.com/D170394
2023-11-27 08:26:46 +00:00
Natalia Csoregi
9e23519bf8 Backed out changeset 20a5c1f3b35e (bug 1807253) for causing failures on content-visibility-continuations-crash.html. CLOSED TREE 2023-11-22 16:12:27 +02:00
Frederic Wang
28dfc50a7f Bug 1807253 - unreliable timing for content-visibility:auto, r=emilio
Rewrite implementation of content-visibility: auto as defined in
https://github.com/w3c/csswg-drafts/issues/8542

Differential Revision: https://phabricator.services.mozilla.com/D170394
2023-11-22 13:00:36 +00:00
Olli Pettay
c43dc7f002 Bug 1857618 - Ensure normal tasks get enough time to run, r=mstange
The basic idea is to check if there are pending tasks also right after RefreshDriver tick has been handled, not only before tick.
But in this new case we can't predict how much time is needed for other tasks, so just a bit of time is given.

The patch tweaks also other things: CanDoCatchUpTick (which is used by catch-up ticks and FinishedWaitingForTransaction) should
return false if the active timer is blocked because of mSuspendVsyncPriorityTicksUntil.
And to make it easier to check whether driver is blocked, mSuspendVsyncPriorityTicksUntil is changed to rely on local time, not the time stamp
from vsync.

The low priority notify is changed so that it uses member variables from the driver and in case it does trigger a tick, it uses the most recent skipped
values.

Differential Revision: https://phabricator.services.mozilla.com/D193409
2023-11-20 10:20:30 +00:00
Emilio Cobos Álvarez
9fb7a17630 Bug 1864425 - Remove PendingAnimationTracker. r=birtles
Instead of starting transitions and animations as a result of a paint,
use the refresh driver tick to do this.

This sets the transition-ready time to the current time during the next
refresh driver tick that it was started on (see mSawTickWhilePending).

This is similar to what's described in the bugs comments, and seems to
work nicely in practice.

We could easily change that (current time) by a paint-based time if
needed (when available), which would be more similar to what we were
doing. But I'd rather do the simple thing for now, and land this shortly
after the soft freeze is over so that we have time to watch out for
regressions.

There's one regression on a test that birtles wrote (using an XHR doc
and switching the timeline to a rendered doc's timeline).

We use the timeline's document rather than the target document to
determine whether to trigger animations now. That's one of the cases
where we'd keep vsync perma-running without this patch, and Chrome also
fails that test. Maybe the test should be removed / the spec should be
tweaked to allow this behavior?

This causes some progression in some CSS transitions tests too, and I
added an extra test for the vsync behavior.

Over-all this is much simpler to reason about and I think we should try
to do this.

Differential Revision: https://phabricator.services.mozilla.com/D193583
2023-11-20 09:31:41 +00:00
Stanca Serban
64050fac35 Backed out changeset 4683ed11f2cd (bug 1857618) for causing multiple assertion failures in nsRefreshDriver.cpp. CLOSED TREE 2023-11-16 01:55:07 +02:00
Olli Pettay
3a3c9824fc Bug 1857618 - Ensure normal tasks get enough time to run, r=mstange
The basic idea is to check if there are pending tasks also right after RefreshDriver tick has been handled, not only before tick.
But in this new case we can't predict how much time is needed for other tasks, so just a bit of time is given.

The patch tweaks also other things: CanDoCatchUpTick (which is used by catch-up ticks and FinishedWaitingForTransaction) should
return false if the active timer is blocked because of mSuspendVsyncPriorityTicksUntil.
And to make it easier to check whether driver is blocked, mSuspendVsyncPriorityTicksUntil is changed to rely on local time, not the time stamp
from vsync.

The low priority notify is changed so that it uses member variables from the driver and in case it does trigger a tick, it uses the most recent skipped
values.

Differential Revision: https://phabricator.services.mozilla.com/D193409
2023-11-15 21:06:20 +00:00
Cristian Tuns
d8831f9284 Backed out changeset 4953e7db7d08 (bug 1857618) because of some performance regressions CLOSED TREE 2023-11-06 17:46:51 -05:00
Sean Feng
2d6e584e05 Bug 1722322 - Implement LargestContentfulPaint r=emilio
Spec: https://w3c.github.io/largest-contentful-paint

Differential Revision: https://phabricator.services.mozilla.com/D151079
2023-11-02 20:53:36 +00:00
Sandor Molnar
d23e2827b7 Backed out 7 changesets (bug 1722322) for causing bp-nu bustages
Backed out changeset 0ebd32e273b8 (bug 1722322)
Backed out changeset 7a75717f127c (bug 1722322)
Backed out changeset c2a6440a83d7 (bug 1722322)
Backed out changeset 9955756855bd (bug 1722322)
Backed out changeset 37fccb407777 (bug 1722322)
Backed out changeset f52b1f28f753 (bug 1722322)
Backed out changeset 0121c8cf5d2f (bug 1722322)
2023-11-02 21:27:24 +02:00
Sean Feng
cacfa492a8 Bug 1722322 - Implement LargestContentfulPaint r=emilio
Spec: https://w3c.github.io/largest-contentful-paint

Differential Revision: https://phabricator.services.mozilla.com/D151079
2023-11-02 17:04:47 +00:00
Daniel Holbert
aeca752232 Bug 1861259 part 3: Coalesce redundant array-index checks in nsRefreshDriver. r=tnikkel
This patch doesn't change behavior; it just removes some redundant checks.

(Note that the tight-scoping around nsAutoMicroTask/ReduceAnimations is
important for the RAII object to be torn down at the intended time; but it
doesn't need its own if-check.)

Depends on D191909

Differential Revision: https://phabricator.services.mozilla.com/D191911
2023-10-25 23:50:05 +00:00
Daniel Holbert
b153a2fb34 Bug 1861259 part 2: Unroll the observer-array-loop in nsRefreshDriver::Tick. r=tnikkel
This patch doesn't change behavior.

This is a bit gross, but it helps us make better use of the backtrace to figure
out what's going on in a given crash report.

Differential Revision: https://phabricator.services.mozilla.com/D191909
2023-10-25 23:50:04 +00:00
Daniel Holbert
aa691045e1 Bug 1861259 part 1: Refactor out a helper function for loop body in nsRefreshDriver::Tick. r=tnikkel
This doesn't affect behavior; it's just a pure refactoring, moving code from
being inline to being in a helper function.

Differential Revision: https://phabricator.services.mozilla.com/D191908
2023-10-25 23:50:04 +00:00
Adam Brouwers-Harries
4a2ba69cbc Bug 1421651 - Remove obseleted timeline and TimelineMarker code r=canaltinova,webidl,devtools-reviewers,saschanaz,smaug,ochameau
This patch removes the old docshell timeline and timeline markers codebase and replaces them with equivalent Gecko profiler marker. This patch also fixes Bug 1834143, which is a subset of 1421651.

Differential Revision: https://phabricator.services.mozilla.com/D184217
2023-10-24 15:18:12 +00:00
Narcis Beleuzu
67b61b8b2c Backed out changeset 714aaf6484fb (bug 1421651) for causing Bug 1860719. CLOSED TREE 2023-10-24 17:31:02 +03:00
Adam Brouwers-Harries
720e582a3a Bug 1421651 - Remove obseleted timeline and TimelineMarker code r=canaltinova,webidl,devtools-reviewers,saschanaz,smaug,ochameau
This patch removes the old docshell timeline and timeline markers codebase and replaces them with equivalent Gecko profiler marker. This patch also fixes Bug 1834143, which is a subset of 1421651.

Differential Revision: https://phabricator.services.mozilla.com/D184217
2023-10-23 13:55:50 +00:00
Sean Feng
8bcf58cf05 Bug 1856514 - Make sure nsRefreshDriver will tick enough times for user input handling r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D190108
2023-10-11 19:39:37 +00:00
Olli Pettay
a5fec5a9ef Bug 1857618 - Ensure normal tasks get enough time to run, so try to avoid triggering RefreshDriver too often, r=bas
Based on testing we can simplify the current setup and also ensure that we don't trigger a RefreshDriver tick too soon
(so that we don't get two ticks when we expect only one).
This gets us even closer to Chrome's raf handling.

Differential Revision: https://phabricator.services.mozilla.com/D190361
2023-10-10 22:45:47 +00:00
Emilio Cobos Álvarez
d02e297b2d Bug 1624819 - Remove TaskCategory and other quantum dom remnants. r=smaug,media-playback-reviewers,credential-management-reviewers,cookie-reviewers,places-reviewers,win-reviewers,valentin,mhowell,sgalich,alwu
Sorry this is not a particularly easy patch to review. But it should be
mostly straight-forward.

I kept Document::Dispatch mostly for convenience, but could be
cleaned-up too / changed by SchedulerGroup::Dispatch. Similarly maybe
that can just be NS_DispatchToMainThread if we add an NS_IsMainThread
check there or something (to preserve shutdown semantics).

Differential Revision: https://phabricator.services.mozilla.com/D190450
2023-10-10 08:51:12 +00:00
Daniel Holbert
f763d4b290 Bug 1857561: Make nsRefreshDriver::Tick gracefully bail if a resize observer destroys the PresContext. r=surkov,emilio
Note, I'm deleting the null-check from UpdateIntersectionObservations, since
I'm essentially hoisting it up one level (and I don't think there's anything
that could null out mPresContext in the intervening code).

Differential Revision: https://phabricator.services.mozilla.com/D190367
2023-10-09 18:49:39 +00:00
Olli Pettay
59bac9f5f4 Bug 1856545 - Try to utilize idle time more, r=farre
We can go through quite a few more timers these days, since timers are stored now in an array and iterating through that is fast.
Also, relying on timer value for another thread or low priority timers does prevent idle tasks to run in some cases, and now that more timers
are iterated through, that behavior can be tweaked.

For RefreshDriver this is taking the simple approach and just let idle tasks to run if RefreshDriver isn't ticking. We do start RefreshDriverTimer pretty
much always when something in DOM or layout is changing.

Differential Revision: https://phabricator.services.mozilla.com/D189909
2023-10-06 11:04:04 +00:00
Cristina Horotan
9e5159a3b2 Backed out changeset 5873383c36e2 (bug 1856545) for causing talos max run time exceeded failures. CLOSED TREE 2023-10-06 04:07:39 +03:00
Olli Pettay
c46d698d22 Bug 1856545 - Try to utilize idle time more, r=farre
We can go through quite a few more timers these days, since timers are stored now in an array and iterating through that is fast.
Also, relying on timer value for another thread or low priority timers does prevent idle tasks to run in some cases, and now that more timers
are iterated through, that behavior can be tweaked.

For RefreshDriver this is taking the simple approach and just let idle tasks to run if RefreshDriver isn't ticking. We do start RefreshDriverTimer pretty
much always when something in DOM or layout is changing.

Differential Revision: https://phabricator.services.mozilla.com/D189909
2023-10-05 18:10:30 +00:00
Emilio Cobos Álvarez
a4e410eecd Bug 1857115 - Add a couple null-checks. r=surkov
Resize observers might have disconnected the refresh driver.

Differential Revision: https://phabricator.services.mozilla.com/D190165
2023-10-05 17:14:07 +00:00
Emilio Cobos Álvarez
061c11bc12 Bug 1857073 - Remove ResizeObserverController. r=surkov,smaug
These days it's just a very thin wrapper over an nsTArray of
ResizeObservers. We also schedule notifications for resize observations
for the whole BrowsingContext tree at once, so there's no point on
individually keep track of them.

Differential Revision: https://phabricator.services.mozilla.com/D190113
2023-10-05 12:11:56 +00:00
Alexander Surkov
793b37abb9 Bug 1807253 - get rid of ResizeObserverNotificationHelper, r=emilio
Integrate resize observer processing with RefreshDriver to make it
more extensible.

Differential Revision: https://phabricator.services.mozilla.com/D189697
2023-10-03 09:48:46 +00:00
Jamie Nicol
81a58d5226 Bug 1850573 - Create/destroy PerformanceHintSession in ContentChild based on process priority. r=smaug
We use a PerformanceHintSession where supported to ensure the content
process main thread and stylo threads are scheduled at a high
priority. Previously we created the session when the
VsyncRefreshDriverTimer is started, and destroyed the session when it
is stopped (after a timeout).

This patch instead moves the creation and destruction to ContentChild
based on the process priority. This more accurately reflects the
conditions under which we want the session to be active.

Differential Revision: https://phabricator.services.mozilla.com/D188477
2023-09-26 12:55:37 +00:00
Emilio Cobos Álvarez
728debfb33 Bug 1847929 - Remove OOPIF activity grace period. r=smaug
This massive hack shouldn't be needed after the previous patch, and
throttling of in-process and out-of-process should be consistent now.

Differential Revision: https://phabricator.services.mozilla.com/D185809
2023-09-06 11:15:45 +00:00