Skip to content

Commit 2e330b2

Browse files
authored
Merge pull request #162 from pmndrs/fix/blocklist-swiftshader-and-punctuation
fix: detect SwiftShader as BLOCKLISTED, not FALLBACK
2 parents 5d552e3 + 79f4e07 commit 2e330b2

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ Based on the reported `fps` the GPU is then classified into either `tier: 1 (>=
6969
| `WEBGL_UNSUPPORTED` | No WebGL context could be created. `tier` is always 0. |
7070
| `SSR` | Running server-side — no `window`, detection skipped. |
7171

72+
The `fps` field is populated only for `BENCHMARK` results. All other `type` values leave `fps` as `undefined`.
73+
7274
## API
7375

7476
```ts

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,11 @@ export const getGPUTier = async ({
335335
aDis === bDis ? aFps - bFps : aDis - bDis
336336
);
337337
if (!results.length) {
338+
// Commas in cleaned renderers (e.g. "google, swiftshader ...") break
339+
// substring matches against blocklist entries — strip them first.
340+
const renderForBlocklist = renderer!.replace(/,/g, '');
338341
const blocklistedModel: string | undefined = BLOCKLISTED_GPUS.find(
339-
(blocklistedModel) => renderer!.includes(blocklistedModel)
342+
(blocklistedModel) => renderForBlocklist.includes(blocklistedModel)
340343
);
341344
if (blocklistedModel) return toResult(0, 'BLOCKLISTED', blocklistedModel);
342345

src/internal/blocklistedGPUS.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const BLOCKLISTED_GPUS = [
1717
'geforce gt 130',
1818
'geforce gt 330m',
1919
'geforce gtx 285',
20-
'google swiftshader',
20+
'swiftshader',
2121
'intel g41',
2222
'intel g45',
2323
'intel gma 4500mhd',

test/index.test.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,19 @@ for (const { input, expected } of [
325325
});
326326
});
327327

328+
test('SwiftShader is detected as BLOCKLISTED tier 0', async () => {
329+
// SwiftShader is Chrome's CPU-based WebGL fallback — no hardware
330+
// acceleration, so consumers should treat it as unusable.
331+
const result = await getTier({
332+
isMobile: false,
333+
renderer:
334+
'ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)',
335+
});
336+
expect(result.type).toBe('BLOCKLISTED');
337+
expect(result.tier).toBe(0);
338+
expect(result.gpu).toBe('swiftshader');
339+
});
340+
328341
test('Apple Silicon desktop Safari — tier-3 BENCHMARK with m-series label', async () => {
329342
// Safari returns 'Apple GPU' uniformly for M1–M5 with no chip-level
330343
// discrimination available from WebGL. Base M1 already hits the tier-3
@@ -403,7 +416,7 @@ test('Apple GPU on mobile does NOT take the desktop tier-3 path', async () => {
403416
},
404417
{
405418
expected: {
406-
gpu: 'google swiftshader',
419+
gpu: 'swiftshader',
407420
},
408421
input: {
409422
isMobile: false,

0 commit comments

Comments
 (0)