{"record":{"id":"9c1e4bd230e651f6","repo":"mrdoob/three.js","slug":"three-renderer-render-called-before-the-backen","errorCode":null,"errorMessage":"THREE.Renderer: .render() called before the backend is initialized. Use \"await renderer.init();\" before rendering.","messagePattern":"THREE\\.Renderer: \\.render\\(\\) called before the backend is initialized\\. Use \"await renderer\\.init\\(\\);\" before rendering\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/renderers/common/Renderer.js","lineNumber":1503,"sourceCode":"\t * Renders the scene or 3D object with the given camera. This method can only be called\n\t * if the renderer has been initialized. When using `render()` inside an animation loop,\n\t * it's guaranteed the renderer will be initialized. The animation loop must be defined\n\t * with {@link Renderer#setAnimationLoop} though.\n\t *\n\t * For all other use cases (like when using on-demand rendering), you must call\n\t * {@link Renderer#init} before rendering.\n\t *\n\t * The target of the method is the default framebuffer (meaning the canvas)\n\t * or alternatively a render target when specified via `setRenderTarget()`.\n\t *\n\t * @param {Object3D} scene - The scene or 3D object to render.\n\t * @param {Camera} camera - The camera to render the scene with.\n\t */\n\trender( scene, camera ) {\n\n\t\tif ( this._initialized === false ) {\n\n\t\t\tthrow new Error( 'THREE.Renderer: .render() called before the backend is initialized. Use \"await renderer.init();\" before rendering.' );\n\n\t\t}\n\n\t\tthis._renderScene( scene, camera );\n\n\t}\n\n\t/**\n\t * Returns whether the renderer has been initialized or not.\n\t *\n\t * @readonly\n\t * @return {boolean} Whether the renderer has been initialized or not.\n\t */\n\tget initialized() {\n\n\t\treturn this._initialized;\n\n\t}","sourceCodeStart":1485,"sourceCodeEnd":1521,"githubUrl":"https://github.com/mrdoob/three.js/blob/da05705fa31f02710c19772a2aa70c7454807f0c/src/renderers/common/Renderer.js#L1485-L1521","documentation":"Thrown by Renderer.render() when the backend has not been initialized. The WebGPU/Nodes Renderer initializes asynchronously; you must await renderer.init() (or any async method that triggers init) before calling render(). Calling render() on an uninitialized renderer has no valid backend to dispatch to.","triggerScenarios":"Constructing new Renderer/backend and immediately calling renderer.render() in a synchronous code path without awaiting init; calling render before the first async operation completed.","commonSituations":"Switching from WebGLRenderer (synchronously ready) to the async Renderer/WebGPURenderer and forgetting to await init; framework lifecycle hooks that render before the init promise resolves; top-level module code that renders synchronously.","solutions":["Call await renderer.init() once after construction, before any render().","Gate your render loop: do not start requestAnimationFrame until the init promise resolves.","Use async/await or .then() on init before the first render call.","If using a framework, perform init in an async setup/effect and render afterwards."],"exampleFix":"// before\nconst renderer = new THREE.WebGPURenderer();\nrenderer.render( scene, camera ); // throws: not initialized\n\n// after\nconst renderer = new THREE.WebGPURenderer();\nawait renderer.init();\nrenderer.render( scene, camera );","handlingStrategy":"validation","validationCode":"await renderer.init();\nrenderer.render( scene, camera ); // safe to call now","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always await renderer.init() before the first render.","Start the requestAnimationFrame loop only after init resolves.","Treat the async Renderer as async throughout your setup.","Guard render entry points with an initialized flag."],"tags":["renderer","initialization","async","webgpu","lifecycle"],"backgroundTag":null,"analyzedSha":"da05705fa31f02710c19772a2aa70c7454807f0c","analyzedAt":"2026-08-12T22:51:37.160Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}