Ensure GPUDevice cleanup in GlobalScope

This commit is contained in:
Kunal Mohan 2020-07-17 21:15:07 +05:30
parent 37d606621d
commit 785497af63
4 changed files with 52 additions and 3 deletions

View file

@ -2954,6 +2954,10 @@ impl GlobalScope {
.insert(device.id(), Dom::from_ref(device));
}
pub fn remove_gpu_device(&self, device: WebGPUDevice) {
let _ = self.gpu_devices.borrow_mut().remove(&device);
}
pub fn handle_wgpu_msg(&self, device: WebGPUDevice, scope: u64, result: WebGPUOpResult) {
let result = match result {
WebGPUOpResult::Success => Ok(()),

View file

@ -2069,6 +2069,13 @@ impl ScriptThread {
let global = self.documents.borrow().find_global(pipeline_id).unwrap();
global.handle_wgpu_msg(device, scope_id, result);
},
WebGPUMsg::CleanDevice {
pipeline_id,
device,
} => {
let global = self.documents.borrow().find_global(pipeline_id).unwrap();
global.remove_gpu_device(device);
},
_ => {},
}
}