-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Compositor+Others: Fix a flake in HTMLVideoElement-resize-event-during-playback.html #11103
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
base: master
Are you sure you want to change the base?
Changes from all commits
2ebab49
0385837
7d9d90e
f03a966
a51b7bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -149,9 +149,19 @@ void CompositorState::update_display_list(Web::Compositor::CompositorContextId c | |||||||||||||||||||||||||||||||||
| context->apply_display_list_resource_transaction(move(resource_transaction)); | ||||||||||||||||||||||||||||||||||
| context->install_display_list_update(move(display_list), move(visual_context_tree), move(scroll_state_snapshot)); | ||||||||||||||||||||||||||||||||||
| resolve_video_sinks(*context); | ||||||||||||||||||||||||||||||||||
| note_display_list_installed_for_video_sinks(context->web_content_client()); | ||||||||||||||||||||||||||||||||||
| update_video_sink_ticking_states(); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| void CompositorState::note_display_list_installed_for_video_sinks(CompositorStateWebContentClient& client) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| auto client_sinks = m_video_sink_states.get(&client); | ||||||||||||||||||||||||||||||||||
| if (!client_sinks.has_value()) | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| for (auto& sink_entry : *client_sinks) | ||||||||||||||||||||||||||||||||||
| sink_entry.value.display_list_installed_since_registration = true; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+156
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Track display-list installation per context sink. This helper marks every sink owned by Pass Proposed fix-void note_display_list_installed_for_video_sinks(CompositorStateWebContentClient&);
+void note_display_list_installed_for_video_sinks(ContextState const&);- note_display_list_installed_for_video_sinks(context->web_content_client());
+ note_display_list_installed_for_video_sinks(*context);-void CompositorState::note_display_list_installed_for_video_sinks(CompositorStateWebContentClient& client)
+void CompositorState::note_display_list_installed_for_video_sinks(ContextState const& context)
{
- auto client_sinks = m_video_sink_states.get(&client);
- if (!client_sinks.has_value())
- return;
- for (auto& sink_entry : *client_sinks)
- sink_entry.value.display_list_installed_since_registration = true;
+ auto& client = context.web_content_client();
+ for (auto const& resource_entry : context.video_sink_handles()) {
+ if (auto* sink_state = video_sink_state(client, resource_entry.value))
+ sink_state->display_list_installed_since_registration = true;
+ }
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| void CompositorState::update_image_frame_resources(Web::Compositor::CompositorContextId context_id, Vector<Web::Painting::DisplayListImageFrameResource> image_frames) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| auto* context = context_if_present(context_id); | ||||||||||||||||||||||||||||||||||
|
|
@@ -222,6 +232,15 @@ bool CompositorState::video_sink_updates_are_admitted(VideoSinkState const& sink | |||||||||||||||||||||||||||||||||
| return has_flag(sink_state.update_flags, Web::Compositor::VideoUpdateFlags::Visible) && painted; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| bool CompositorState::video_sink_ticking_state_is_determined(VideoSinkState const& sink_state, bool client_can_paint) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| if (!has_flag(sink_state.update_flags, Web::Compositor::VideoUpdateFlags::Visible)) | ||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| if (!client_can_paint) | ||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||
| return sink_state.sink != nullptr && sink_state.display_list_installed_since_registration; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| void CompositorState::on_video_sink_ready(CompositorStateWebContentClient& client, Media::VideoSinkHandle handle, NonnullRefPtr<Media::DisplayingVideoSink> const& sink) | ||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||
| auto* sink_state = video_sink_state(client, handle); | ||||||||||||||||||||||||||||||||||
|
|
@@ -250,6 +269,10 @@ void CompositorState::update_video_sink_ticking_states() | |||||||||||||||||||||||||||||||||
| auto is_painted = client_painted.has_value() && client_painted->contains(sink_entry.key); | ||||||||||||||||||||||||||||||||||
| auto ticking = video_sink_updates_are_admitted(sink_state, is_painted); | ||||||||||||||||||||||||||||||||||
| any_unpainted_sink_admits_updates |= ticking && !is_painted; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if (!video_sink_ticking_state_is_determined(sink_state, client_painted.has_value())) | ||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if (ticking == sink_state.ticking) | ||||||||||||||||||||||||||||||||||
| continue; | ||||||||||||||||||||||||||||||||||
| sink_state.ticking = ticking; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| presented after reattachment: 640x480 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <!DOCTYPE html> | ||
| <script src="../include.js"></script> | ||
| <video id="video"></video> | ||
| <script> | ||
| // Moving a video element into a document that is not fully active releases its video sink, since an inactive | ||
| // document has no compositor context to present through. Moving it back must rebuild the sink, otherwise the | ||
| // element would never present another frame. | ||
| const video = document.getElementById("video"); | ||
|
|
||
| asyncTest(async done => { | ||
| video.src = "../../../Assets/resize-320x240-640x480.webm"; | ||
| await new Promise(resolve => video.addEventListener("loadedmetadata", resolve, { once: true })); | ||
|
|
||
| const inactiveDocument = new DOMParser().parseFromString("<body></body>", "text/html"); | ||
| inactiveDocument.body.appendChild(video); | ||
| document.body.appendChild(video); | ||
|
|
||
| // The mid-stream resize is only reported once a frame has been presented through the rebuilt sink. | ||
| const sawResize = new Promise(resolve => video.addEventListener("resize", resolve, { once: true })); | ||
| await video.play(); | ||
| await new Promise(resolve => video.addEventListener("ended", resolve, { once: true })); | ||
| await sawResize; | ||
|
|
||
| println(`presented after reattachment: ${video.videoWidth}x${video.videoHeight}`); | ||
| done(); | ||
| }); | ||
| </script> |
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.
This rename doesn't seem to match the commit title