BabylonJS/Babylon.js · error
FrameGraphGUITask: targetTexture is required
Error message
FrameGraphGUITask: targetTexture is required
What it means
FrameGraphGUITask.record() renders the GUI into a frame-graph texture pass. Before recording, it verifies that a target texture handle has been assigned; without one the render pass has nowhere to write and downstream handle resolution (resolveDanglingHandle) would be meaningless, so the library throws immediately.
Source
Thrown at packages/dev/gui/src/2D/FrameGraph/guiTask.ts:69
} else {
adt = AdvancedDynamicTexture.CreateFullscreenUI(name, undefined, { useStandalone: true, scene: frameGraph.scene });
}
this._adt = adt;
this.outputTexture = this._frameGraph.textureManager.createDanglingHandle();
}
public override isReady() {
return this._adt.guiIsReady() && this._adt._layerToDispose!.isReady();
}
public override getClassName(): string {
return "FrameGraphGUITask";
}
public record(): void {
if (this.targetTexture === undefined) {
throw new Error("FrameGraphGUITask: targetTexture is required");
}
this._frameGraph.textureManager.resolveDanglingHandle(this.outputTexture, this.targetTexture);
const pass = this._frameGraph.addRenderPass(this.name);
pass.setRenderTarget(this.outputTexture);
pass.setExecuteFunc((context) => {
this._adt._checkUpdate(null);
context.render(this._adt._layerToDispose!);
});
const passDisabled = this._frameGraph.addRenderPass(this.name + "_disabled", true);
passDisabled.setRenderTarget(this.outputTexture);
passDisabled.setExecuteFunc((_context) => {});
}
View on GitHub (pinned to 0592b347b8)
Solutions
- Set guiTask.targetTexture = <texture handle> (e.g. the output of frameGraph.createRenderTargetTexture(...) or another task's output) before calling record().
- Verify task wiring order: the texture-producing task must be created and its output assigned to the GUI task before the record phase.
- Add a guard/assert in your pipeline setup that all render tasks have a target texture before frameGraph.build() / execute().
Example fix
// before
const guiTask = new FrameGraphGUITask("gui", frameGraph, adt);
frameGraph.addTask(guiTask);
guiTask.record(); // throws
// after
const guiTask = new FrameGraphGUITask("gui", frameGraph, adt);
const target = frameGraph.createRenderTargetTexture("guiTarget", { size: { width, height } });
guiTask.targetTexture = target;
frameGraph.addTask(guiTask);
guiTask.record(); Defensive patterns
Strategy: validation
Validate before calling
if (guiTask.targetTexture === undefined) {
throw new Error("GUI task must have targetTexture set before record()");
}
guiTask.record(); Type guard
function hasTargetTexture(t: FrameGraphGUITask): boolean {
return t.targetTexture !== undefined;
} Try / catch
try {
guiTask.record();
} catch (e) {
if (e instanceof Error && e.message.includes("targetTexture is required")) {
console.error("FrameGraphGUITask not wired to a texture:", e);
} else {
throw e;
}
} Prevention
- Assign targetTexture immediately after constructing the task, before addTask/record.
- Write a pipeline-setup validator that asserts every render task has a target texture before frameGraph.build().
- Keep texture creation and task wiring in one setup function to avoid ordering mistakes.
When it happens
Trigger: Calling frameGraphTask.record() on a FrameGraphGUITask whose targetTexture property is still undefined — i.e. the task was constructed and added to the FrameGraph but targetTexture (typically the output of a texture creation task) was never set.
Common situations: Building a FrameGraph pipeline and forgetting to wire the GUI task to a render target texture; copy-pasting GUI task setup from a non-framegraph flow; ordering mistakes where the texture task has not yet been built/consumed before GUI record is invoked.
Related errors
- NodeRenderGraphInputBlock: Creation options are missing for
- FrameGraphClearTextureTask ${this.name}: the depth texture (
- FrameGraphCopyToBackbufferColorTask "${this.name}": sourceTe
- FrameGraphCopyToTextureTask "${this.name}": sourceTexture an
- FrameGraphGenerateMipMapsTask ${this.name}: targetTexture is
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/268c9b24b41adc6e.
Report an issue: GitHub.