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

@ -9,6 +9,7 @@ use std::sync::Arc;
use app_units::Au;
use base::Epoch;
use base::generic_channel::GenericSender;
use canvas_traits::canvas::{
Canvas2dMsg, CanvasFont, CanvasId, CanvasMsg, CompositionOptions, CompositionOrBlending,
FillOrStrokeStyle, FillRule, GlyphAndPosition, LineCapStyle, LineJoinStyle, LineOptions,
@ -23,7 +24,7 @@ use fonts::{
ByteIndex, FontBaseline, FontContext, FontGroup, FontIdentifier, FontMetrics, FontRef,
LAST_RESORT_GLYPH_ADVANCE, ShapingFlags, ShapingOptions,
};
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::ipc;
use net_traits::image_cache::{ImageCache, ImageResponse};
use net_traits::request::CorsSettings;
use pixels::{PixelFormat, Snapshot, SnapshotAlphaMode, SnapshotPixelFormat};
@ -193,9 +194,8 @@ impl CanvasContextState {
#[cfg_attr(crown, crown::unrooted_must_root_lint::must_root)]
#[derive(JSTraceable, MallocSizeOf)]
pub(super) struct CanvasState {
#[ignore_malloc_size_of = "Defined in ipc-channel"]
#[no_trace]
ipc_renderer: IpcSender<CanvasMsg>,
ipc_renderer: GenericSender<CanvasMsg>,
#[no_trace]
canvas_id: CanvasId,
#[no_trace]