Skip to content

Commit 0ce5184

Browse files
authored
Viewer v2: Switch back to WebGL as the default for now (#16946)
Unfortunately we've hit some reliability issues with WebGPU + snapshot rendering that are difficult to repro and seem to be timing related. We need to investigate more, but the quick fix to make sure the Viewer is stable is to switch back to WebGL as the default for now. Might wait for @Popov72 availability for deeper investigation. I also added a query param for the Viewer Configurator so that in that context its easy to test both WebGL and WebGPU.
1 parent 7946061 commit 0ce5184

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

packages/tools/viewer-configurator/src/components/babylonViewer/viewer.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,13 @@ export const Viewer: FunctionComponent<{ onViewerCreated: (element: ViewerElemen
4545
})();
4646
}, []);
4747

48-
return <configured-babylon-viewer class="viewerElement" ref={props.onViewerCreated}></configured-babylon-viewer>;
48+
// Allow engine selection through query param for testing. Later we may add an option in the UI for engine selection.
49+
const engineQueryParam: string | null | undefined = new URLSearchParams(window.location.search).get("engine");
50+
const engine = engineQueryParam?.toLowerCase() === "webgl" ? "WebGL" : engineQueryParam?.toLowerCase() === "webgpu" ? "WebGPU" : undefined;
51+
52+
if (engineQueryParam && !engine) {
53+
Logger.Warn(`Invalid engine specified in query param: ${engineQueryParam}. 'webgl' or 'webgpu' expected.`);
54+
}
55+
56+
return <configured-babylon-viewer class="viewerElement" ref={props.onViewerCreated} engine={engine}></configured-babylon-viewer>;
4957
};

packages/tools/viewer/src/viewerFactory.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ const DefaultCanvasViewerOptions = {
2525
* @returns The default engine to use.
2626
*/
2727
export function GetDefaultEngine(): NonNullable<CanvasViewerOptions["engine"]> {
28-
// First check for WebGPU support.
29-
if ("gpu" in navigator) {
30-
// For now, only use WebGPU with chromium-based browsers.
31-
// WebGPU can be enabled in other browsers once they are fully functional and the performance is at least as good as WebGL.
32-
if ("chrome" in window) {
33-
return "WebGPU";
34-
}
35-
}
28+
// TODO: There are some difficult to repro timing issues with WebGPU + snapshot rendering.
29+
// We need to do deeper diagnosis to understand the issues and make this more reliable.
30+
// For now, we will default to WebGL.
31+
32+
// // First check for WebGPU support.
33+
// if ("gpu" in navigator) {
34+
// // For now, only use WebGPU with chromium-based browsers.
35+
// // WebGPU can be enabled in other browsers once they are fully functional and the performance is at least as good as WebGL.
36+
// if ("chrome" in window) {
37+
// return "WebGPU";
38+
// }
39+
// }
3640

3741
return "WebGL";
3842
}

0 commit comments

Comments
 (0)