1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:25:08 +00:00

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).
This commit is contained in:
Timothy Flynn 2023-04-19 09:20:48 -04:00 committed by Andreas Kling
parent 8d4d01d99a
commit d2f9645cc0

View file

@ -314,7 +314,7 @@ WebIDL::ExceptionOr<void> 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<void> HTMLMediaElement::process_media_data(Function<void()>
// -> 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();