Tilemap crashes and rendering bugs in Unity 6.4, 6.5, and 6.6 collection post

Gathering information about different bugs related to Tilemaps in Unity 6.4, 6.5, and 6.6 in one post just in case anyone runs into them. One might be a Sprite Atlas bug instead though. If you have any tilemap related posts please drop it here. Just trying to put stuff together to help a set of bug reports I am sending to Unity.

Videos at the bottom showcases the crashes and different issues to help visualize if somethign is happening to other people.

Hard Crashes:

Two possibly different crashes related to the Tilemap have been noticed.
Link to bug report for one with a fix already in review and coming to some Unity versions next week and more the week after. The other one I am writing a bug report on, but it might also be fixed by the first bug fix in progress already.

Unity Issue Tracker - Crash on PolygonCollider2D::CreatePolygonShapes when painting multiple tiles from Tile Palette onto Tilemap

If anyone is getting a crash for tilemaps when painting a tile and the crash is around something that goes into any of the following: RuleMatches for rule tiles, any tile RefreshTile method, or GetTileData check the following to see if the crashes stopped.

  1. You have any scripts that listen to the Tilemap.tilemapTileChanged callback for when tiles changed happening in editor or playmode. Try unregistering event listeners to the Tilemap.tilemapTileChanged callback and see if that helps.

  2. If you got domain and scene reload turned off. - Try turning it on and clearing static reference to any tilemap or tilemap callback than turning it back off and seeing if that helps. - There was a bug in 6.4 and 6.5, but it was fixed in Unity 6.4 beta 8, but an edge case might of been missed.
    Can’t tell for sure, but this might be related to a dictionary or haset in rules tiles not being cleaned up correctly when domaon/scene reload is off. Not sure though what the exact thing was.

Bug report case id was IN-123724 for anyone wondering about this one.
Link to confirmaion by staff it was fixed. Haven’t ran into this one personally after the fix in 6.4 beta 8, but something similar could be happening still.

  1. Check if the crash is happening around
    UnityEditor.Tilemaps.PaintableSceneViewGrid:OnSceneGUI via the editor crash log. Be near the very bottom after a crash. This one is the one I am trying to figure out how to make a good bug report on. Will update post when a work around is found.

  2. If your tiles are from an Aseprite file and you have background import for Aseprite files turned on and your crash log says something related to PreviewImporter that ends up calling UnityEditor.Tilemaps.PaintableSceneViewGrid:OnSceneGUI

Example to show what the crash log could look like when running into the 3rd or 4th mentioned crash scenario.

core::flat_set<math::int3_storage,TilemapPosition_Less,core::allocator<math::int3_storage,0> >::insert
Tilemap::RefreshTileAsset
Tilemap_CUSTOM_RefreshTile
 (wrapper managed-to-native) UnityEngine.Tilemaps.Tilemap:RefreshTile_Injected (intptr,UnityEngine.Vector3Int&)
UnityEngine.Tilemaps.Tilemap:RefreshTile (UnityEngine.Vector3Int)
UnityEngine.Tilemaps.ITilemap:RefreshTile (UnityEngine.Vector3Int)
UnityEngine.Tilemaps.TileBase:RefreshTile (UnityEngine.Vector3Int,UnityEngine.Tilemaps.ITilemap)
(wrapper runtime-invoke) <Module>:runtime_invoke_void__this___Vector3Int_object (object,intptr,intptr,intptr)
[C:\build\output\Unity-Technologies\mono\mono\mini\mini-runtime.c:3445] mono_jit_runtime_invoke 
[C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3068] do_runtime_invoke 
[C:\build\output\Unity-Technologies\mono\mono\metadata\object.c:3115] mono_runtime_invoke scripting_method_invoke
ScriptingInvocation::Invoke
InvokeRefreshTile
Tilemap::RefreshTileAssetsInQueueFromArrays
Tilemap::RefreshTileAssetsInQueue
Tilemap::RefreshAndSyncTileAssetsInQueue<1>
Tilemap::SetEditorPreviewTileAsset
Tilemap_CUSTOM_SetEditorPreviewTileAsset (wrapper managed-to-native) UnityEngine.Tilemaps.Tilemap:SetEditorPreviewTileAsset_Injected (intptr,UnityEngine.Vector3Int&,intptr)
UnityEngine.Tilemaps.Tilemap:SetEditorPreviewTileAsset (UnityEngine.Vector3Int,UnityEngine.Object)
UnityEngine.Tilemaps.Tilemap:SetEditorPreviewTile (UnityEngine.Vector3Int,UnityEngine.Tilemaps.TileBase)
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\GridBrushEditor.cs:906] UnityEditor.Tilemaps.GridBrushEditor:SetTilemapPreviewCell (UnityEngine.Tilemaps.Tilemap,UnityEngine.Vector3Int,UnityEngine.Tilemaps.TileBase,UnityEngine.Matrix4x4,UnityEngine.Color) 
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\GridBrushEditor.cs:593] UnityEditor.Tilemaps.GridBrushEditor:PaintPreview (UnityEngine.GridLayout,UnityEngine.GameObject,UnityEngine.Vector3Int) 
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\GridBrushEditor.cs:232] UnityEditor.Tilemaps.GridBrushEditor:OnPaintSceneGUI (UnityEngine.GridLayout,UnityEngine.GameObject,UnityEngine.BoundsInt,UnityEngine.GridBrushBase/Tool,bool) 
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\PaintableSceneViewGrid.cs:372] UnityEditor.Tilemaps.PaintableSceneViewGrid:CallOnPaintSceneGUI () 
[.\Library\PackageCache\com.unity.2d.tilemap@93aebd748a84\Editor\PaintableSceneViewGrid.cs:91] UnityEditor.Tilemaps.PaintableSceneViewGrid:OnSceneGUI (UnityEditor.SceneView) 

Other posts related to build failing or crashing in editor.

Tilemap not rendering correctly:

If your tiles are not rendering properly in Unity 6.5 or newer check sprite atlas settings. After updating to Unity 6.5 for some reason Sprite Atlas in editor started malforming my tile sprites. I need to see what all changed for Sprite Atlas in 6.4 and 6.5.

There honestly is more to the issue outside of Sprite Atlas, but wanted to share a possible thing to check. One of the videos at the bottom shows off the sprite corruption issue. This happens when dragging the sprite into scene and when making the sprite a tile it gets worse.

Another issue was tiles were being painted, but the sprites were coming up null on the grid position where the tile was painted at. Check the last video at the bottom of the post for examples on that and how to see if this is a problem you could be running into.

Link to another thread tilemaps not rendering.

Videos

Jet brains opens randomly in the first video because I have certain exceptions that auto open it and tries to log it. This video crash is caused by Tilemap.onTilemapTilesChanged. I was making a custom PhysicsShape for Tilemap using the PhysicsCore2D API and listened to the callback when tiles changed to update the Tilemap PhysicsShape and PhyiscsBody. The tile changed queue in Unity’s RefreshTileAssetsInQueueFromArrays method was causing a native crash for an index of a tile that was out of the range of the array for tiles needing synced.

This video showcases a possible reason some Tilemap sprites don’t render correctly. Turning off Sprite atlas v2 in editor for Unity 6.5 fixed this issue for me at least. Sometimes the tile just didn’t render anything at all.

This video shows a bug that was fixed already in Unity 6.4 beta 8, but showcasing it for anyone who is still running into it. Tiles were trying to set their sprites to null. This is a hard crash example.

Sorry @ChuanXin to ping you, but you are the only staff member in forums I have seen invoved in this area of work that works on the Tilemap stuff. Hope this helps a little bit.

I have two different bug reports and small projects coming to Unity via the bug reporter. Will edit this post with their case ids to make life easier for anyone reading this when I get the bug report confirmation numbers.

May I request for a repro project please? Will take a look at the earliest.

Thank you for your effort! All of these is very helpful, and every bug report helps!

@Venkify @ChuanXin
I managed to get a smaller project repo sent with a new bug report that has three videos showing off the crash and sprite corruption. Also typed out step by step instructions on how to reprouce both the tilemap crash and the sprite corruption in the reports

Bug report id is IN-139426. Please note I had to embed a couple of my custom packages that was originally hosted on GitHub, so there might be a couple non-blocking errors only on project start up related to UXML schema file definitions needing updated. They just clear away in the console. The packages are currently in alpha state, but the project I pushed up with the bug report was playable and had no issues.

If there is any issues I can update the bug report and add more details.
Hope this helps out in any way.

Many thanks for submitting the report with repro. Really appreciate it as it helps us to narrow down the issue and take a deeper look. Taking a look at it now. Will post an update asap.
Apologies for any inconvenience this may have caused.

Thank you! We have managed to reproduce the issues you have mentioned with the bug report and will look into fixes for them!

If you need any extra information on top of the bug report or more cases where it can happen I got a lot of videos and examples that can show how to make it happen.

Thank you for this. This crash has been the biggest headache in testing new betas and alphas. Sadly I would finish making part of a map and lose the entire set of changes before I can even open git to push the changes. Made it a bit harder to debug and figure out the exact issue as well.

Note don’t worry about if it caused any issues. The two projects I was testing the Unity betas and alphas in for 2D games are used for self learning and made just to try out new Unity features and API. For the most part throw away projects just to try new stuff out in.

Heads up another user also made a post about issues related to Tilemap.tilemapTileChanged not working when using changing multiple tiles at once. Not sure if it is also related to the crash since it seems the common factor for a lot of the crashes are related to callbacks done with Tilemap.tilemapTileChanged.

Tilemap.tilemapTileChanged not working for multiple tiles - Unity Engine - Unity Discussions

Thanks, really appreciate it. The bug report is clear and detailed. Issue with SpriteAtlas has been fixed and hopefully will land as soon as possible. Will post an update once it lands.

@ChuanXin
Wanted to let you know in Unity 6.5 beta 4 the crashes were lowered by a lot.
I was still able to get a crash in it, but it took a lot longer to run into a crash and was only able to get it to crash on certain tiles now instead of painting any tile.

Edit: Not sure what are the differences between the two of them, but tried Unity 6.6 alpha 3 and so far I can not get it to crash at all after the other fix for tilemaps was implemented. Currently now only able to get a crash on Unity 6.5.

Also some of the rendering issues related to previewing tiles when painting seem to be fixed as well. No longer losing rendering of entire tilemap layers.

@Jonathan-Westfall-8Bits

Thank you for letting us know!

Just an update for the issues here, there will be another fix for the RefreshTile crashes in Unity 6000.4.4f1 and Unity 6000.5.0b5. The SpriteAtlas fix will be landing soon and we will update here with the fix version.

Actually got an email about the bug report being inmiddle of review and being processed this morning.

Thank you both for all the help. These crashes were starting to be a bit of a problem time wise because of lost progress. We have been doing test projects to check the viability of starting a new project in Unity 6.5 and almost decided not to due to the a few bugs, but seems all of them are being fixed.

Note we chose 6.5 and not 6.3 mainly because of

  1. Physics Core 2D module introduction - start with it now so we don’t have to refactor for CoreCLR later in Unity 6.8. - I made a complete Metroidvania 2D package with the PhysicsShape/PhysicsBody API and didn’t want to refactor over 100 scripts later.

  2. Visual Element references.

  3. The updated API for providing a LightDataProvider for creating custom 2D lighting tools.

  4. Honestly slimmer builds with a lot of modules being removed as dependcies as well.

Knowing these bugs are almost all fixed makes us more comfortable of giving 6.5 a chance for the start of the next project.

If you encounter any further issues, do let us know and we will try our best to resolve them!

Okay so 2D team will love and hate what I am about to say.

Spent a few days trying to get the same crash after the last fix and so far I can’t get it to crash with that previous issue. Sadly though I discovered a completely new crash I have never seen, but it was simple to work around it.

Not sure if this one is related to Tilemap specifically or Sprite Render in general though. Might have to make a new thread and file an updated bug report for this new one.

When I have SRP batching set for the render mode in the Tilemap inspector I get a crash only after editing the sprite rects in the sprite editor and slicing up a new sprite. Turning off all SRP batching modes in all renders in the scene stopped the crash and has not crash once after that.

Edit: Added the site of crash. Will make a new bug report and thread later today on it with a video example. New thread is because it looks sperate from any other tilemap rendering issue mentioned before in this thread here.

>	Unity.dll!ShaderPropertySheet::FindPropertyIndex(struct ShaderLab::FastPropertyName,enum ShaderPropertySheetType)	Unknown
 	Unity.dll!ShaderPropertySheet::FindPropertyOffset(struct ShaderLab::FastPropertyName,enum ShaderPropertySheetType)	Unknown
 	Unity.dll!SpriteRendererSRPMaterialCallback(struct GfxBatchItem *,struct RenderNode const &,int,struct SRPBatcherSubProgramInfo const *,struct GfxTextureParam * *,struct GfxTextureParam const *,struct SharedMaterialData const *,int,int const * *)	Unknown
 	Unity.dll!ScriptableBatchRenderer::RenderMultipleMeshes(class RenderNodeQueue const &,struct BatchInstanceDataSRPB const *,int,class VertexInputMasks)	Unknown
 	Unity.dll!ScriptableBatchRenderer::Flush(enum BatchBreakCause)	Unknown
 	Unity.dll!ScriptableRenderLoopDrawSRPBatcher(struct ScriptableLoopObjectData const *,unsigned __int64,struct SharedRendererScene const &,struct DrawRenderersCommand const &,struct ShaderPassContext &,class GfxDevice &,int,class BatchRendererGroupMetadataCacheContext const *)	Unknown
 	Unity.dll!ScriptableRenderLoopJob()	Unknown

Thanks for this!

We have a fix incoming for a crash with a similar callstack. We can compare this with your bug report and see if that helps or a new fix needs to be applied!