From af2ac67be379c7c26f1fc445c2f62f4b29d6638c Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Fri, 13 Feb 2026 13:09:48 -0600 Subject: [PATCH] LibMedia: Don't lock the main loop while initializing a media source We only need to take a strong reference to the main event loop when an error occurred in order to invoke the callback on the main thread. By taking this lock for the entire duration of the thread, we were preventing the main thread from exiting if the init thread hangs. --- Libraries/LibMedia/PlaybackManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibMedia/PlaybackManager.cpp b/Libraries/LibMedia/PlaybackManager.cpp index a468655101..6e47669d98 100644 --- a/Libraries/LibMedia/PlaybackManager.cpp +++ b/Libraries/LibMedia/PlaybackManager.cpp @@ -135,9 +135,9 @@ PlaybackManager::~PlaybackManager() void PlaybackManager::add_media_source(NonnullRefPtr const& stream) { auto thread = Threading::Thread::construct("Media Init"sv, [playback_manager = NonnullRefPtr { *this }, stream = stream, main_thread_event_loop_reference = Core::EventLoop::current_weak()] -> int { - auto main_thread_event_loop = main_thread_event_loop_reference->take(); auto maybe_error = playback_manager->prepare_playback_from_media_data(stream, main_thread_event_loop_reference); if (maybe_error.is_error()) { + auto main_thread_event_loop = main_thread_event_loop_reference->take(); main_thread_event_loop->deferred_invoke([playback_manager, error = maybe_error.release_error()] mutable { if (playback_manager->on_unsupported_format_error) playback_manager->on_unsupported_format_error(move(error));