Skip to content

Conversation

@white-axe
Copy link
Collaborator

Description

Before this pull request, the web builds would decide whether to use WebGPU or WebGL by checking if navigator.gpu is 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 define navigator.gpu when WebGPU isn't supported, and the web builds would crash in such cases because wgpu would choose WebGPU based on the fact that navigator.gpu was 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.gpu is 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

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown -Z build-std=std,panic_abort
  • Run cargo build --release
  • If applicable, run trunk build --release

@melody-rs melody-rs merged commit badc99c into Astrabit-ST:dev Jul 27, 2025
4 checks passed
@white-axe white-axe deleted the webgl branch July 27, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants