Fix panic in Webrender during shutdown (#32897)

* Fix panic in webrender during shutdown

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Pass webgl_threads_sender to WebGLThreads::exit

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* follow the naming convention and use sender instead of webgl_threads_sender

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Avoid deadlock when webgl_threads is None

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Use tuple matching for webgl_threads and webgl_threads_receiver

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

* Remove unused _webgl_threads_sender

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>

---------

Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
Taym Haddadi 2024-08-06 12:01:33 +02:00 committed by GitHub
parent 28430bad0e
commit 3800922cde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 13 deletions

View file

@ -14,7 +14,7 @@ pub use base::generic_channel::GenericSender as WebGLSender;
/// Result type for send()/recv() calls in in WebGLCommands.
pub use base::generic_channel::SendResult as WebGLSendResult;
use euclid::default::{Rect, Size2D};
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSharedMemory};
use ipc_channel::ipc::{IpcBytesReceiver, IpcBytesSender, IpcSender, IpcSharedMemory};
use malloc_size_of_derive::MallocSizeOf;
use pixels::PixelFormat;
use serde::{Deserialize, Serialize};
@ -73,9 +73,9 @@ impl WebGLThreads {
}
/// Sends a exit message to close the WebGLThreads and release all WebGLContexts.
pub fn exit(&self) -> Result<(), &'static str> {
pub fn exit(&self, sender: IpcSender<()>) -> Result<(), &'static str> {
self.0
.send(WebGLMsg::Exit)
.send(WebGLMsg::Exit(sender))
.map_err(|_| "Failed to send Exit message")
}
}
@ -106,7 +106,7 @@ pub enum WebGLMsg {
/// request is fulfilled
SwapBuffers(Vec<WebGLContextId>, WebGLSender<u64>, u64),
/// Frees all resources and closes the thread.
Exit,
Exit(IpcSender<()>),
}
#[derive(Clone, Copy, Debug, Deserialize, MallocSizeOf, PartialEq, Serialize)]