Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGPURenderer causes warning: render() called before the backend is initialized #3403

Open
verekia opened this issue Nov 26, 2024 · 1 comment
Assignees

Comments

@verekia
Copy link
Contributor

verekia commented Nov 26, 2024

R3F v8 and v9 both cause the following warning:
THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead.

Reproduction:

@krispya
Copy link
Member

krispya commented Dec 6, 2024

@CodyJasonBennett provided a workaround here:

  const [frameloop, setFrameloop] = useState('never')

  return (
    <Canvas
      frameloop={frameloop}
      gl={canvas => {
        const renderer = new WebGPURenderer({
          canvas,
          powerPreference: 'high-performance',
          antialias: true,
          alpha: true,
        })
        renderer.init().then(() => setFrameloop('always'))
        renderer.xr = { addEventListener: () => {} }
        return renderer
      }}
    >

But ideally we leverage suspense and allow for a promise to be passed into gl such that this works:

<Canvas 
  gl={async (canvas) => {
    const renderer = new WebGPURenderer({
      canvas,
      powerPreference: 'high-performance',
      antialias: true,
      alpha: true,
    });

    await renderer.init();
    // This shouldn't be necessary either
    // renderer.xr = { addEventListener: () => {} };
    return renderer;
  }}
>

@krispya krispya self-assigned this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants