Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't call wgpu::Device::poll on the web #1626

Merged
merged 2 commits into from
Mar 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions crates/re_renderer/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ impl RenderContext {
///
/// Should be somewhere between 1-4, too high and we use up more memory and introduce latency,
/// too low and we may starve the GPU.
/// On the web we want to go lower because a lot more memory constraint.
#[cfg(not(target_arch = "wasm32"))]
const MAX_NUM_INFLIGHT_QUEUE_SUBMISSIONS: usize = 4;
#[cfg(target_arch = "wasm32")]
const MAX_NUM_INFLIGHT_QUEUE_SUBMISSIONS: usize = 2;

pub fn new(
device: Arc<wgpu::Device>,
Expand Down Expand Up @@ -204,6 +200,17 @@ impl RenderContext {
fn poll_device(&mut self) {
crate::profile_function!();

// Browsers don't let us wait for GPU work via `poll`.
// * WebGPU: `poll` is a no-op as the spec doesn't specify it at all.
// * WebGL: Internal timeout can't go above a browser specific value.
// Since wgpu ran into issues in the past with some browsers returning errors,
// it uses a timeout of zero and ignores errors there.
// TODO(andreas): That's not the only thing that's weird with `maintain` in general.
// See https://github.com/gfx-rs/wgpu/issues/3601
if cfg!(target_arch = "wasm32") {
return;
}

// Ensure not too many queue submissions are in flight.
let num_submissions_to_wait_for = self
.inflight_queue_submissions
Expand Down