From 49557c2e128e01f757092dfd4dd63e7dfacff86c Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sun, 28 Jun 2026 21:37:10 -0400 Subject: [PATCH] Ladybird+MacVideoPlayer: Align post_event with other event loop impls After cherry-picking ladybird deferred invoke changes, the macOS event loop implementations' post_event have diverged from everyone else's. It tries to post the 'deferred invoke' event, but after all the changes to how deferred invoke is dispatched, deferred invoke will never go through post_event. Restore the previous "wake if not my thread" behavior, and clean up the unused atomic variable. --- Ladybird/AppKit/Application/EventLoopImplementation.mm | 7 ++----- .../Contrib/MacVideoPlayer/EventLoopImplementation.mm | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/Ladybird/AppKit/Application/EventLoopImplementation.mm b/Ladybird/AppKit/Application/EventLoopImplementation.mm index 0fd61e07b03..04b9cd4cb9b 100644 --- a/Ladybird/AppKit/Application/EventLoopImplementation.mm +++ b/Ladybird/AppKit/Application/EventLoopImplementation.mm @@ -210,7 +210,6 @@ struct CFEventLoopImplementation::Impl { context.info = &event_loop_implementation; context.perform = [](void* info) { auto& self = *static_cast(info); - self.m_impl->deferred_source_pending = false; self.m_thread_event_queue.process(); }; @@ -226,7 +225,6 @@ struct CFEventLoopImplementation::Impl { CFRunLoopRef run_loop { nullptr }; CFRunLoopSourceRef deferred_source { nullptr }; - Atomic deferred_source_pending { false }; }; CFEventLoopImplementation::CFEventLoopImplementation() @@ -450,9 +448,8 @@ void CFEventLoopImplementation::post_event(Core::EventReceiver* receiver, Nonnul { m_thread_event_queue.post_event(receiver, move(event)); - bool expected = false; - if (m_impl->deferred_source && m_impl->deferred_source_pending.compare_exchange_strong(expected, true)) - CFRunLoopSourceSignal(m_impl->deferred_source); + if (&m_thread_event_queue != &Core::ThreadEventQueue::current()) + wake(); } } diff --git a/Meta/Lagom/Contrib/MacVideoPlayer/EventLoopImplementation.mm b/Meta/Lagom/Contrib/MacVideoPlayer/EventLoopImplementation.mm index d8cef700deb..c9e491f7a2e 100644 --- a/Meta/Lagom/Contrib/MacVideoPlayer/EventLoopImplementation.mm +++ b/Meta/Lagom/Contrib/MacVideoPlayer/EventLoopImplementation.mm @@ -211,7 +211,6 @@ struct CFEventLoopImplementation::Impl { context.info = &event_loop_implementation; context.perform = [](void* info) { auto& self = *static_cast(info); - self.m_impl->deferred_source_pending = false; self.m_thread_event_queue.process(); }; @@ -227,7 +226,6 @@ struct CFEventLoopImplementation::Impl { CFRunLoopRef run_loop { nullptr }; CFRunLoopSourceRef deferred_source { nullptr }; - Atomic deferred_source_pending { false }; }; CFEventLoopImplementation::CFEventLoopImplementation() @@ -451,9 +449,8 @@ void CFEventLoopImplementation::post_event(Core::EventReceiver* receiver, Nonnul { m_thread_event_queue.post_event(receiver, move(event)); - bool expected = false; - if (m_impl->deferred_source && m_impl->deferred_source_pending.compare_exchange_strong(expected, true)) - CFRunLoopSourceSignal(m_impl->deferred_source); + if (&m_thread_event_queue != &Core::ThreadEventQueue::current()) + wake(); } }