constellation: Wait for canvas thread to shut down before shutting down system font service (#37182)

The canvas thread might need access to the system font service before it
shuts down. Ensure that it finishes shutting down before triggering the
shutdown of the system font service. This should avoid issues where
canvas tries to access fonts right before shutting down.

Fixes: #36849.
Testing: Since this fixes a flaky crash on shutdown, there isn't a good
way to write a test for it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-05-30 13:44:16 +02:00 committed by GitHub
parent 5de3b5d166
commit 578c52fe2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -97,7 +97,10 @@ impl<'a> CanvasPaintThread<'a> {
let canvas_data = canvas_paint_thread.create_canvas(size);
creator.send(canvas_data).unwrap();
},
Ok(ConstellationCanvasMsg::Exit) => break,
Ok(ConstellationCanvasMsg::Exit(exit_sender)) => {
let _ = exit_sender.send(());
break;
},
Err(e) => {
warn!("Error on CanvasPaintThread receive ({})", e);
break;

View file

@ -2758,7 +2758,11 @@ where
}
debug!("Exiting Canvas Paint thread.");
if let Err(e) = self.canvas_sender.send(ConstellationCanvasMsg::Exit) {
let (canvas_exit_sender, canvas_exit_receiver) = unbounded();
if let Err(e) = self
.canvas_sender
.send(ConstellationCanvasMsg::Exit(canvas_exit_sender))
{
warn!("Exit Canvas Paint thread failed ({})", e);
}
@ -2800,6 +2804,10 @@ where
debug!("Exiting GLPlayer thread.");
WindowGLContext::get().exit();
// Wait for the canvas thread to exit before shutting down the font service, as
// canvas might still be using the system font service before shutting down.
let _ = canvas_exit_receiver.recv();
debug!("Exiting the system font service thread.");
self.system_font_service.exit();

View file

@ -21,5 +21,5 @@ pub enum ConstellationCanvasMsg {
sender: Sender<(CanvasId, ImageKey)>,
size: Size2D<u64>,
},
Exit,
Exit(Sender<()>),
}