Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected scene tile recreation after calling update_internals() #93076

Open
timothyqiu opened this issue Jun 12, 2024 · 1 comment
Open

Unexpected scene tile recreation after calling update_internals() #93076

timothyqiu opened this issue Jun 12, 2024 · 1 comment

Comments

@timothyqiu
Copy link
Member

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

@KoBeWi
Copy link
Member

KoBeWi commented Jun 12, 2024

The deferred update probably comes from #89493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants