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

wgpu often panics on errors #3777

Closed
emilk opened this issue May 16, 2023 · 2 comments
Closed

wgpu often panics on errors #3777

emilk opened this issue May 16, 2023 · 2 comments

Comments

@emilk
Copy link
Contributor

emilk commented May 16, 2023

For instance, I get this in my browser:

Error] panicked at 'wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
    Color state [0] is invalid
    Format Rgba8UnormSrgb can't be multisampled

', /home/jp/.cargo/git/checkouts/wgpu-b5b0e12eef369ba9/de497ae/wgpu/src/backend/direct.rs:3019:5

The error message is pretty good, but I would prefer to get an Err instead of a panic.

Here is the code from wgpu/src/backend/direct.rs:

    #[track_caller]
    fn handle_error_fatal(
        &self,
        cause: impl Error + Send + Sync + 'static,
        operation: &'static str,
    ) -> ! {
        panic!("Error in {operation}: {f}", f = self.format_error(&cause));
    }

This is not a big problem; if returning a Result would be extremely annoying for some reason, then the current behavior is good enough, but usually it is bad manners for a library to panic when it could use Result instead.

@Wumpf
Copy link
Member

Wumpf commented May 16, 2023

Related to

@cwfitzgerald
Copy link
Member

Due to us wanting to abstract over WebGPU which has completely asynchronous error handling we need to use WebGPU style error handling for native as well. We have discussed having a native only version that returns an Error, but how much we diverge on native is a long standing debate. I'm going to close in favor of #3767 and add information there about the functions to call.

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

No branches or pull requests

3 participants