Skip to content

Commit

Permalink
Handle cases where SharedWorker is not supported at all
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois authored and greggman committed Feb 1, 2024
1 parent b21fa15 commit a5f1762
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ <h1><img src="webgpu-notext.svg" class="logo">WebGPU Report <div class="hide-on-
pointer-events: none;
}
#forkongithub a {
margin-top: 8px;
background: #000;
color: #fff;
text-decoration: none;
Expand Down
12 changes: 10 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function expandMapLike(obj, sort = true) {
function setLikeToTableRows(values) {
return values
? expandSetLike(values)
: [el('tr', {}, [el('td', {colSpan: 2, textContent: 'not yet implemented by this browser'})])];
: [el('tr', {}, [el('td', {colSpan: 2, className: 'nowrap', textContent: 'not yet implemented by this browser'})])];
}

function mapLikeToTableRows(values, sort = true) {
Expand Down Expand Up @@ -435,7 +435,15 @@ async function checkWorkers(workerType) {
obj[feature] = supported ? success : [fail, {className: 'not-supported'}];
};

const worker = new WorkerHelper('worker.js', workerType);
let worker;
try {
worker = new WorkerHelper('worker.js', workerType);
} catch(error) {
addElemToDocument(el('table', { className: 'worker' }, [
el('tbody', {}, setLikeToTableRows(undefined)),
]));
return;
}
const {rAF, gpu, adapter, device, context, offscreen: offscreenSupported, twoD } = await worker.getMessage('checkWebGPU', {canvas: offscreenCanvas}, [offscreenCanvas]);
addSupportsRow('webgpu API', gpu, 'exists', 'n/a');
if (gpu) {
Expand Down

0 comments on commit a5f1762

Please sign in to comment.