emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.37k stars 3.25k forks source link

Browser arguments with underscores not supported #22045

Closed rghosh0 closed 1 month ago

rghosh0 commented 1 month ago

In emrun.py, browser arguments are transformed to replace '_' with '-'. This is preventing some browser arguments from getting through to chrome.

https://github.com/emscripten-core/emscripten/blob/main/emrun.py#L1570

In particular, the browser flags --enable-dawn-features and --disable-dawn-features match against string values from here, including use_dxc https://source.chromium.org/chromium/chromium/src/+/main:third_party/dawn/src/dawn/native/Toggles.cpp?q=toggles

When emrun.py changes use_dxc to use-dxc this prevents this flag from taking effect.

Version of emscripten/emsdk:

$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.61 (67fa4c16496b157a7fc3377afd69ee0445e8a6e3)
clang version 19.0.0git (https:/github.com/llvm/llvm-project 7cfffe74eeb68fbb3fb9706ac7071f8caeeb6520)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\install\emsdk\upstream\bin

Failing command line in full:

C:\install\emsdk\python\3.9.2-nuget_64bit\python.exe "C:\install\emsdk\upstream\emscripten\emrun.py" --browser chrome --browser_args="--start-maximized --disable-dawn-features=use_dxc" Demonstrator.html

With this command, we see that --disable-dawn-features=use_dxc did not take effect. Navigating to "chrome://gpu", we see that use_dxc appears under [Enabled Toggle Names]. Further, in "Version Information" we see

Command Line               : "C:\Program Files\Google/Chrome/Application/chrome.exe" --start-maximized --disable-dawn-features=use-dxc --enable-nacl --enable-pnacl --disable-restore-session-state --enable-webgl --no-default-browser-check --no-first-run --allow-file-access-from-files --password-store=basic --flag-switches-begin --flag-switches-end http://localhost:6931/Demonstrator.html

In contrast, if I run this command:

& 'C:\Program Files\Google\Chrome\Application\chrome.exe' --start-maximized --disable-dawn-features=use_dxc

Then in "chrome://gpu", use_dxc appears under [WebGPU Required Toggles - disabled]. And in "Version Information" we see

Command Line               : "C:\Program Files\Google\Chrome\Application\chrome.exe" --start-maximized --disable-dawn-features=use_dxc --flag-switches-begin --flag-switches-end