WebGPU installer: read Firefox's lock (IP:+PID) correctly; Firefox verified
Browse filesThe running-browser check expected Chromium's host-PID lock format, so a closed Firefox looked like a running one and was skipped. The script now takes the trailing PID in both formats, with tests for each.
Verified on Firefox 158 (Linux): WebGPU is off as shipped. With the installer's pref the check passes on the real card, --undo switches it off again, and the extension installs and marks drAIML's page.
Co-Authored-By: Professor Codephreak <codephreak@pythai.net>
Files changed (3)
31 unmodified lines32333435363738394031 unmodified linesos.symlink(f"{os.uname().nodename}-{os.getpid()}", tmp_path / "SingletonLock") # this test process: aliver = run("--dir", str(tmp_path))assert r.returncode == 3 and "running" in r.stdout and json.loads((tmp_path / "Local State").read_text()) == {}def test_firefox_profile(tmp_path):(tmp_path / "prefs.js").write_text('user_pref("dom.webgpu.enabled", true);\nuser_pref("other", 1);\n')run("--dir", str(tmp_path))assert 'user_pref("dom.webgpu.enabled", true);' in (tmp_path / "user.js").read_text()31 unmodified lines3233343536373839404142434431 unmodified linesos.symlink(f"{os.uname().nodename}-{os.getpid()}", tmp_path / "SingletonLock") # this test process: aliver = run("--dir", str(tmp_path))assert r.returncode == 3 and "running" in r.stdout and json.loads((tmp_path / "Local State").read_text()) == {}ff = tmp_path / "ff"; ff.mkdir(); (ff / "prefs.js").write_text("")os.symlink(f"127.0.1.1:+{os.getpid()}", ff / "lock")assert run("--dir", str(ff)).returncode == 3 and not (ff / "user.js").exists()def test_firefox_profile(tmp_path):os.symlink("127.0.1.1:+999999999", tmp_path / "lock") # Firefox's lock format; a pid that is not running(tmp_path / "prefs.js").write_text('user_pref("dom.webgpu.enabled", true);\nuser_pref("other", 1);\n')run("--dir", str(tmp_path))assert 'user_pref("dom.webgpu.enabled", true);' in (tmp_path / "user.js").read_text()
56 unmodified lines575859606162636456 unmodified lines- With only the installer's two flags, the browser goes from "no adapter" to the AMD card.- Headless mode forces a software renderer, so that run used `--use-angle=vulkan` as a stand-in for a desktop browser'snormal graphics path.- **Not yet tested:** `webgpu-enable.ps1` (written for Windows PowerShell 5.1 and PowerShell 7), macOS, and Firefox loadingthe extension.## Build`bash build.sh` writes `draiml-webgpu-helper-<version>.zip` from `extension/`. It is the same file for Chrome (Load unpacked,56 unmodified lines5758596061626364656667686956 unmodified lines- With only the installer's two flags, the browser goes from "no adapter" to the AMD card.- Headless mode forces a software renderer, so that run used `--use-angle=vulkan` as a stand-in for a desktop browser'snormal graphics path.- **Linux, Firefox 158, headless, driven over WebDriver BiDi:**- As shipped, WebGPU is off and the page says so.- After `webgpu-enable.sh --firefox`, the check passes on the real card (not a software adapter, shader-f16). Firefoxhides the card's vendor name.- `--undo` switches it off again.- The extension installs (`webExtension.install`) and its content script marks drAIML's page.- **Not yet tested:** `webgpu-enable.ps1` (written for Windows PowerShell 5.1 and PowerShell 7) and macOS.## Build`bash build.sh` writes `draiml-webgpu-helper-<version>.zip` from `extension/`. It is the same file for Chrome (Load unpacked,
51 unmodified lines5253545556575851 unmodified linesrunning() {local lock="$1" target pid[ -L "$lock" ] || return 1target=$(readlink "$lock"); pid=${target##*-}; pid=${pid#+}[[ "$pid" =~ ^[0-9]+$ ]] || return 0 # a lock we cannot read: treat as runningkill -0 "$pid" 2>/dev/null}51 unmodified lines5253545556575851 unmodified linesrunning() {local lock="$1" target pid[ -L "$lock" ] || return 1target=$(readlink "$lock"); pid=$(printf '%s' "$target" | sed 's/.*[^0-9]//') # Chromium host-PID, Firefox IP:+PID[[ "$pid" =~ ^[0-9]+$ ]] || return 0 # a lock we cannot read: treat as runningkill -0 "$pid" 2>/dev/null}
tests/test_webgpu_installer.py+4
webgpu/README.md+7-2
webgpu/installer/webgpu-enable.sh+1-1