From fd63ffb8c3bd9336e204f481698e978a33b76949 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Mon, 11 Mar 2024 03:58:47 +0100 Subject: [PATCH] LibWeb: Use Core::Timer instead for animation driver timer Platform::Timer uses JS::SafeFunction that prevents document from ever being deallocated because of strong reference. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 4 ++-- Userland/Libraries/LibWeb/DOM/Document.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index 2aad5211d6..7840445726 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -4023,7 +4023,7 @@ void Document::ensure_animation_timer() { constexpr static auto timer_delay_ms = 1000 / 60; if (!m_animation_driver_timer) { - m_animation_driver_timer = Platform::Timer::create_repeating(timer_delay_ms, [this] { + m_animation_driver_timer = MUST(Core::Timer::create_repeating(timer_delay_ms, [this] { bool has_animations = false; for (auto& timeline : m_associated_animation_timelines) { if (!timeline->associated_animations().is_empty()) { @@ -4042,7 +4042,7 @@ void Document::ensure_animation_timer() for (auto& animation : timeline->associated_animations()) dispatch_events_for_animation_if_necessary(animation); } - }); + })); } m_animation_driver_timer->start(); diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index d6c62b7b2a..fbae8afca4 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -828,7 +828,7 @@ private: // https://www.w3.org/TR/web-animations-1/#pending-animation-event-queue Vector m_pending_animation_event_queue; - RefPtr m_animation_driver_timer; + RefPtr m_animation_driver_timer; bool m_needs_to_call_page_did_load { false };