-
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.
Cap the duration of EventLoop::run in the main thread
https://bugs.webkit.org/show_bug.cgi?id=260112 Reviewed by Yusuke Suzuki. Cap the duration of EventLoop::run in the main thread using the same time limit ThreadTimers::sharedTimerFiredInternal() uses. * LayoutTests/fast/eventloop/queue-task-event-loop-starvation-expected.txt: Added. * LayoutTests/fast/eventloop/queue-task-event-loop-starvation.html: Added. * Source/WebCore/dom/EventLoop.cpp: (WebCore::EventLoop::run): * Source/WebCore/dom/EventLoop.h: * Source/WebCore/dom/WindowEventLoop.cpp: (WebCore::WindowEventLoop::didReachTimeToRun): * Source/WebCore/platform/ThreadTimers.cpp: * Source/WebCore/platform/ThreadTimers.h: Canonical link: https://commits.webkit.org/266896@main
- Loading branch information
Showing
7 changed files
with
71 additions
and
7 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
LayoutTests/fast/eventloop/queue-task-event-loop-starvation-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,10 @@ | ||
This tests repeated queueing of event loop tasks. Event loop should eventually yield to the run loop. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS executedTaskCount < 100 is true | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
45 changes: 45 additions & 0 deletions
45
LayoutTests/fast/eventloop/queue-task-event-loop-starvation.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,45 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<script src="../../resources/js-test.js"></script> | ||
<script> | ||
|
||
description('This tests repeated queueing of event loop tasks. Event loop should eventually yield to the run loop.'); | ||
|
||
if (!window.internals) | ||
testFailed('This test relies on window.internals'); | ||
else { | ||
jsTestIsAsync = true; | ||
logs = []; | ||
} | ||
|
||
function slowFunction(duration) | ||
{ | ||
const startTime = performance.now(); | ||
while (performance.now() < startTime + duration); | ||
} | ||
|
||
let executedTaskCount = 0; | ||
function scheduleSlowTask() | ||
{ | ||
internals.queueTask("DOMManipulation", () => { | ||
slowFunction(10); | ||
++executedTaskCount; | ||
}); | ||
} | ||
|
||
function runTest() | ||
{ | ||
setTimeout(() => { | ||
shouldBeTrue('executedTaskCount < 100'); | ||
finishJSTest(); | ||
}, 100); | ||
for (let i = 0; i < 100; ++i) | ||
scheduleSlowTask(); | ||
} | ||
|
||
onload = runTest; | ||
|
||
</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