GoogleChrome / GoogleChrome/webai-compute-benchmark

Show warning/error if WebGPU is not available

Open
#3 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
13
Forks
5
PR merge metrics
No merged PRs in 30d

Description

Right now, the WebGPU workloads just fail "silently" on Chrome on Linux for example, since WebGPU is not enabled there by default (it needs a flag, sadly). Let's show some error message in the benchmark page instead (preferably red and big), something (very rough AI sketch):
```js
function checkWebGPUSupport() {
if (!navigator.gpu) {
displayWebGPUError("WebGPU API not found in navigator.");
return;
}

navigator.gpu.requestAdapter()
.then(adapter => {
if (adapter) {
console.log("WebGPU is supported. Adapter:", adapter.name);
// You can proceed with WebGPU initialization here
} else {
displayWebGPUError("No WebGPU adapter available. This might be due to a software rendering list, driver issues, or unsupported hardware.");
}
})
.catch(error => {
console.error("Error requesting WebGPU adapter:", error);
displayWebGPUError("WebGPU is not fully supported or enabled. Check browser settings and hardware acceleration.");
});
}

function displayWebGPUError(message) {
let errorDiv = document.getElementById('webgpu-error');
if (!errorDiv) {
errorDiv = document.createElement('div');
errorDiv.id = 'webgpu-error';
// Append to the body, or a specific container if you have one
document.body.appendChild(errorDiv);
}
errorDiv.textContent = "Error: " + message;
}

// Run the check when the DOM is ready
document.addEventListener('DOMContentLoaded', checkWebGPUSupport);
```

CSS:
```css
#webgpu-error {
color: #D93025; /* Google Red 600 */
background-color: #FAD2CF; /* Google Red 50 */
border: 1px solid #C5221F; /* Google Red 700 */
padding: 12px 16px;
margin: 16px 0;
border-radius: 4px;
font-weight: bold;
text-align: center;
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the benchmark page's WebGPU initialization and the existing page styling. Check for a missing navigator.gpu, unavailable adapter, and initialization failure, then show a prominent red warning instead of failing silently. Verify the message by opening the benchmark in Chrome on Linux with WebGPU disabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.