Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Based on the reported `fps` the GPU is then classified into either `tier: 1 (>=
| `WEBGL_UNSUPPORTED` | No WebGL context could be created. `tier` is always 0. |
| `SSR` | Running server-side — no `window`, detection skipped. |

The `fps` field is populated only for `BENCHMARK` results. All other `type` values leave `fps` as `undefined`.

## API

```ts
Expand Down
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,11 @@ export const getGPUTier = async ({
aDis === bDis ? aFps - bFps : aDis - bDis
);
if (!results.length) {
// Commas in cleaned renderers (e.g. "google, swiftshader ...") break
// substring matches against blocklist entries — strip them first.
const renderForBlocklist = renderer!.replace(/,/g, '');
const blocklistedModel: string | undefined = BLOCKLISTED_GPUS.find(
(blocklistedModel) => renderer!.includes(blocklistedModel)
(blocklistedModel) => renderForBlocklist.includes(blocklistedModel)
);
if (blocklistedModel) return toResult(0, 'BLOCKLISTED', blocklistedModel);

Expand Down
2 changes: 1 addition & 1 deletion src/internal/blocklistedGPUS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const BLOCKLISTED_GPUS = [
'geforce gt 130',
'geforce gt 330m',
'geforce gtx 285',
'google swiftshader',
'swiftshader',
'intel g41',
'intel g45',
'intel gma 4500mhd',
Expand Down
15 changes: 14 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,19 @@ for (const { input, expected } of [
});
});

test('SwiftShader is detected as BLOCKLISTED tier 0', async () => {
// SwiftShader is Chrome's CPU-based WebGL fallback — no hardware
// acceleration, so consumers should treat it as unusable.
const result = await getTier({
isMobile: false,
renderer:
'ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)',
});
expect(result.type).toBe('BLOCKLISTED');
expect(result.tier).toBe(0);
expect(result.gpu).toBe('swiftshader');
});

test('Apple Silicon desktop Safari — tier-3 BENCHMARK with m-series label', async () => {
// Safari returns 'Apple GPU' uniformly for M1–M5 with no chip-level
// discrimination available from WebGL. Base M1 already hits the tier-3
Expand Down Expand Up @@ -403,7 +416,7 @@ test('Apple GPU on mobile does NOT take the desktop tier-3 path', async () => {
},
{
expected: {
gpu: 'google swiftshader',
gpu: 'swiftshader',
},
input: {
isMobile: false,
Expand Down