Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate setTimeout and setInterval with HTML5 event loop #16550

Conversation

rniwa
Copy link
Member

@rniwa rniwa commented Aug 10, 2023

43d0b6d

Integrate setTimeout and setInterval with HTML5 event loop
https://bugs.webkit.org/show_bug.cgi?id=203137

Reviewed by Chris Dumez.

This PR integrates DOM timers with HTML5 event loop. Specifically, DOMTimer now uses
EventLoopTaskGroup::scheduleTask and EventLoopTaskGroup::scheduleRepeatingTask instead of
inheriting from SuspendableTimer. This PR also deletes SuspendableTimer class now that
we've migrated all uses of it to EventLoop's equivalents.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/EventLoop.cpp:
(WebCore::EventLoop::scheduleTask): Fixed a bug that the newly created timer won't be
suspended when the task group had been suspended.
(WebCore::EventLoop::scheduleRepeatingTask): Ditto.
(WebCore::EventLoopTaskGroup::setTimerAlignment):
(WebCore::EventLoopTaskGroup::setTimerHasReachedMaxNestingLevel):
(WebCore::EventLoopTaskGroup::adjustTimerNextTimeout):
(WebCore::EventLoopTaskGroup::adjustTimerRepeatInterval):
(WebCore::EventLoopTaskGroup::didChangeTimerAlignmentInterval):
* Source/WebCore/dom/EventLoop.h:
* Source/WebCore/dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::didChangeTimerAlignmentInterval):
* Source/WebCore/dom/ScriptExecutionContext.h:
* Source/WebCore/dom/TaskSource.h:
* Source/WebCore/page/DOMTimer.cpp:
(WebCore::DOMTimer::DOMTimer):
(WebCore::DOMTimer::removeById):
(WebCore::DOMTimer::fired):
(WebCore::DOMTimer::stop):
(WebCore::DOMTimer::updateTimerIntervalIfNecessary):
(WebCore::DOMTimer::didStop): Deleted.
* Source/WebCore/page/DOMTimer.h:
* Source/WebCore/page/SuspendableTimer.cpp: Removed.
* Source/WebCore/page/SuspendableTimer.h: Removed.
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::isTimerThrottled):

Canonical link: https://commits.webkit.org/266828@main

1839804

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ›  gtk
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ api-gtk
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  tv-sim
βœ… πŸ›  watch
βœ… πŸ›  πŸ§ͺ unsafe-merge βœ… πŸ›  watch-sim

@rniwa rniwa requested a review from cdumez as a code owner August 10, 2023 02:30
@rniwa rniwa self-assigned this Aug 10, 2023
@rniwa rniwa added the DOM For bugs specific to XML/HTML DOM elements (including parsing). label Aug 10, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from a285599 to 9cd4de7 Compare August 10, 2023 02:59
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from 9cd4de7 to 2f33bb5 Compare August 10, 2023 05:04
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from 2f33bb5 to 264f495 Compare August 10, 2023 05:43
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from 264f495 to 9727782 Compare August 10, 2023 07:50
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from 9727782 to dec5a4a Compare August 10, 2023 07:56
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa removed the merging-blocked Applied to prevent a change from being merged label Aug 10, 2023
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from dec5a4a to 45987aa Compare August 10, 2023 18:18
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from 45987aa to 88109a8 Compare August 11, 2023 00:25
@rniwa rniwa force-pushed the fix203137-dom-timer-event-loop-integration branch from 88109a8 to 1839804 Compare August 11, 2023 03:53
Copy link
Contributor

@cdumez cdumez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rniwa rniwa added the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 11, 2023
https://bugs.webkit.org/show_bug.cgi?id=203137

Reviewed by Chris Dumez.

This PR integrates DOM timers with HTML5 event loop. Specifically, DOMTimer now uses
EventLoopTaskGroup::scheduleTask and EventLoopTaskGroup::scheduleRepeatingTask instead of
inheriting from SuspendableTimer. This PR also deletes SuspendableTimer class now that
we've migrated all uses of it to EventLoop's equivalents.

* Source/WebCore/Headers.cmake:
* Source/WebCore/Sources.txt:
* Source/WebCore/WebCore.xcodeproj/project.pbxproj:
* Source/WebCore/dom/EventLoop.cpp:
(WebCore::EventLoop::scheduleTask): Fixed a bug that the newly created timer won't be
suspended when the task group had been suspended.
(WebCore::EventLoop::scheduleRepeatingTask): Ditto.
(WebCore::EventLoopTaskGroup::setTimerAlignment):
(WebCore::EventLoopTaskGroup::setTimerHasReachedMaxNestingLevel):
(WebCore::EventLoopTaskGroup::adjustTimerNextTimeout):
(WebCore::EventLoopTaskGroup::adjustTimerRepeatInterval):
(WebCore::EventLoopTaskGroup::didChangeTimerAlignmentInterval):
* Source/WebCore/dom/EventLoop.h:
* Source/WebCore/dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::didChangeTimerAlignmentInterval):
* Source/WebCore/dom/ScriptExecutionContext.h:
* Source/WebCore/dom/TaskSource.h:
* Source/WebCore/page/DOMTimer.cpp:
(WebCore::DOMTimer::DOMTimer):
(WebCore::DOMTimer::removeById):
(WebCore::DOMTimer::fired):
(WebCore::DOMTimer::stop):
(WebCore::DOMTimer::updateTimerIntervalIfNecessary):
(WebCore::DOMTimer::didStop): Deleted.
* Source/WebCore/page/DOMTimer.h:
* Source/WebCore/page/SuspendableTimer.cpp: Removed.
* Source/WebCore/page/SuspendableTimer.h: Removed.
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::isTimerThrottled):

Canonical link: https://commits.webkit.org/266828@main
@webkit-commit-queue webkit-commit-queue force-pushed the fix203137-dom-timer-event-loop-integration branch from 1839804 to 43d0b6d Compare August 11, 2023 20:27
@webkit-commit-queue
Copy link
Collaborator

Committed 266828@main (43d0b6d): https://commits.webkit.org/266828@main

Reviewed commits have been landed. Closing PR #16550 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 43d0b6d into WebKit:main Aug 11, 2023
@webkit-commit-queue webkit-commit-queue removed the unsafe-merge-queue Applied to send a pull request to merge-queue, but skip building and testing label Aug 11, 2023
@rniwa rniwa deleted the fix203137-dom-timer-event-loop-integration branch August 11, 2023 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DOM For bugs specific to XML/HTML DOM elements (including parsing).
Projects
None yet
6 participants