Skip to content

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Sep 30, 2025

Connections

Description
Introduces wgpu::PollType::WaitWithTimeout/wgpu::PollType::WaitForSubmissionIndexWithTimeout variants to allow specifying a timeout on polls. This is useful for instance for image comparision tests or similar in a CI environment!

Decided to expose this as new enum variants since this is the least intrusive for current code and least bothersome if one doesn't care about timeouts here.
Went with Duration all the way since it's most expressive and doesn't require unit documentation/assumptions.

A soft-breaking change that comes along with this is that the non-timeout waits no longer have a hardcoded timeout of 60s. Note that the constant that set this was misdocumented at this point: our timeouting on device drop is a lot more sophisticated by now and there's no more UB involved in any of this!

Testing
Added test, some coverage by existing

Squash or Rebase?

Squash

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

Copy link
Member

@ErichDonGubler ErichDonGubler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minus a seemingly accidental CHANGELOG entry. Approving and trusting this will be fixed before merge.

timeout: Option<Duration>,
) -> Result<bool, crate::DeviceError> {
let timeout_duration = Duration::from_millis(timeout_ms as u64);
let timeout = timeout.unwrap_or(Duration::MAX);
Copy link
Contributor

@emilk emilk Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If None means the same as Duration::MAX, why pass duration by Option at all?

From just the function declaration it is far from obvious that None means MAX. It could just as well mean "Use the default timeout"

Copy link
Member Author

@Wumpf Wumpf Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of the implementations do this right now, but often there's simpler fast/path for no timeout. I think for the low-level hal api this is fine like that, but I am missing docstring on the trait this implements

@Wumpf Wumpf enabled auto-merge (squash) October 1, 2025 07:03
@Wumpf Wumpf merged commit 00ea850 into gfx-rs:trunk Oct 1, 2025
70 of 71 checks passed
@Wumpf Wumpf deleted the poll-timeouts branch October 1, 2025 07:19
sharmajai pushed a commit to sharmajai/wgpu that referenced this pull request Oct 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants