Skip to content

Show a clear error when WebGPU is unavailable during SOG and viewer export#956

Merged
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:soggpu-dev
Jul 8, 2026
Merged

Show a clear error when WebGPU is unavailable during SOG and viewer export#956
slimbuck merged 2 commits into
playcanvas:mainfrom
slimbuck:soggpu-dev

Conversation

@slimbuck

@slimbuck slimbuck commented Jul 8, 2026

Copy link
Copy Markdown
Member

Fixes #934

Exporting to SOG (or the HTML viewer, which bundles SOG) requires a WebGPU device for spherical harmonic k-means clustering. On systems where WebGPU is unavailable — no navigator.gpu, or requestAdapter() returning null, as on the reporter's Ubuntu/Chrome setup — the export failed with the cryptic popup "Cannot read properties of null (reading 'features') while saving file" under an "Error Loading File" header.

createGpuDevice now throws a dedicated WebGPUUnavailableError for every way device creation can fail: missing navigator.gpu, createDevice() throwing on a null adapter, and createDevice() resolving without creating a device (blocklisted adapters). The underlying error is still logged to the console for debugging. The export handler catches this error type and shows a localized, actionable message instead of the raw error text: "This export requires WebGPU, which is not available in this browser. Please try a recent version of Chrome, Edge or Safari." The new string is translated in all nine locales.

Verified in the browser by simulating both failure modes (removing navigator.gpu, and stubbing requestAdapter() to resolve null, which reproduces the exact TypeError from #934), and by confirming a normal SOG export still succeeds with a working adapter.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves SOG / viewer export failure handling when WebGPU is unavailable by introducing a dedicated error type during GPU device creation and showing a localized, actionable popup message instead of a cryptic TypeError.

Changes:

  • Add WebGPUUnavailableError and throw it from createGpuDevice() for multiple WebGPU device-creation failure modes.
  • Catch WebGPUUnavailableError in the export flow to show a localized “WebGPU unavailable” message.
  • Add the new localized string to all nine supported locales.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
static/locales/zh-CN.json Adds localized popup.webgpu-unavailable message (Chinese).
static/locales/ru.json Adds localized popup.webgpu-unavailable message (Russian).
static/locales/pt-BR.json Adds localized popup.webgpu-unavailable message (Brazilian Portuguese).
static/locales/ko.json Adds localized popup.webgpu-unavailable message (Korean).
static/locales/ja.json Adds localized popup.webgpu-unavailable message (Japanese).
static/locales/fr.json Adds localized popup.webgpu-unavailable message (French).
static/locales/es.json Adds localized popup.webgpu-unavailable message (Spanish).
static/locales/en.json Adds localized popup.webgpu-unavailable message (English).
static/locales/de.json Adds localized popup.webgpu-unavailable message (German).
src/splat-serialize.ts Introduces WebGPUUnavailableError and improves WebGPU device creation error signaling for SOG/viewer export.
src/file-handler.ts Shows a friendly, localized popup message when export fails due to WebGPU unavailability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/file-handler.ts
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@slimbuck slimbuck marked this pull request as ready for review July 8, 2026 16:42
@slimbuck slimbuck requested a review from a team July 8, 2026 16:42
@slimbuck slimbuck merged commit bcfa038 into playcanvas:main Jul 8, 2026
2 checks passed
@slimbuck slimbuck deleted the soggpu-dev branch July 8, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot read properties of null (reading 'features') while saving file

2 participants