Skip to content

Conversation

@Azorlogh
Copy link
Contributor

@Azorlogh Azorlogh commented Nov 18, 2025

Description

On windows + gl backend:

  • When a process loads a dynamic library containing wgpu, the gles backend will create a window class.
  • It then leaks the window class (never unregisters it)
  • If the library is unloaded and loaded again by that same process, wgpu will try to initialize the window class again, with the same name, and fail with: wgpu_core::instance: Instance::new: failed to create Gl backend: InstanceError { message: "unable to register window class", source: Some(Error { code: HRESULT(0x80070582), message: "Class already exists." }) }

This adds an additional check to skip initialization if the window class already exists.

Testing

I ran my wgpu-based VST plugin against this PR and it now works properly.
Without this change, it only managed to initialize once, then subsequent initializations fail to get the adapter.

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. <- I don't have a windows machine to run tests on... The aforementioned VST ran on wine
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@Azorlogh Azorlogh changed the title Fix double window class registration windows/gl: Fix double window class registration Nov 18, 2025
@Azorlogh Azorlogh force-pushed the fix/gles/duplicate-window-class-registration branch from ce3e4fb to 1f2f3cc Compare November 18, 2025 23:27
@Azorlogh Azorlogh marked this pull request as draft November 19, 2025 00:55
@Azorlogh Azorlogh force-pushed the fix/gles/duplicate-window-class-registration branch from 1f2f3cc to df03631 Compare November 20, 2025 00:09
@Azorlogh Azorlogh marked this pull request as ready for review November 20, 2025 00:09
@cwfitzgerald cwfitzgerald self-assigned this Nov 26, 2025
@cwfitzgerald cwfitzgerald merged commit 43c5d27 into gfx-rs:trunk Nov 26, 2025
42 checks passed
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.

2 participants