Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 374b4feb0aeff3225da6e6f25579d7b460f1363e
https://github.com/WebKit/WebKit/commit/374b4feb0aeff3225da6e6f25579d7b460f1363e
Author: Ryosuke Niwa <[email protected]>
Date: 2023-08-14 (Mon, 14 Aug 2023)
Changed paths:
M LayoutTests/TestExpectations
A
LayoutTests/http/tests/eventloop/idle-callback-not-affected-by-timers-in-cross-origin-expected.txt
A
LayoutTests/http/tests/eventloop/idle-callback-not-affected-by-timers-in-cross-origin.html
A LayoutTests/http/tests/eventloop/resources/idle-callback-timer-helper.html
M
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic-expected.txt
M LayoutTests/platform/ios-wk2/TestExpectations
M LayoutTests/platform/mac-wk2/TestExpectations
M LayoutTests/requestidlecallback/requestidlecallback-in-page-cache.html
M Source/WebCore/dom/EventLoop.cpp
M Source/WebCore/dom/EventLoop.h
M Source/WebCore/dom/IdleCallbackController.h
M Source/WebCore/dom/IdleDeadline.cpp
M Source/WebCore/dom/WindowEventLoop.cpp
M Source/WebCore/page/Page.cpp
M Source/WebCore/platform/Timer.h
Log Message:
-----------
Event loop should attempt to run idle callbacks at the end of each task
https://bugs.webkit.org/show_bug.cgi?id=260115
Reviewed by Wenson Hsieh.
This PR implements the step 8 in the HTML5 event loop processing model:
https://html.spec.whatwg.org/multipage/webappapis.html#event-loop-processing-model
Specifically, after executing each task in WindowEventLoop, we check if there
are any tasks or microtasks
scheduled in the event loop. If there are none, we attempt to run idle
callbacks.
This PR also fixes IdleDeadline::timeRemaining to subtract the current time
before reducing the resolution
as it turns out that reducing the resolution before subtraction can generate
the remaining time that is
slightly longer than the actual time remaining. e.g. 50.000000002ms as opposed
to 50ms.
In addition, this PR updates WindowEventLoop::computeIdleDeadline() to take
into account the next time
a timer associated with this event loop fires. This is computed & cached by
EventLoop::nextTimerFiringTime.
Finally, this PR also fixes a bug in Page::scheduleRenderingUpdateInternal()
that it was sometimes calling
WindowEventLoop::didScheduleRenderingUpdate with a rendering update time in the
past.
*
LayoutTests/http/tests/eventloop/idle-callback-not-affected-by-timers-in-cross-origin-expected.txt:
Added.
*
LayoutTests/http/tests/eventloop/idle-callback-not-affected-by-timers-in-cross-origin.html:
Added.
* LayoutTests/http/tests/eventloop/resources/idle-callback-timer-helper.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic-expected.txt:
* LayoutTests/platform/ios-wk2/TestExpectations:
* LayoutTests/platform/mac-wk2/TestExpectations:
* LayoutTests/requestidlecallback/requestidlecallback-in-page-cache.html: This
test was relying on the idle
callback in the main frame to be invoked after idle callbacks in subframes.
Since this is not guaranteed,
* Source/WebCore/dom/EventLoop.cpp:
(WebCore::EventLoop::scheduleTask):
(WebCore::EventLoop::removeScheduledTimer):
(WebCore::EventLoop::scheduleRepeatingTask):
(WebCore::EventLoop::removeRepeatingTimer):
(WebCore::EventLoop::findMatchingAssociatedContext): Added.
(WebCore::EventLoop::nextTimerFiringTime const): Added.
(WebCore::EventLoopTaskGroup::suspend):
(WebCore::EventLoopTaskGroup::resume):
(WebCore::EventLoopTaskGroup::setTimerAlignment):
(WebCore::EventLoopTaskGroup::didChangeTimerAlignmentInterval):
(WebCore::EventLoopTaskGroup::setTimerHasReachedMaxNestingLevel):
(WebCore::EventLoopTaskGroup::adjustTimerNextFireTime):
(WebCore::EventLoopTaskGroup::adjustTimerRepeatInterval):
* Source/WebCore/dom/EventLoop.h:
(WebCore::EventLoop::invalidateNextTimerFiringTimeCache): Added.
* Source/WebCore/dom/IdleCallbackController.h:
(WebCore::IdleCallbackController::isEmpty):
* Source/WebCore/dom/IdleDeadline.cpp:
(WebCore::IdleDeadline::timeRemaining const):
* Source/WebCore/dom/WindowEventLoop.cpp:
(WebCore::WindowEventLoop::computeIdleDeadline):
(WebCore::WindowEventLoop::didReachTimeToRun):
* Source/WebCore/page/Page.cpp:
(WebCore::Page::scheduleRenderingUpdateInternal):
* Source/WebCore/platform/Timer.h:
(WebCore::TimerBase::nextFireTime const):
Canonical link: https://commits.webkit.org/266877@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes