Skip to content

Unexpected scene tile recreation after calling update_internals() #93076

Open
@timothyqiu

Description

@timothyqiu

Tested versions

4.2.2.stable / 4.3.beta1

System information

Arch Linux

Issue description

It's documented that scene tiles may not be available when the tilemap is ready, and users can call update_internals() to force immediate update.

For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a [TileSetScenesCollectionSource] may be initialized after their parent. This is only queued when inside the scene tree.
To force an update earlier on, call [method update_internals].

Calling update_internals() does force create the scene tiles. But these scene tile instances seem temporary. Another deferred internal update (caused by TileSetAtlasSource::_update_padded_texture) will soon destroy these instances after _ready().

This seems like a bug, because scene tile instances are not related to the TileSetAtlasSource texture update. They should not be recreated.

Steps to reproduce

Create a TileMapLayer and draw a scene tile.

Run the MRP. Sample output:

Scene tiles are not created when _ready: []
Call update_internals()
Created <Node2D#28823258389>
Now scene tiles are created: [SceneTile:<Node2D#28823258389>]
Now exit _ready
Created <Node2D#29041362196>
In a deferred call: [SceneTile:<Node2D#28823258389>, @Node2D@2:<Node2D#29041362196>]
Destroyed SceneTile:<Node2D#28823258389>

Minimal reproduction project (MRP)

update-internals.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions