mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +01:00
compositor: Preserve CompositorMsg deserialization errors (#38972)
Forward any deserialization errors to the receiver, instead of panicking on the router thread. This change was previously part of #38782, which got reverted, since generic channels don't support custom router callbacks yet. Propagating the error is still something we want, and landing this separately will reduce the diff of the PR that introduces generic callbacks. Testing: Should be covered by existing tests. Also manually tested https://github.com/servo/servo/issues/38939 --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com> Signed-off-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
eaab71d335
commit
a5d890c13a
4 changed files with 25 additions and 10 deletions
|
@ -45,7 +45,7 @@ use crate::viewport_description::ViewportDescription;
|
|||
/// Sends messages to the compositor.
|
||||
#[derive(Clone)]
|
||||
pub struct CompositorProxy {
|
||||
pub sender: Sender<CompositorMsg>,
|
||||
pub sender: Sender<Result<CompositorMsg, ipc_channel::Error>>,
|
||||
/// Access to [`Self::sender`] that is possible to send across an IPC
|
||||
/// channel. These messages are routed via the router thread to
|
||||
/// [`Self::sender`].
|
||||
|
@ -61,6 +61,14 @@ impl OpaqueSender<CompositorMsg> for CompositorProxy {
|
|||
|
||||
impl CompositorProxy {
|
||||
pub fn send(&self, msg: CompositorMsg) {
|
||||
self.route_msg(Ok(msg))
|
||||
}
|
||||
|
||||
/// Helper method to route a deserialized IPC message to the receiver.
|
||||
///
|
||||
/// This method is a temporary solution, and will be removed when migrating
|
||||
/// to `GenericChannel`.
|
||||
pub fn route_msg(&self, msg: Result<CompositorMsg, ipc_channel::Error>) {
|
||||
if let Err(err) = self.sender.send(msg) {
|
||||
warn!("Failed to send response ({:?}).", err);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue