fix(viewer): skip post-processing pipeline when WebGPU is unavailable#234
Open
b9llach wants to merge 1 commit intopascalorg:mainfrom
Open
fix(viewer): skip post-processing pipeline when WebGPU is unavailable#234b9llach wants to merge 1 commit intopascalorg:mainfrom
b9llach wants to merge 1 commit intopascalorg:mainfrom
Conversation
`RenderPipeline`, SSGI, and the denoise TSL node imported from `three/webgpu` and `three/tsl` are all WebGPU-only. On a browser without `navigator.gpu`, the WebGPURenderer falls back to WebGL2, and attempting to build the TSL post-processing pipeline either throws or produces broken output — the scene renders for a few frames, then goes black as the 3-attempt retry loop fights the direct-render fallback path in `useFrame`. This sets `hasPipelineErrorRef.current = true` at pipeline setup time when `navigator.gpu` is undefined, so `useFrame` takes the existing direct `renderer.render(scene, camera)` path exclusively and never tries to build the broken TSL pipeline. No behavioural change in WebGPU mode — the guard only fires when the WebGPU API is literally not exposed by the browser. The rare edge case of `navigator.gpu` being defined but device creation failing at runtime still falls through the existing try/catch unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a browser where
navigator.gpuis undefined (Safari without the WebGPU flag, most iOS WebKit builds, older Chrome on machines without a WebGPU device), theWebGPURendererfalls back to WebGL2. When that happens, the TSL-based post-processing pipeline inpost-processing.tsxcan't be built —RenderPipeline,ssgi,denoise, and the MRT pass setup fromthree/webgpu/three/tslare all WebGPU-only.The existing error path in
useFrameretries the pipeline up to 3 times with a 500ms delay between attempts. Each retry fights the direct-render fallback, and the net result is "scene renders for about a second, then goes black and stays black."Fix
Add a short-circuit at the top of the pipeline-setup
useEffect:When the guard fires,
hasPipelineErrorRef.currentis set at setup time, souseFrame's existingif (hasPipelineErrorRef.current || !renderPipelineRef.current)branch takes the directrenderer.render(scene, camera)path and never attempts the TSL pipeline. The retry loop is skipped entirely.Scope
navigator.gpuis defined, the guard passes, nothing changes. SSGI, outlines, denoise all still run.try { … } catchblock exactly like today.Pairs well with #233 (await
renderer.init()in the gl factory), which fixes the direct-render path itself so the fallback actually works in WebGL2.Test
On a WebGL2-only browser:
[viewer] WebGPU unavailablewarning, scene renders without post FX, stays rendered.