From c0e2f475a237648098afde1ba95e41cf1318be66 Mon Sep 17 00:00:00 2001 From: Brad Werth Date: Mon, 29 Apr 2024 16:07:57 +0000 Subject: [PATCH] Bug 1893188: Make ComputePipeline::Cleanup gracefully handle a missing bridge. r=webgpu-reviewers,ErichDonGubler This aligns the implementation with RenderPipeline::Cleanup(). It also adds a drive-by assert to GetBindGroupLayout() in both classes to add confidence that the bridge is in the expected state. Differential Revision: https://phabricator.services.mozilla.com/D208916 --- dom/webgpu/ComputePipeline.cpp | 5 +++++ dom/webgpu/RenderPipeline.cpp | 1 + 2 files changed, 6 insertions(+) diff --git a/dom/webgpu/ComputePipeline.cpp b/dom/webgpu/ComputePipeline.cpp index 14df7f257a9c..759d8e16db46 100644 --- a/dom/webgpu/ComputePipeline.cpp +++ b/dom/webgpu/ComputePipeline.cpp @@ -33,6 +33,10 @@ void ComputePipeline::Cleanup() { mValid = false; auto bridge = mParent->GetBridge(); + if (!bridge) { + return; + } + if (bridge->CanSend()) { bridge->SendComputePipelineDrop(mId); if (mImplicitPipelineLayoutId) { @@ -54,6 +58,7 @@ void ComputePipeline::Cleanup() { already_AddRefed ComputePipeline::GetBindGroupLayout( uint32_t aIndex) const { auto bridge = mParent->GetBridge(); + MOZ_ASSERT(bridge && bridge->CanSend()); auto* client = bridge->GetClient(); ipc::ByteBuf bb; diff --git a/dom/webgpu/RenderPipeline.cpp b/dom/webgpu/RenderPipeline.cpp index aa9ffcdf9ae1..a8a0348f9de9 100644 --- a/dom/webgpu/RenderPipeline.cpp +++ b/dom/webgpu/RenderPipeline.cpp @@ -58,6 +58,7 @@ void RenderPipeline::Cleanup() { already_AddRefed RenderPipeline::GetBindGroupLayout( uint32_t aIndex) const { auto bridge = mParent->GetBridge(); + MOZ_ASSERT(bridge && bridge->CanSend()); auto* client = bridge->GetClient(); ipc::ByteBuf bb;