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 panic when gl.create_buffer() fails on webgl #3396

Merged
merged 1 commit into from
Jan 18, 2023

Conversation

Dinnerbone
Copy link
Contributor

@Dinnerbone Dinnerbone commented Jan 18, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
n/a

Description
In webgl gl.create_buffer() is fallible, and can return null (or Err, thanks to glow) when the device is unable to allocate any more buffers. We unwrap and crash instead of treating it as we do other OOM cases.

Side note: Has there been a discussion already about potentially disallowing unwrap() going forwards? So many unwraps are quite fragile :( expect forces developers to give a reason to why the panic should never happen.

Testing
Passes existing tests.

@codecov-commenter
Copy link

Codecov Report

Merging #3396 (ca2b2b6) into master (0849e78) will increase coverage by 0.26%.
The diff coverage is 100.00%.

❗ Current head ca2b2b6 differs from pull request most recent head 0cd527c. Consider uploading reports for the commit 0cd527c to get more accurate results

@@            Coverage Diff             @@
##           master    #3396      +/-   ##
==========================================
+ Coverage   65.23%   65.49%   +0.26%     
==========================================
  Files          86       66      -20     
  Lines       42772    37392    -5380     
==========================================
- Hits        27901    24490    -3411     
+ Misses      14871    12902    -1969     
Impacted Files Coverage Δ
wgpu-hal/src/gles/device.rs 81.40% <100.00%> (ø)
wgpu-types/src/assertions.rs 0.00% <0.00%> (-37.50%) ⬇️
wgpu-hal/src/auxil/renderdoc.rs 40.50% <0.00%> (-3.55%) ⬇️
wgpu-hal/src/lib.rs 24.03% <0.00%> (-2.89%) ⬇️
wgpu-types/src/lib.rs 86.53% <0.00%> (-0.92%) ⬇️
wgpu-hal/src/gles/egl.rs 38.00% <0.00%> (-0.50%) ⬇️
wgpu-core/src/device/mod.rs 66.44% <0.00%> (-0.29%) ⬇️
wgpu-hal/src/vulkan/instance.rs 38.18% <0.00%> (-0.19%) ⬇️
wgpu/src/backend/direct.rs 56.90% <0.00%> (-0.09%) ⬇️
wgpu-core/src/command/render.rs 62.71% <0.00%> (-0.06%) ⬇️
... and 23 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Side note: Has there been a discussion already about potentially disallowing unwrap() going forwards? So many unwraps are quite fragile :( expect forces developers to give a reason to why the panic should never happen.

We haven't - my gut feeling is that the verbosity of expect might get very annoying for trivial stuff.

@cwfitzgerald cwfitzgerald enabled auto-merge (squash) January 18, 2023 21:31
@cwfitzgerald cwfitzgerald merged commit cecf063 into gfx-rs:master Jan 18, 2023
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