Compositor+Others: Fix a flake in HTMLVideoElement-resize-event-during-playback.html - #11103
Compositor+Others: Fix a flake in HTMLVideoElement-resize-event-during-playback.html#11103Zaggy1024 wants to merge 5 commits into
Conversation
While a sink is still being resolved, or a display list containing the sink is still being produced, we can't know whether it will actually be ticked when it is ready for display. If we update the remote ticking flag to false during that window, we may fall back from the pipeline- based playback ending trigger and lose some resize events. HTMLVideoElement-resize-event-during-playback.html could flake due to contention of the Compositor process during a full test run, since the sink being resolved was getting delayed.
If a video track's edge is detached, then that track's sink resolved again, the detachment could race and destroy the resolving sink. Ensure that the sink being detached is the one that the caller wants to detach.
This can be used for more than a lost connection.
This reduces memory consumption and frees some of Compositor's fds to avoid hitting its limit. Fixes crashes when running video tests for more than about 15k repetitions.
Compositor deals in quite a few fds, and we shouldn't crash it when one client is sending too many fds.
📝 WalkthroughWalkthroughThe change adds error handling for Mach file-port conversion and updates malformed IPC disconnect logging. It renames video sink detachment APIs and passes the released sink during video edge cleanup. Sequence Diagram(s)sequenceDiagram
participant HTMLMediaElement
participant PlaybackManager
participant CompositorState
HTMLMediaElement->>PlaybackManager: Detach video sink edge
HTMLMediaElement->>PlaybackManager: Re-add current video sink
CompositorState->>CompositorState: Record display-list installation
CompositorState->>PlaybackManager: Update video sink ticking state
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Services/Compositor/CompositorState.cpp`:
- Around line 156-163: Update
CompositorState::note_display_list_installed_for_video_sinks to accept the
relevant ContextState and mark only sink handles returned by
context.video_sink_handles(), rather than every sink owned by the client. Update
its declaration and the call site around the existing display-list installation
flow to pass the ContextState.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e4c220ad-0c37-4ef7-bbf0-937fb8cf41af
📒 Files selected for processing (12)
Libraries/LibIPC/AttachmentMachPort.cppLibraries/LibIPC/Connection.cppLibraries/LibMedia/PlaybackManager.cppLibraries/LibMedia/PlaybackManager.hLibraries/LibMedia/VideoPresentation/VideoPresentationServerConnection.cppLibraries/LibWeb/HTML/HTMLMediaElement.cppLibraries/LibWeb/HTML/HTMLMediaElement.hLibraries/LibWeb/Page/Page.cppServices/Compositor/CompositorState.cppServices/Compositor/CompositorState.hTests/LibWeb/Text/expected/HTML/HTMLVideoElement-sink-reattached-after-inactive-document.txtTests/LibWeb/Text/input/HTML/HTMLVideoElement-sink-reattached-after-inactive-document.html
| 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; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Track display-list installation per context sink.
This helper marks every sink owned by client after any one context installs a display list. If the client owns multiple contexts, an unrelated display-list update can satisfy readiness for a visible sink that its own context has not displayed yet. update_video_sink_ticking_states() can then untick that sink before its first presentation.
Pass ContextState to this helper. Mark only handles in context.video_sink_handles(). Update the declaration and the call at Line 152.
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
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 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; | |
| } | |
| void CompositorState::note_display_list_installed_for_video_sinks(ContextState const& context) | |
| { | |
| 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; | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@Services/Compositor/CompositorState.cpp` around lines 156 - 163, Update
CompositorState::note_display_list_installed_for_video_sinks to accept the
relevant ContextState and mark only sink handles returned by
context.video_sink_handles(), rather than every sink owned by the client. Update
its declaration and the call site around the existing display-list installation
flow to pass the ContextState.
| } | ||
|
|
||
| void PlaybackManager::detach_lost_video_sink(VideoSinkHandle handle) | ||
| void PlaybackManager::detach_video_sink(VideoSinkHandle handle) |
There was a problem hiding this comment.
This rename doesn't seem to match the commit title
The first commit fixes the flake, and the rest are improvements to prevent repeated video tests from crashing the content processes.