diff --git a/README.md b/README.md index d129f7a..8b65295 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/index.ts b/src/index.ts index 6dc89c0..45bb22a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); diff --git a/src/internal/blocklistedGPUS.ts b/src/internal/blocklistedGPUS.ts index da4d717..9570283 100644 --- a/src/internal/blocklistedGPUS.ts +++ b/src/internal/blocklistedGPUS.ts @@ -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', diff --git a/test/index.test.ts b/test/index.test.ts index 78118c8..bb22933 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -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 @@ -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,