From d2f9645cc00be122625298a7d7ddbb36bb5ba3aa Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 19 Apr 2023 09:20:48 -0400 Subject: [PATCH] LibWeb: Properly stop, rather than terminate, ongoing media fetches We are currently using the fetch controller's terminate() method to stop ongoing fetches when the HTMLMediaElement load algorithm is invoked. This method ultimately causes the fetch response to be a network error, which we propagate through the HTMLMediaElement's error event. This can cause websites, such as Steam, to avoid attempting to play any video. The spec does not actually specify what it means to "stop" or "cancel" a fetching process. But we should not use terminate() as that is a defined spec method, and the spec does tend to indicate when that method should be used (e.g. as it does in XMLHttpRequest). --- Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp index 5f7018f68a..e8b878f4c8 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp @@ -314,7 +314,7 @@ WebIDL::ExceptionOr HTMLMediaElement::load_element() // 2. If a fetching process is in progress for the media element, the user agent should stop it. if (m_fetch_controller && m_fetch_controller->state() == Fetch::Infrastructure::FetchController::State::Ongoing) - m_fetch_controller->terminate(); + m_fetch_controller->stop_fetch(); // FIXME: 3. If the media element's assigned media provider object is a MediaSource object, then detach it. // FIXME: 4. Forget the media element's media-resource-specific tracks. @@ -728,7 +728,7 @@ WebIDL::ExceptionOr HTMLMediaElement::process_media_data(Function // -> If the media data can be fetched but is found by inspection to be in an unsupported format, or can otherwise not be rendered at all if (playback_manager.is_error()) { // 1. The user agent should cancel the fetching process. - m_fetch_controller->terminate(); + m_fetch_controller->stop_fetch(); // 2. Abort this subalgorithm, returning to the resource selection algorithm. failure_callback();