fix(web): fall back to the web tools view when no WebGPU adapter exists
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled

The native desktop canvas needs a WebGPU adapter; without one it stayed black
and the web tools below were unreachable. App.tsx now probes
navigator.gpu.requestAdapter() at startup, hides the native canvas, shows the
web business-tools view and a dismissible notice.

Diagnosis behind it: no flags -> no adapter (black canvas); --enable-unsafe-webgpu
-> SwiftShader adapter, stable over a 10-minute headed soak;
--enable-unsafe-webgpu --enable-features=Vulkan -> NVIDIA adapter renders but the
GPU process exits 133 after ~7 minutes under interaction, while a minimal WebGPU
control page stays stable on the same configuration.

The full frozen Clip suite passes 28/28 after the change
(tests/golden/CLIP-HEADED-20261205); acceptance stays NOT_CLAIMED.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-12-05 02:15:27 +08:00
parent 11a69f6354
commit 65d086a55b
37 changed files with 3554 additions and 4 deletions

View File

@@ -6039,6 +6039,7 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
const [localRetryPending,setLocalRetryPending]=useState<{expectedActiveObjectId?:string;context:NativeWorkflowContext;command:Extract<NativeSessionCommand,{kind:'invoke'}>}|null>(null);
const localInvokeAbortRef = useRef<AbortController | null>(null);
const [gpuSurfaceOpen,setGPUSurfaceOpen]=useState(course?false:true);
const [webgpuFallback,setWebgpuFallback]=useState(false);
const [nativeCanvasReady,setNativeCanvasReady]=useState(false);
const [nativeCanvasEpoch, setNativeCanvasEpoch] = useState(0);
useEffect(() => {
@@ -6046,6 +6047,26 @@ export function App({localOnly=false,course,teach}:{localOnly?:boolean;course?:A
* attached, so readiness must survive it; only a lost Main or engine does. */
if (!localOnly || !snapshot) setNativeCanvasReady(false);
}, [localOnly, gpuSurfaceOpen, snapshot]);
useEffect(() => {
/* The native desktop canvas needs a WebGPU adapter; without one it stays
* black and the web tools below are unreachable, so fall back and say why. */
if (!localOnly || course) return;
if (!navigator.gpu) {
setGPUSurfaceOpen(false);
setWebgpuFallback(true);
setEngineStatus('当前浏览器未启用 WebGPU:已切换到 Web 业务工具视图');
return;
}
let disposed = false;
navigator.gpu.requestAdapter().then((adapter) => {
if (!disposed && !adapter) {
setGPUSurfaceOpen(false);
setWebgpuFallback(true);
setEngineStatus('当前浏览器没有可用的 WebGPU 适配器:已切换到 Web 业务工具视图');
}
}).catch(() => {});
return () => { disposed = true; };
}, [localOnly, course]);
const [nativeTimelinePlaying, setNativeTimelinePlaying] = useState(false);
const [nativeRecoveryUseScripts, setNativeRecoveryUseScripts] = useState(false);
const [nativeTimelinePumpError, setNativeTimelinePumpError] = useState(false);
@@ -11413,7 +11434,7 @@ else:
<button type="button" disabled={delivery.busy} onClick={() => setFailedNativeFiles(current => current.filter(item => item !== delivery))}>忽略</button></div>
</div>)}
</aside>}
{localOnly && snapshot && webClientRef.current ? <><button type="button" data-testid="desktop-file-transfer-entry" aria-label="文件传输" onClick={()=>setGPUSurfaceOpen(true)} style={{position:'fixed',top:6,right:260,zIndex:60}}>文件传输</button><section aria-label="Blender 桌面" data-native-canvas-open={gpuSurfaceOpen ? "true" : "false"} style={{position:'fixed',top:'var(--native-desktop-top,0px)',left:0,right:0,bottom:0,display:'flex',visibility:gpuSurfaceOpen?'visible':'hidden',pointerEvents:gpuSurfaceOpen?'auto':'none',zIndex:gpuSurfaceOpen?20:-1,overflow:'hidden'}}><button type="button" data-testid="native-web-tools-toggle" aria-label="切换到 Web 业务工具" onClick={()=>{cancelNativeGesture();localInvokeAbortRef.current?.abort();setLocalInvokePending(null);setLocalRetryPending(null);setGPUSurfaceOpen(false);}} style={{position:'fixed',top:6,right:110,zIndex:30}}>Web 业务工具</button><WasmGPUCanvas key={nativeCanvasEpoch} client={webClientRef.current} active={gpuSurfaceOpen} playing={nativeTimelinePlaying} onCleanup={cleanup => { nativeCanvasCleanupRef.current = cleanup; }} onModalActive={active => setNativeModalActive(active)} onApplied={result => {
{localOnly && snapshot && webClientRef.current ? <>{webgpuFallback ? <div role="status" data-testid="webgpu-fallback-notice" style={{position:'fixed',left:12,bottom:40,zIndex:70,background:'#33261a',border:'1px solid #8a6a3a',color:'#f2e6d6',padding:'6px 10px',borderRadius:4,fontSize:12,maxWidth:520}}>当前浏览器没有可用的 WebGPU 适配器:原生桌面画布不可用,已切换到 Web 业务工具视图。<button type="button" onClick={()=>setWebgpuFallback(false)} style={{marginLeft:8}}>知道了</button></div> : null}<button type="button" data-testid="desktop-file-transfer-entry" aria-label="文件传输" onClick={()=>setGPUSurfaceOpen(true)} style={{position:'fixed',top:6,right:260,zIndex:60}}>文件传输</button><section aria-label="Blender 桌面" data-native-canvas-open={gpuSurfaceOpen ? "true" : "false"} style={{position:'fixed',top:'var(--native-desktop-top,0px)',left:0,right:0,bottom:0,display:'flex',visibility:gpuSurfaceOpen?'visible':'hidden',pointerEvents:gpuSurfaceOpen?'auto':'none',zIndex:gpuSurfaceOpen?20:-1,overflow:'hidden'}}><button type="button" data-testid="native-web-tools-toggle" aria-label="切换到 Web 业务工具" onClick={()=>{cancelNativeGesture();localInvokeAbortRef.current?.abort();setLocalInvokePending(null);setLocalRetryPending(null);setGPUSurfaceOpen(false);}} style={{position:'fixed',top:6,right:110,zIndex:30}}>Web 业务工具</button><WasmGPUCanvas key={nativeCanvasEpoch} client={webClientRef.current} active={gpuSurfaceOpen} playing={nativeTimelinePlaying} onCleanup={cleanup => { nativeCanvasCleanupRef.current = cleanup; }} onModalActive={active => setNativeModalActive(active)} onApplied={result => {
const client = webClientRef.current, project = projectIdRef.current;
const changed = result.snapshot.revision !== snapshot.revision;
applyNativeScene(result, changed);