File size: 5,042 Bytes
7e173d8
 
 
 
 
 
 
 
df78ac0
7e173d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5abc97
 
 
 
 
 
e940395
 
 
 
 
 
 
7e173d8
c44b6e6
 
 
 
 
7e173d8
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# drAIML WebGPU helper

drAIML's Bonsai runs in the browser and can use a graphics card through **WebGPU**. Many browsers ship WebGPU turned off
(Chromium-family browsers on Linux, Firefox outside Windows) or with the card blocklisted. Without it, Bonsai still runs on the
processor, just more slowly, and a visitor cannot lend their graphics card from the ❤️ Donate panel. This folder helps those visitors.

| Part | What it does |
|---|---|
| `index.html` (the Space's `/webgpu/index.html`) | Runs the check in any browser, phones and Safari included. Links the extension and installers. |
| `extension/` | A Manifest V3 browser extension (Chrome, Brave, Edge, Vivaldi, Opera, Firefox 121+). A toolbar button runs the check, the badge shows the verdict (✓ / ! / ✕), and flag pages open in one click. |
| `installer/webgpu-enable.sh` | Linux and macOS: switches WebGPU on in every Chromium-family profile, and in Firefox with `--firefox`. |
| `installer/webgpu-enable.ps1` | Windows: the same. |

**There is nothing to install for WebGPU itself.** It is part of the browser. The "installer" changes the same settings
chrome://flags or about:config would:

- **Chromium-family browsers:** `enable-unsafe-webgpu`, and on Linux also `enable-vulkan@1`. With `--blocklist`, also
  `ignore-gpu-blocklist`. They go into the profile's `Local State` → `browser.enabled_labs_experiments`, which is where chrome://flags
  stores them.
- **Firefox:** `user_pref("dom.webgpu.enabled", true)` in each profile's `user.js`, between marker comments.

How the installer handles changes:
- It skips a browser that is running, because the browser would rewrite its settings on exit.
- It backs up `Local State` before editing it.
- It records what it added in `Local State.webgpu-helper.json`, so `--undo` removes exactly that.
- `--dry-run` shows what it would change.
- On Linux it also warns when no Vulkan driver is installed. WebGPU runs on Vulkan there.

## The check
`extension/check.js` works through these steps:
1. It asks for a low-power and a high-performance adapter.
2. It describes the card: vendor, architecture, features, limits, and whether it is a software adapter.
3. It runs one compute shader, `out[i] = in[i] * 3 + 1`, over 65,536 values and checks every result.

Verdicts:
- **ready:** a real card passed.
- **software:** only SwiftShader or another CPU fallback answered.
- **broken:** a card answered but failed the test.
- **no-adapter:** WebGPU is on, but no card answered.
- **missing:** there is no `navigator.gpu`.

Each verdict comes with steps for this browser and system. Nothing is sent anywhere.

## Privacy and permissions
The extension asks for no permissions. Its content script runs only on drAIML's own pages
(`pythai-draiml.static.hf.space`, and `127.0.0.1:8766` for local development). There it sets
`<html data-webgpu-helper="0.1.0">` and, when the page posts `{type: "draiml-webgpu-helper:open"}`, opens the check. It reads
nothing from any page.

The "Unsafe WebGPU Support" flag lets every site use WebGPU, not only drAIML. That is why Chromium calls it unsafe. Undo it any
time in chrome://flags, or with the installer's `--undo`.

## Tested
- **Linux, Brave 157, AMD Radeon Vega (gcn-5), headless:**
  - The extension loads, gives a verdict, sets the badge, and marks drAIML's page.
  - The installer adds the flags, is idempotent, skips locked profiles, and undo removes exactly what it added.
  - 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's
    normal 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). Firefox
    hides the card's vendor name.
  - `--undo` switches it off again.
  - The extension installs (`webExtension.install`) and its content script marks drAIML's page.
- **`webgpu-enable.ps1` on PowerShell 7.4** (Microsoft's container, Windows-style `%LOCALAPPDATA%`/`%APPDATA%` trees):
  `tests/webgpu_installer.ps1`, 24 checks.
  - Dry run, add, `-Blocklist`, and undo across both runs.
  - Keys that differ only in case and large numbers survive.
  - Firefox profiles are handled.
  - A held `lockfile` is skipped.
- **Not yet tested:** Windows PowerShell 5.1 (the JavaScriptSerializer path) on a real Windows, and macOS.

## Stores
`store/` holds what the Chrome Web Store, addons.mozilla.org and Edge Add-ons ask for: listing text and privacy answers
(`LISTING.md`), the privacy policy (`PRIVACY.md`), 1280×800 screenshots and promo tiles. Submitting needs the owner's
developer accounts.

## Build
`bash build.sh` writes `draiml-webgpu-helper-<version>.zip` from `extension/`. It is the same file for Chrome (Load unpacked,
or the Chrome Web Store) and Firefox (about:debugging, or addons.mozilla.org signing).

MIT licence.