Multiple "Viewport Texture must be set to use it" errors

Using latest Godot 4.5.1

I have a scene with an AnimatedSprite2D, and whenever it’s instantiated and added to the node tree the engine fires like 10 of these errors. They don’t seem to affect anything.

Clicking on the error sends me to the script that adds the node. Here’s its code:

extends Control
var files = preload("res://scenes/files.tscn")
var cctv = preload("res://scenes/cctv.tscn")
var files_inst
var cctv_inst
var tab: StringName

func _ready() -> void:
	files_inst = files.instantiate()
	cctv_inst = cctv.instantiate()
	switch_tab('cctv_tab')

func reinstantiate() -> void:
	files_inst = files.instantiate()
	cctv_inst = cctv.instantiate()

func _on_files_button_pressed() -> void:
	switch_tab('files_tab')

func _on_cctv_button_pressed() -> void:
	switch_tab('cctv_tab')

func switch_tab(tab_):
	if tab_ == 'cctv_tab':
		if tab != 'cctv_tab':
			$Node2D.add_child(cctv_inst)
		reinstantiate()
		tab = 'cctv_tab'
		if $Node2D.get_node_or_null('files') != null:
			$Node2D.get_node('files').queue_free()
			
	elif tab_ == 'files_tab':
		if tab != 'files_tab':
			$Node2D.add_child(files_inst)
		reinstantiate()
		tab = 'files_tab'
		if $Node2D.get_node_or_null('cctv') != null:
			$Node2D.get_node('cctv').queue_free()

func _on_close_button_pressed() -> void:
	queue_free()

Are you using a viewport texture?

Not sure, but probably not. Here’s the scene tree:


I do change an AnimatedSprite2D animation. An existing one, not loading any textures.

There’s no AnimatedSprite2D in the scene you posted.


It is there, it’s just in one of the nodes that are instantiated.

Check if there’s viewport texture resource assigned to any of nodes.

What happens if you remove resource preloader node?

Check if there’s viewport texture resource assigned to any of nodes.

Buttons for some reason had empty viewport textures. Thanks!