Conversation
|
hi @davepagurek, fn.createStorage = function (dataOrCount) {
if (!this._renderer.createStorage) {
p5._friendlyError(
`createStorage() is only available with the WebGPU renderer. ${webGPUAddonMessage}`,
'createStorage'
);
return;
}
return this._renderer.createStorage(dataOrCount);
}; |
It's good that we already have an FES guard here, but FES doesn't stop execution. It only logs a message and the function returns undefined, so the sketch keeps running. @davepagurek said in the issue that for buildComputeShader, createStorage and createStorageList we should
If someone runs a sketch that uses these functions in a browser without WebGPU, the sketch will still execute, but none of the compute/storage work will actually happen. The user might get an FES message in the console, but the sketch will look like it's running while silently doing nothing. That could be confusing. So I think we should throw an error here instead of only logging one, so the sketch fails at the first WebGPU-only call with a clear message. |
| this._renderer = new renderers[constants.WEBGL](this, w, h, true, ...args); | ||
| this._elements.push(this._renderer); | ||
| this._renderer._applyDefaults(); | ||
| return this._renderer; |
There was a problem hiding this comment.
I think this is what createCanvas() actually does in the code.
So instead of these, we can directly use this.createCanvas(w, h, constants.WEBGL, ...args);
There was a problem hiding this comment.
hmm. yes, thanks for spotting that
| const failed = this._renderer; | ||
| try { | ||
| failed.remove(); | ||
| } catch { |
There was a problem hiding this comment.
I think this also createCanvas() does above, so we can probably remove this one as well?
There was a problem hiding this comment.
yes but we should also remove failed renderer from this._elements, so i think i should put it above in createCanvas()
perminder-17
left a comment
There was a problem hiding this comment.
Hi @skyyash, the code looks good so far. Do you have any test results, a short video or screenshot of the fallback running with WebGPU disabled? That would help me confirm it works end to end.
|
hi @perminder-17 , here is the video... fallback.mp4on using webgpu only functions in non-webgpu renderer, the execution is stopped but the loader keeps running because control never reaches |
Resolves #9175
Changes:
src/core/rendering.jsholds the two fallback paths. The sync path covers a missing addon. It corrects an old check that looked at theselectedRendererinstead of the requested one, so the warning actually fires now. The async path catches a rejectedcontextReadyonly when WEBGPU was requested, removes the failed canvas from_elements, builds a WebGL renderer with the same size and leftover args, and returns it. Other renderers still reject withFailed to create canvas.src/webgpu/p5.RendererWebGPU.jssplits one error into four friendly errors. Missingnavigator.gpu, null adapter, null device, and null canvas context.src/core/environment.jsaddsrendererType. Each constructor (src/core/p5.Renderer.js,src/webgl/p5.RendererGL.jsandsrc/webgpu/p5.RendererWebGPU.js) assigns its type on the renderer and the sketch synchronously, which matters because WebGPU init is async and the old placement leftp2dvisible until the promise resolved.PR Checklist
npm run lintpasses