Improve detection of available graphics backends in web builds#171
Merged
melody-rs merged 1 commit intoAstrabit-ST:devfrom Jul 27, 2025
Merged
Improve detection of available graphics backends in web builds#171melody-rs merged 1 commit intoAstrabit-ST:devfrom
melody-rs merged 1 commit intoAstrabit-ST:devfrom
Conversation
melody-rs
approved these changes
Jul 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before this pull request, the web builds would decide whether to use WebGPU or WebGL by checking if
navigator.gpuis defined in JavaScript (in the worker thread that most of Luminol's code runs in, not in the main thread), and then use WebGPU if it is or WebGL if it isn't. However, some browsers definenavigator.gpuwhen WebGPU isn't supported, and the web builds would crash in such cases because wgpu would choose WebGPU based on the fact thatnavigator.gpuwas defined, fail to create a WebGPU instance and then give up instead of falling back to WebGL.This pull request changes the web runner initialization to use a utility function provided by wgpu to check if a WebGPU instance can be successfully initialized and then choose WebGPU or WebGL depending on the outcome.
Testing
In Firefox 141 on Arch Linux, I noticed that
navigator.gpuis defined in the worker thread even though WebGPU doesn't work. It wasn't defined when I was testing #170, so this might be a recent development.Checklist
cargo fmt.cargo clippy. If applicable, add:--target wasm32-unknown-unknown -Z build-std=std,panic_abortcargo build --releasetrunk build --release