Description
Tested versions
Reproducible in 4.4.1stable, 4.5beta1
System information
Godot v4.4.1.stable - Windows 11 (build 22631) - Multi-window, 2 monitors - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 32.0.15.6094) - AMD Ryzen 7 5800X 8-Core Processor (16 threads)
Issue description
Using create_tile on TileSetAtlasSource can cause unpredictable errors and crashes. These do not occur on the main thread.
Steps to reproduce
This code attached to a node will trigger crashes, and occasionally these errors:
<C++ Source> servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:615 @ canvas_texture_set_channel()
<C++ Error> Method/function failed. Returning: false
<C++ Source> core/object/object.cpp:1490 @ is_connected()
<C++ Error> Condition "!p_callable.is_valid()" is true. Returning: ERR_INVALID_PARAMETER
<C++ Source> core/object/object.cpp:1418 @ connect()
Although icon.svg is used as an example, using larger textures such as 512x512 to fill in tiles this way can cause these types of errors (where x and y are not consistent in value or frequency):
E 0:00:00:703 get_tile_texture_region: TileSetAtlasSource has no tile at (x, y). <C++ Error> Condition "!tiles.has(p_atlas_coords)" is true. Returning: Rect2i() <C++ Source> scene/resources/2d/tile_set.cpp:5303 @ get_tile_texture_region()
extends Node2D
var thread: Thread = Thread.new()
func _ready() -> void:
thread.start(create_tiles)
func create_tiles():
var new_tileset_atlas_source: TileSetAtlasSource
for i in range(64):
new_tileset_atlas_source = TileSetAtlasSource.new()
new_tileset_atlas_source.texture = preload("res://icon.svg")
for x in 8:
for y in 8:
new_tileset_atlas_source.create_tile(Vector2i(x, y))
Minimal reproduction project (MRP)
N/A