godot-tiled-importer icon indicating copy to clipboard operation
godot-tiled-importer copied to clipboard

Crash when using a 500x500 tilemap

Open innocenzi opened this issue 4 years ago • 8 comments

Plugin version I'm using the latest version (commit hash 8cb54dbc2f14387758d0bbf979921c7c6eb19ad6), and Godot 3.1.1. I started using the plugin from the asset library but it wasn't working, so I updated from the Git.

Issue description So, what's happening is that Godot crashes when I import a tilemap of 500x500 or larger. I tested with 100x100, 200x200, until 500x500, where it just crashes, and I can't seem to be able to get a log.

Steps to reproduce

  • Create a new project
  • Create a scene with a Node2D
  • Create a map in Tiled with a tile size of 32x32 and a map size of 500x500, orthogonal, with CSV format
  • Import it in Godot
  • Drag the .tmx under the Node2D
  • Godot crashes

Repeat the same with a 400x400 and Godot won't crash.

Sample map or tileset https://github.com/hawezo/tiled-godot-crashtest

innocenzi avatar Jul 20 '19 13:07 innocenzi

I think it might be an issue with Godot itself, and not the plugin. See https://github.com/godotengine/godot/issues/29238.

innocenzi avatar Jul 20 '19 13:07 innocenzi

I never optimized this for memory since I've never needed it, so there might be some room to improve. But if the issue is in Godot itself there's not much that could be done here.

vnen avatar Jul 20 '19 19:07 vnen

I believe the proper way to implement this in a 3.1 Godot world is to use a Tile_Atlas instead of defining each Tiled tile as a single tile. I've tested large tile atlases in the Editor and I believe it uses a separate code path to render those, and can handle 600+ tiles.

I'm currently working on a modification to verify this.

ChainedLupine avatar Sep 10 '19 20:09 ChainedLupine

Yeah, I re-wrote the importer to use Tile_Atlas and all the weird Tileset Editor problems went away. Tile selection is a bit more awkward (have to click the atlas, then the sub-tile, and it resets your selection when changing the tile transform), but I don't care as the point is to do all of my tile editing in Tiled anyway. :)

I also split the tileset generation out so it no longer embeds the Godot TileSets in the TileMaps (but instead creates external resources) and that has solved all of the problems with updates to the tilemaps not showing up in the editor.

ChainedLupine avatar Sep 14 '19 22:09 ChainedLupine

@ChainedLupine That sounds great! Any insight into how you accomplished that? Looking at the code, I figure what you describe would require extensive changes, but maybe I'm overthinking it.

ThewDev avatar Oct 23 '19 12:10 ThewDev

@ChainedLupine Maybe you could share your changes. 😊

gjatzlau avatar Nov 02 '19 17:11 gjatzlau

I tried to import a 500x500 map with an embedded tileset. The import appeared to work but Godot crashed without any report, when I attempted to use the map.

yuppox avatar Jan 05 '20 10:01 yuppox

@ChainedLupine Maybe you could share your changes. 😊

I made a lot of game-specific changes so my code isn't public-ready. (For example, since I modified the per-image per-tile code, I am unsure if it works as I only use tile atlases in my game. I also redid the entire tileset import system.)

It's working well enough for my individual use-case but it's not worth a full pull request. I will try to put one together and test it when I have time.

ChainedLupine avatar Jan 05 '20 21:01 ChainedLupine