File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,10 @@ impl Drop for Queue {
154
154
self . device . raw ( ) . wait (
155
155
fence. as_ref ( ) ,
156
156
last_successful_submission_index,
157
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
157
158
crate :: device:: CLEANUP_WAIT_MS ,
159
+ #[ cfg( target_arch = "wasm32" ) ]
160
+ 0 , // WebKit and Chromium don't support a non-0 timeout
158
161
)
159
162
} ;
160
163
drop ( fence) ;
@@ -163,6 +166,13 @@ impl Drop for Queue {
163
166
Ok ( true ) => { }
164
167
// Note: If we don't panic here we are in UB land (destroying resources while they are still in use by the GPU).
165
168
Ok ( false ) => {
169
+ // It's fine that we timed out on WebGL; GL objects can be deleted early as they
170
+ // will be kept around by the driver if GPU work hasn't finished.
171
+ // Moreover, the way we emulate read mappings on WebGL allows us to execute map_buffer earlier than on other
172
+ // backends since getBufferSubData is synchronous with respect to the other previously enqueued GL commands.
173
+ // Relying on this behavior breaks the clean abstraction wgpu-hal tries to maintain and
174
+ // we should find ways to improve this. See https://github.com/gfx-rs/wgpu/issues/6538.
175
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
166
176
panic ! ( "We timed out while waiting on the last successful submission to complete!" ) ;
167
177
}
168
178
Err ( e) => {
Original file line number Diff line number Diff line change @@ -1563,6 +1563,10 @@ impl crate::Device for super::Device {
1563
1563
) -> Result < bool , crate :: DeviceError > {
1564
1564
if fence. last_completed . load ( Ordering :: Relaxed ) < wait_value {
1565
1565
let gl = & self . shared . context . lock ( ) ;
1566
+ // MAX_CLIENT_WAIT_TIMEOUT_WEBGL is:
1567
+ // - 1s in Gecko https://searchfox.org/mozilla-central/rev/754074e05178e017ef6c3d8e30428ffa8f1b794d/dom/canvas/WebGLTypes.h#1386
1568
+ // - 0 in WebKit https://github.com/WebKit/WebKit/blob/4ef90d4672ca50267c0971b85db403d9684508ea/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp#L110
1569
+ // - 0 in Chromium https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/webgl/webgl2_rendering_context_base.cc;l=112;drc=a3cb0ac4c71ec04abfeaed199e5d63230eca2551
1566
1570
let timeout_ns = if cfg ! ( any( webgl, Emscripten ) ) {
1567
1571
0
1568
1572
} else {
You can’t perform that action at this time.
0 commit comments