Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 7f4e98d321b787aa4d4ebe2600cbd63c25ea6454
      
https://github.com/WebKit/WebKit/commit/7f4e98d321b787aa4d4ebe2600cbd63c25ea6454
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-10-08 (Thu, 08 Oct 2026)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/lint.ignore
    A 
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-after-removed-frame-with-pending-timeout-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-after-removed-frame-with-pending-timeout.html
    M Source/WebCore/dom/EventLoop.cpp

  Log Message:
  -----------
  requestIdleCallback callbacks stop running after removing a same-origin 
iframe that had a pending setTimeout
https://bugs.webkit.org/show_bug.cgi?id=326641
rdar://189379748

Reviewed by Ryosuke Niwa.

This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.

EventLoopTaskGroup::markAsReadyToStop() stops the group's timers, which clears 
each
timer's task. Once that happens, EventLoopTimer::group() returns null, so when 
the
owner later drops its EventLoopTimerHandle, the handle's destructor never calls
removeScheduledTimer(). That call is the only thing that clears
EventLoop::m_nextTimerFireTimeCache. The timer is destroyed and quietly drops 
out of
the event loop's weak timer sets, but the cache keeps its old fire time.

Same-origin frames share a WindowEventLoop. When an iframe with a pending 
setTimeout
is removed, the parent's event loop keeps reporting the dead timer's fire time. 
After
that time passes, WindowEventLoop::opportunisticallyRunIdleCallbacks() always 
sees
work due immediately, so it keeps re-arming the idle timer and never starts an 
idle
period. Idle callbacks without a timeout never run until some other timer is
scheduled in that event loop.

Also, EventLoop::nextTimerFireTime() did not skip stopped timers. A stopped 
TimerBase
reports a fire time of 0, so any stopped timer that was still referenced made 
it look
as if timer work was already overdue.

Fix both: clear the fire-time cache after markAsReadyToStop() stops the group's
timers, and ignore inactive timers when computing the next fire time.

Test: 
imported/w3c/web-platform-tests/requestidlecallback/callback-after-removed-frame-with-pending-timeout.html

* 
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-after-removed-frame-with-pending-timeout-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-after-removed-frame-with-pending-timeout.html:
 Added.
* LayoutTests/imported/w3c/web-platform-tests/lint.ignore:
* Source/WebCore/dom/EventLoop.cpp:
(WebCore::EventLoop::nextTimerFireTime const):
(WebCore::EventLoopTaskGroup::markAsReadyToStop):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to