LibWeb: Do not spin the event loop awaiting text track state changes

The text track processing model would previously spin forever waiting
for the track URL to change. It would then recursively invoke itself
to handle the new URL, again entering the spin loop. This meant that
tracks could easily cause event loop hangs.

We now have an observer system to be notified when the track state
changes instead. This lets us exit the processing model and move on.
This commit is contained in:
Timothy Flynn
2025-06-12 08:51:45 -04:00
committed by Tim Flynn
parent 24ac860998
commit de34143a4e
Notes: github-actions[bot] 2025-06-12 16:26:50 +00:00
11 changed files with 182 additions and 17 deletions

View File

@@ -7,8 +7,8 @@
#pragma once
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/HTMLElement.h>
#include <LibWeb/HTML/TextTrack.h>
namespace Web::HTML {
@@ -33,8 +33,9 @@ private:
void set_track_url(String);
void start_the_track_processing_model();
void start_the_track_processing_model_parallel_steps(JS::Realm& realm);
void start_the_track_processing_model_parallel_steps();
void track_became_ready();
void track_failed_to_load();
// ^DOM::Element
@@ -42,6 +43,7 @@ private:
virtual void inserted() override;
GC::Ptr<TextTrack> m_track;
GC::Ptr<TextTrackObserver> m_track_observer;
// https://html.spec.whatwg.org/multipage/media.html#track-url
String m_track_url {};
@@ -50,6 +52,7 @@ private:
GC::Ptr<Fetch::Infrastructure::FetchController> m_fetch_controller;
bool m_loading { false };
bool m_awaiting_track_url_change { false };
};
}