Skip to content

Commit

Permalink
fix: wait for context lost promise
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Jun 13, 2023
1 parent bc371cf commit f64e45d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/g-plugin-webgpu-device/src/WebGPUDeviceContribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export class WebGPUDeviceContribution implements DeviceContribution {
);
const device = await adapter.requestDevice({ requiredFeatures });

// @see https://github.com/gpuweb/gpuweb/blob/main/design/ErrorHandling.md#fatal-errors-requestadapter-requestdevice-and-devicelost
const { onContextLost } = this.pluginOptions;
device.lost.then(() => {
if (onContextLost) {
onContextLost();
}
});
if (device) {
// @see https://github.com/gpuweb/gpuweb/blob/main/design/ErrorHandling.md#fatal-errors-requestadapter-requestdevice-and-devicelost
const { onContextLost } = this.pluginOptions;
device.lost.then(() => {
if (onContextLost) {
onContextLost();
}
});
}

if (device === null) return null;

Expand Down

0 comments on commit f64e45d

Please sign in to comment.