canvas: Port CanvasMsg channel to generic channel (#39348)

Additionally also improve the warning message if the routed receiver
disconnects and exit the thread.
If the routed receiver disconnects, we can't receive any canvas messages
anymore, and any control messages can't remedy that, so we might as well
exit.

Testing: Channel changes are covered by existing tests. Exiting the
canvas thread if the routed thread disconnects is not tested, and needs
reviewer attention.
Part of https://github.com/servo/servo/issues/38912

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2025-09-18 08:06:08 +08:00 committed by GitHub
parent 76645e5e26
commit 666b17a9a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 18 deletions

View file

@ -451,7 +451,7 @@ pub struct Constellation<STF, SWF> {
webxr_registry: Option<webxr_api::Registry>,
/// Lazily initialized channels for canvas paint thread.
canvas: OnceCell<(Sender<ConstellationCanvasMsg>, IpcSender<CanvasMsg>)>,
canvas: OnceCell<(Sender<ConstellationCanvasMsg>, GenericSender<CanvasMsg>)>,
/// Navigation requests from script awaiting approval from the embedder.
pending_approval_navigations: PendingApprovalNavigations,
@ -4495,7 +4495,7 @@ where
fn handle_create_canvas_paint_thread_msg(
&mut self,
size: UntypedSize2D<u64>,
response_sender: IpcSender<Option<(IpcSender<CanvasMsg>, CanvasId, ImageKey)>>,
response_sender: IpcSender<Option<(GenericSender<CanvasMsg>, CanvasId, ImageKey)>>,
) {
let (canvas_data_sender, canvas_data_receiver) = unbounded();
let (canvas_sender, canvas_ipc_sender) = self
@ -5648,7 +5648,9 @@ where
}
}
fn create_canvas_paint_thread(&self) -> (Sender<ConstellationCanvasMsg>, IpcSender<CanvasMsg>) {
fn create_canvas_paint_thread(
&self,
) -> (Sender<ConstellationCanvasMsg>, GenericSender<CanvasMsg>) {
CanvasPaintThread::start(self.compositor_proxy.cross_process_compositor_api.clone())
}
}