WebGPU device-loss recovery, the counterpart of webgl-context-recovery.ts.
three's WebGPURenderer does NOT recreate a lost device: its backend calls
renderer.onDeviceLost, which only logs and latches _isDeviceLost, after
which every render returns early. So recovery here means building a NEW
renderer on the same canvas (the host's recreateRenderer) and handing it to
everything that renders (post-processing, environment, picking), then
re-uploading the geometry from its CPU mirrors, exactly as a WebGL context
restore does.
Sequence:
Loss: the current device's lost promise resolves. A 'destroyed'
reason means the device was explicitly destroyed and is not a
recoverable loss. Otherwise flip isLost, tell the host (onLost: event, toast,
smaller GPU budget), and start recovery.
Recovery: recreateRenderer() builds a renderer on a fresh device and
rewires the host. Success re-arms the observer on the new device and calls
onRestored. A failure is retried once after retryDelayMs; a second
failure ends in onUnrecoverable (the reload prompt).
A device that is lost again after a successful recovery starts the cycle
afresh: the attempt budget is per loss, not per session.
WebGPU device-loss recovery, the counterpart of
webgl-context-recovery.ts.three's
WebGPURendererdoes NOT recreate a lost device: its backend callsrenderer.onDeviceLost, which only logs and latches_isDeviceLost, after which every render returns early. So recovery here means building a NEW renderer on the same canvas (the host'srecreateRenderer) and handing it to everything that renders (post-processing, environment, picking), then re-uploading the geometry from its CPU mirrors, exactly as a WebGL context restore does.Sequence:
lostpromise resolves. A'destroyed'reason means the device was explicitly destroyed and is not a recoverable loss. Otherwise flipisLost, tell the host (onLost: event, toast, smaller GPU budget), and start recovery.recreateRenderer()builds a renderer on a fresh device and rewires the host. Success re-arms the observer on the new device and callsonRestored. A failure is retried once afterretryDelayMs; a second failure ends inonUnrecoverable(the reload prompt).A device that is lost again after a successful recovery starts the cycle afresh: the attempt budget is per loss, not per session.