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
Media player errors can prevent documents from reaching DocumentReadyState::Complete for a long time #31688
Comments
Whether a page is considered complete is affected by the presence of outstanding network fetches for resources, as well as LoadBlocker objects that are attached to the document. For media elements, there is a load blocker defined in |
I'd like to give this a shot and see how far I can get |
Hm, so I wrote a one-line patch that fixes this: diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index e9de8cb20d5b..4388b30af7c6 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -1556,6 +1556,7 @@ impl HTMLMediaElement {
MEDIA_ERR_DECODE,
)));
self.upcast::<EventTarget>().fire_event(atom!("error"));
+ self.queue_dedicated_media_source_failure_steps();
},
PlayerEvent::VideoFrameUpdated => {
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage); I'd now like to add a test for this but I'm struggling. I think it should be a new unit test but the other unit tests only test very basic functionality of the components. I think I'd have to write a new unit test that initalized a |
One note: the dedicated failure steps already fire an error event ( servo/components/script/dom/htmlmediaelement.rs Line 1033 in 8cfc6a1
In general, we don't do a lot of unit testing in the script crate. Part of it is for the reasons you identified (lots of boilerplate, and the code structure is written to reflect the specifications), and partly because we usually care about the overall conformance to the web standards instead. Instead, we use integration tests like https://github.com/servo/servo/tree/main/tests/wpt/tests/html/semantics/embedded-content/the-video-element which verify that pages finish loading, fire expected events, display certain content, etc. https://github.com/servo/servo/blob/main/tests/wpt/tests/html/semantics/embedded-content/media-elements/error-codes/error.html#L23 suggests that there may not be any tests for decoding errors right now, but shows a model for how to write tests that verify the behavior. |
See https://github.com/servo/servo/blob/main/tests/wpt/README.md for more information about how to makes use of this test suite. |
Ah, got it! servo/components/script/dom/htmlmediaelement.rs Lines 817 to 819 in 8cfc6a1
servo/components/script/dom/htmlmediaelement.rs Lines 825 to 827 in 8cfc6a1
Thanks! I'll try to create
thanks for your help |
Okay, sorry for all this back and forth / spam, but I actually cannot reproduce the issue as described: [nix-shell:~/Source/servo]$ git rev-parse HEAD
8cfc6a1898d02eb1df9c13c3c410747cb1e0b412
[nix-shell:~/Source/servo]$ RUST_LOG='warn,servoshell<servo@LoadStart,servoshell<servo@HeadParsed,servoshell<servo@LoadComplete,script::dom::document' ./mach run -d 'data:text/html,<video autoplay src="https://video.fosdem.org/2024/h1308/fosdem-2024-2321-embedding-servo-in-rust-projects.av1.webm">'
[...]
[2024-03-16T22:07:19Z ERROR script::dom::htmlmediaelement] Player error: "Error from element /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: Your GStreamer installation is missing a plug-in.\nYour GStreamer installation is missing a plug-in.\n../gst/playback/gsturidecodebin.c(1049): no_more_pads_full (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0:\nno suitable plugins found:\n../gst/playback/gstdecodebin2.c(4704): gst_decode_bin_expose (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstDecodeBin:decodebin0:\nno suitable plugins found:\nMissing decoder: WebM (video/webm)\n"
[2024-03-16T22:07:40Z DEBUG script::dom::document] Document got finish_load: Media
[2024-03-16T22:07:40Z DEBUG script::dom::document] Document loads are complete.
[2024-03-16T22:07:40Z DEBUG script::dom::document] About to dispatch load for "data:text/html,<video autoplay src=\"http... (f8a72f128b37adab)"
[2024-03-16T22:07:40Z TRACE servoshell<servo@LoadComplete] TopLevelBrowsingContext(0,1) LoadComplete Note how it just takes ~20s for the Document to reach @delan: Could you please validate that the document actually never reaches This would also mean that this issue isn't actually a blocker of #31689? I mean sure, it's not great that the spinner would stay on screen longer than neccessary but I don't see how it's a blocker. |
Out of curiosity, do we reach the complete state sooner with your changes? |
Thanks for investigating. Indeed the test case does finish loading for me, though it takes over six minutes!
|
Yes. With the new changes (#31748) the LoadComplete event fires instantly when a Player Error occurs. |
@servo-highfive assign me |
Hey @frereit! Thanks for your interest in working on this issue. It's now assigned to you! |
To reproduce:
RUST_LOG='warn,servoshell<servo@LoadStart,servoshell<servo@HeadParsed,servoshell<servo@LoadComplete,script::dom::document' ./mach run -d 'data:text/html,<video autoplay src="https://video.fosdem.org/2024/h1308/fosdem-2024-2321-embedding-servo-in-rust-projects.av1.webm">'
Output when installed:
Output when uninstalled:
The text was updated successfully, but these errors were encountered: