Skip to content

Commit

Permalink
expect to timeout when targeting WebGL
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed Oct 15, 2024
1 parent 19bd94e commit 2f16a44
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions wgpu-core/src/device/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ impl Drop for Queue {
self.device.raw().wait(
fence.as_ref(),
last_successful_submission_index,
#[cfg(not(target_arch = "wasm32"))]
crate::device::CLEANUP_WAIT_MS,
#[cfg(target_arch = "wasm32")]
0, // WebKit and Chromium don't support a non-0 timeout
)
};
drop(fence);
Expand All @@ -163,6 +166,7 @@ impl Drop for Queue {
Ok(true) => {}
// Note: If we don't panic here we are in UB land (destroying resources while they are still in use by the GPU).
Ok(false) => {
#[cfg(not(target_arch = "wasm32"))] // this is not right but should get CI passing :(
panic!("We timed out while waiting on the last successful submission to complete!");
}
Err(e) => {
Expand Down
4 changes: 4 additions & 0 deletions wgpu-hal/src/gles/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,10 @@ impl crate::Device for super::Device {
) -> Result<bool, crate::DeviceError> {
if fence.last_completed < wait_value {
let gl = &self.shared.context.lock();
// MAX_CLIENT_WAIT_TIMEOUT_WEBGL is:
// - 1s in Gecko https://searchfox.org/mozilla-central/rev/754074e05178e017ef6c3d8e30428ffa8f1b794d/dom/canvas/WebGLTypes.h#1386
// - 0 in WebKit https://github.com/WebKit/WebKit/blob/4ef90d4672ca50267c0971b85db403d9684508ea/Source/WebCore/html/canvas/WebGL2RenderingContext.cpp#L110
// - 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
let timeout_ns = if cfg!(any(webgl, Emscripten)) {
0
} else {
Expand Down

0 comments on commit 2f16a44

Please sign in to comment.