lost property
The lost
read-only property of the
GPUDevice interface contains a Promise
that remains pending throughout
the device's lifetime and resolves with a GPUDeviceLostInfo object when
the device is lost.
GPUAdapter.requestDevice will never return null
, and it will reject
only if the request is invalid, i.e. it exceeds the capabilities of the
GPUAdapter. If a valid device request can't be fulfilled for some reason
however it may resolve to a device that has already been lost.
Additionally, devices can be lost at any time after creation for a variety
of reasons (such as browser resource management or driver updates), so
it's a good idea to always handle lost devices gracefully.
Many causes for lost devices are transient, so you should try getting a new device once a previous one has been lost unless the loss was caused by the application intentionally destroying the device (i.e. with GPUDevice.destroy). Note that any WebGPU resources created with a previous device (buffers, textures, etc.) will need to be re-created with the new one.
Note
Also bear in mind that a GPUAdapter
may become unavailable, e.g. if
the physical GPU is unplugged from the system or disabled to save power.
From then on, the adapter can no longer return valid devices, and will
always return already-lost devices.
Implementation
external JSPromise<GPUDeviceLostInfo> get lost;