Repository navigation
Description
Which package is this bug report for?
graphics-3d
Issue description
When the game's container has no size (in the editor: switch from the Game tab to the Scene tab while the game runs), the canvas becomes 0×0, but Graphics3DLibrary keeps calling renderer.render(scene, camera) every tick. WebGPU rejects the 0-size swapchain texture, and the rest of the frame fails with it, so the console gets 5 errors per frame (60 fps → ~300/s; 12k+ after a short while):
THREE.WebGPURenderer: Uncaptured WebGPU GPUValidationError: Could not create a swapchain texture of size 0.
… [Invalid Texture] is invalid due to a previous error. - While calling [Invalid Texture].CreateView(…)
… [Invalid TextureView] is invalid due to a previous error. - While validating colorAttachments[0] …
… [Invalid CommandBuffer …] is invalid due to a previous error. - While calling [Queue].Submit(…)
… The texture size ([Extent3D width:0, height:0, depthOrArrayLayers:1]) or mipLevelCount (1) is empty.
The game itself keeps running, and rendering comes back once the container has a size again. graphics-2d doesn't have this problem: Konva accepts a 0-size stage.
Cause: _applyViewport (and _followContainer) size the renderer to the visible area, 0×0 here, and _draw() renders whatever the size.
Suggested fix: skip the render when the canvas has no area, in _draw(), so __run, the paused-resize redraw and graphics-capture all get it:
private _draw(): void {
const { width, height } = this.renderer.domElement;
if (!width || !height) return; // hidden game (another editor tab, collapsed container): nothing to show
if (this._customRender) this._customRender();
else this._drawDefault();
}
graphics-capture should then still answer, with an empty string, instead of a blank PNG. Add a test: with a 0×0 viewport, __run doesn't call renderer.render.
Code sample
Versions
@nanoforge-dev/graphics-3d 3.0.0, three 0.187.0, @nanoforge-dev/cli 3.0.4, @nanoforge-dev/editor 1.1.0
Chrome (WebGPU backend), macOS
Issue priority
High (immediate attention needed)
I have tested this issue on a development release
No response
Activity