Bug 1758070 - Null out mContext during shutdown. r=emilio, a=tritter FIREFOX_91_7_0esr_BUILD3 FIREFOX_91_7_0esr_RELEASE
authorNicolas Silva <nsilva@mozilla.com>
Fri, 04 Mar 2022 16:12:04 +0000 (2022-03-04)
changeset 681335 a9d3c0f4732a9a62428089fff64ae8ff3d608918
parent 681334 b585e5dc126bd9604680992d489be7a787b0f76e
child 681344 8c98c97c0fecf2d0dcb2d2b8ec970bd41762c679
push id290433
push userryanvm@gmail.com
push dateFri, 04 Mar 2022 16:46:49 +0000 (2022-03-04)
reviewersemilio, tritter
bugs1758070
milestone91.7.0
Bug 1758070 - Null out mContext during shutdown. r=emilio, a=tritter Differential Revision: https://phabricator.services.mozilla.com/D140336
dom/webgpu/ipc/WebGPUParent.cpp
dom/webgpu/ipc/WebGPUParent.h
--- a/dom/webgpu/ipc/WebGPUParent.cpp
+++ b/dom/webgpu/ipc/WebGPUParent.cpp
@@ -731,16 +731,17 @@ ipc::IPCResult WebGPUParent::RecvShutdow
   mTimer.Stop();
   for (const auto& p : mCanvasMap) {
     const wr::ExternalImageId extId = {p.first};
     layers::TextureHost::DestroyRenderTexture(extId);
   }
   mCanvasMap.clear();
   ffi::wgpu_server_poll_all_devices(mContext, true);
   ffi::wgpu_server_delete(const_cast<ffi::WGPUGlobal*>(mContext));
+  mContext = nullptr;
   return IPC_OK();
 }
 
 ipc::IPCResult WebGPUParent::RecvDeviceAction(RawId aSelf,
                                               const ipc::ByteBuf& aByteBuf) {
   ErrorBuffer error;
   ffi::wgpu_server_device_action(mContext, aSelf, ToFFI(&aByteBuf),
                                  error.ToFFI());
--- a/dom/webgpu/ipc/WebGPUParent.h
+++ b/dom/webgpu/ipc/WebGPUParent.h
@@ -89,17 +89,17 @@ class WebGPUParent final : public PWebGP
 
   ipc::IPCResult RecvShutdown();
 
  private:
   virtual ~WebGPUParent();
   void MaintainDevices();
   bool ForwardError(RawId aDeviceID, ErrorBuffer& aError);
 
-  const ffi::WGPUGlobal* const mContext;
+  const ffi::WGPUGlobal* mContext;
   base::RepeatingTimer<WebGPUParent> mTimer;
   /// Shmem associated with a mappable buffer has to be owned by one of the
   /// processes. We keep it here for every mappable buffer while the buffer is
   /// used by GPU.
   std::unordered_map<uint64_t, Shmem> mSharedMemoryMap;
   /// Associated presentation data for each swapchain.
   std::unordered_map<uint64_t, RefPtr<PresentationData>> mCanvasMap;
   /// Associated stack of error scopes for each device.