New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dom: Abort media element load on decode errors #31748
Conversation
Signed-off-by: Frederik Reiter <hi@frereit.de>
I think these changes do change behavior, though perhaps they are hard to test for other reasons. I wonder if there is a way to write a test for this though. |
🔨 Triggering try run (#8334593698) for Linux WPT |
Test results for linux-wpt-layout-2013 from try job (#8334593698): Flaky unexpected result (20)
Stable unexpected results that are known to be intermittent (11)
|
Test results for linux-wpt-layout-2020 from try job (#8334593698): Flaky unexpected result (22)
Stable unexpected results that are known to be intermittent (16)
|
✨ Try run (#8334593698) succeeded. |
I just spent some time looking into how to test is. Unfortunately it seems pretty difficult to test servo/tests/wpt/tests/media-source/mediasource-errors.html Lines 124 to 131 in d6d903c
I tried around with creating an MP4 / webm that triggers a
Edit: I experimented around some more and managed to create a completely empty MP4 file (i.e. valid, but contains no video or audio streams): empty.mp4Reading the file with ffmpeg gives no errors but also shows that it doesn't contain any streams: $ ffprobe -i empty.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Mpeg4.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
Duration: N/A, bitrate: N/A So this file is a valid MP4. However, both firefox and chromium still only raise a "MEDIA_ERR_SRC_NOT_SUPPORTED". Firefox even says that "Media resource [...] could not be decoded" but does not raise a "MEDIA_ERR_DECODE" (??). Servo also doesn't raise a "MEDIA_ERR_DECODE". As a matter of fact, in Chromium, a MEDIA_ERR_DECODE is only raised during a It seems to me like MEDIA_ERR_DECODE is only raised very exceptional cases, which makes testing this very hard until the Media Source API is available. Would it be acceptable to only add a comment that states that a test can only be written when the Media Source API is available? |
|
||
// TODO: 6. Abort the overall resource selection algorithm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is not required here / we can skip this step. There is a similar error path in HTMLMediaElementFetchListener
that is also supposed to "Abort the overall resource selection algorithm" and it is skipped there too:
servo/components/script/dom/htmlmediaelement.rs
Lines 2813 to 2833 in 06a021d
// => "If the connection is interrupted after some media data has been received..." | |
else if elem.ready_state.get() != ReadyState::HaveNothing { | |
// Step 1 | |
if let Some(ref mut current_fetch_context) = *elem.current_fetch_context.borrow_mut() { | |
current_fetch_context.cancel(CancelReason::Error); | |
} | |
// Step 2 | |
elem.error.set(Some(&*MediaError::new( | |
&*window_from_node(&*elem), | |
MEDIA_ERR_NETWORK, | |
))); | |
// Step 3 | |
elem.network_state.set(NetworkState::Idle); | |
// Step 4. | |
elem.delay_load_event(false); | |
// Step 5 | |
elem.upcast::<EventTarget>().fire_event(atom!("error")); |
// TODO: 6. Abort the overall resource selection algorithm. |
This makes sense to me and the code change is pretty straight-forward. I've updated the PR description to say this. |
Signed-off-by: Frederik Reiter <hi@frereit.de>
Signed-off-by: Frederik Reiter <hi@frereit.de>
Previously, when a
PlayerEvent::Error
was encountered, anerror
Event was fired on the element, but the "delaying-the-load-event" flag was never set to false, so the document was loading until the end of the media source was received inprocess_response_eof
:servo/components/script/dom/htmlmediaelement.rs
Line 2811 in d6d903c
I think the issue was that the
PlayerEvent::Error
was not handled according to spec. I believe the relevant portion is "The media data processing steps list is as follows: ... If the media is corrupted".I've implemented most of the steps but am unsure about "6. Abort the overall resource selection algorithm." Is this even applicable here, or is it "automatically" aborted by cancelling the fetch event?
With this patch, the
LoadComplete
event is triggered immediately after a media decode error:./mach build -d
does not report any errors./mach test-tidy
does not report any errors