From bfe6e204365e373e5b20201570ebdd86ff6b6780 Mon Sep 17 00:00:00 2001 From: Gregg Tavares Date: Tue, 16 Jan 2024 15:18:51 -0800 Subject: [PATCH] handle requestAdapter returning null better I'm not sure this is better? The old way printed errors about trying to look at properties of null. The new way says "WebGPU looks disabled". This means `navigator.gpu` exists but `requestAdapter` returned null for all cases --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index f547bac..22c81ca 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,3 @@ - function makeTable(members, defaults, table) { const result = {}; for (const [k, v] of Object.entries(table)) { @@ -456,8 +455,8 @@ async function checkWorkers() { function adapterOptionsToDesc(requestAdapterOptions, adapter) { const parts = [ - ...(adapter.isFallbackAdapter ? ['fallback'] : []), - ...(adapter.isCompatibilityMode ? ['compatibilityMode'] : []), + ...(adapter?.isFallbackAdapter ? ['fallback'] : []), + ...(adapter?.isCompatibilityMode ? ['compatibilityMode'] : []), ]; return parts.length > 0 ? parts.join(' ')