libservo: Move GL acclerated media setup out of RenderingContext and simplify it (#35553)

This moves the GL accelerated media setup out of `RenderingContext`
which prevents making libservo dependo on the Wayland and X11 versions
of surfman explicitly. This support is experimental and (honestly) a bit
broken. I've confirmed that this works as well as it did before the
change.

The main thing here is that the configuration, which currently needs
surfman types, moves to servoshell. In addition:

1. Instead of passing the information to the Constellation, the setup is
   stored statically. This is necessary to avoid introducing a
   dependency on `media` in `webrender_traits`. It's quite likely that
   `media` types should move to the internal embedding API to avoid
   this. This is preserved for a followup change.
2. The whole system of wrapping the media channels in an abstract type
   is removed. They could be either mpsc channels or IPC channels. This
   was never going to work because mpsc channels cannot be serialized
   and deserialized with serde. Instead this just uses IPC channels. We
   also have other ways of doing this kind of abstraction in Servo so we
   do not need another. The `mpsc` version was hard-coded to be
   disabled.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-20 14:52:18 +01:00 committed by GitHub
parent 9887ad369d
commit 5465bfc2af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 226 additions and 469 deletions

View file

@ -131,7 +131,7 @@ use ipc_channel::router::ROUTER;
use ipc_channel::Error as IpcError;
use keyboard_types::webdriver::Event as WebDriverInputEvent;
use log::{debug, error, info, trace, warn};
use media::{GLPlayerThreads, WindowGLContext};
use media::WindowGLContext;
use net_traits::pub_domains::reg_host;
use net_traits::request::Referrer;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
@ -465,12 +465,6 @@ pub struct Constellation<STF, SWF> {
/// If True, exits on thread failure instead of displaying about:failure
hard_fail: bool,
/// Entry point to create and get channels to a GLPlayerThread.
glplayer_threads: Option<GLPlayerThreads>,
/// Application window's GL Context for Media player
player_context: WindowGLContext,
/// Pipeline ID of the active media session.
active_media_session: Option<PipelineId>,
@ -528,11 +522,6 @@ pub struct InitialConstellationState {
/// The XR device registry
pub webxr_registry: Option<webxr_api::Registry>,
pub glplayer_threads: Option<GLPlayerThreads>,
/// Application window's GL Context for Media player
pub player_context: WindowGLContext,
/// User agent string to report in network requests.
pub user_agent: Cow<'static, str>,
@ -759,8 +748,6 @@ where
pending_approval_navigations: HashMap::new(),
pressed_mouse_buttons: 0,
hard_fail,
glplayer_threads: state.glplayer_threads,
player_context: state.player_context,
active_media_session: None,
user_agent: state.user_agent,
rippy_data,
@ -1011,7 +998,7 @@ where
.as_ref()
.map(|threads| threads.pipeline()),
webxr_registry: self.webxr_registry.clone(),
player_context: self.player_context.clone(),
player_context: WindowGLContext::get(),
user_agent: self.user_agent.clone(),
rippy_data: self.rippy_data.clone(),
});
@ -2690,11 +2677,7 @@ where
}
debug!("Exiting GLPlayer thread.");
if let Some(glplayer_threads) = self.glplayer_threads.as_ref() {
if let Err(e) = glplayer_threads.exit() {
warn!("Exit GLPlayer Thread failed ({})", e);
}
}
WindowGLContext::get().exit();
debug!("Exiting the system font service thread.");
self.system_font_service.exit();