-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=260183 Reviewed by Antti Koivisto. This PR fixes a number of issues to make requestidlecallback/deadline-max-rAF.html pass. 1. Due to rounding errors / loss of precision, IdleDeadline::timeRemaining could return a time that is off by 1ms or 20us, which ever is currently used for the time precision. We now ensure this off-by-one-time-unit issue does not affect idle callbacks by always subtracting the same amount from the remaining time. Since timeRemaining is defined to be an upper cap, this is fine. 2. didFinishRenderingUpdate was erroneously removing Page from m_pagesWithRenderingOpportunity when the next rendering update has been scheduled within the current rendering update. Moved the removal of the entry to at the beginning of Page::updateRendering so that subsequent scheduling of rendering update within this rendering update does not end up getting cleared. 3. shouldEndIdlePeriod would return true whenever m_pagesWithRenderingOpportunity contains any entry, which would effectively disable idle callbacks when there is any pending rendering update. We now return true only if the next rendering update is happening within the next 4ms. Unfortunately, this PR doesn't remove PASS FAIL expectation from deadline-max-rAF.html because the test fails intermittently on the stress bots, and adding any logging to help debug the issue will make the test no longer flaky, not providing means to debug it. Instead, this PR introduces a new layout test to test the same scenario. * LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic.html: * LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF.html: * LayoutTests/platform/ios-wk2/TestExpectations: * LayoutTests/platform/mac-wk2/TestExpectations: * LayoutTests/requestidlecallback/requestidlecallback-deadline-cap-by-rendering-update-expected.txt: Added. * LayoutTests/requestidlecallback/requestidlecallback-deadline-cap-by-rendering-update.html: Added. * Source/WebCore/dom/IdleDeadline.cpp: (WebCore::IdleDeadline::timeRemaining const): Fixed off-by-one error (1). * Source/WebCore/dom/WindowEventLoop.cpp: (WebCore::WindowEventLoop::didStartRenderingUpdate): Renamed from didFinishRenderingUpdate. (WebCore::WindowEventLoop::opportunisticallyRunIdleCallbacks): (WebCore::WindowEventLoop::shouldEndIdlePeriod): Now takes the current timestamp and only returns true if the next rendering update is happening within the next 4ms instead of whenever (3). (WebCore::WindowEventLoop::computeIdleDeadline): (WebCore::WindowEventLoop::nextRenderingTime const): Added. * Source/WebCore/dom/WindowEventLoop.h: * Source/WebCore/page/Page.cpp: (WebCore::Page::updateRendering): Moved the call to didStartRenderingUpdate (previously named didFinishRenderingUpdate) here so that rendering update scheduled within this rendering update doesn't get cleared at the end of the current rendering update (2). (WebCore::Page::renderingUpdateCompleted): * Source/WebCore/page/Performance.cpp: (WebCore::Performance::timeResolution): Added. * Source/WebCore/page/Performance.h: Canonical link: https://commits.webkit.org/267008@main
- Loading branch information
Showing
11 changed files
with
92 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...sts/requestidlecallback/requestidlecallback-deadline-cap-by-rendering-update-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
This tests that the deadline can be reached. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS idleDeadline.timeRemaining() <= preferredRenderingUpdateInterval is true | ||
PASS didRunIdleCallback is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
33 changes: 33 additions & 0 deletions
33
LayoutTests/requestidlecallback/requestidlecallback-deadline-cap-by-rendering-update.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] --> | ||
<html> | ||
<body> | ||
<script src="../resources/js-test.js"></script> | ||
<script> | ||
|
||
description('This tests that the deadline can be reached.'); | ||
|
||
jsTestIsAsync = true; | ||
|
||
let didRunIdleCallback = false; | ||
onload = () => { | ||
function runRAFLoop() { | ||
requestAnimationFrame(runRAFLoop); | ||
} | ||
runRAFLoop(); | ||
requestIdleCallback((idleDeadline) => { | ||
didRunIdleCallback = true; | ||
window.idleDeadline = idleDeadline; | ||
window.preferredRenderingUpdateInterval = internals.preferredRenderingUpdateInterval(); | ||
shouldBeTrue('idleDeadline.timeRemaining() <= preferredRenderingUpdateInterval'); | ||
if (idleDeadline.timeRemaining() > preferredRenderingUpdateInterval) | ||
console.log(idleDeadline.timeRemaining() + ' >' + preferredRenderingUpdateInterval); | ||
}); | ||
setTimeout(() => { | ||
shouldBeTrue('didRunIdleCallback'); | ||
finishJSTest(); | ||
}, 200); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters