TilemapRenderer.CameraBoundsCheck causing 10ms lag spike

Hi all,

The problem is the title. Here is an attachment of what I see in the Profiler Timeline.

The game is a 2D procedurally generated voxel based survival game (Basically Terraria but infinite) I’m assuming this has to do with the tilemaps of my chunks, but I’m not sure where to start looking for solutions for this problem. (My Google results have turned purple.) Please let me know if you know of any common issues that cause this or if you need more information about my problem.

Cheers, and thank you all so much for your help.

Maybe just too many tiles in the view? A Terraria-style game wouldn’t typically be done with such a system depending on the scale.

Regardless, I’m not the expert here but I’ve pinged the dev who is for you.

Yeah, I’ve seen this too but not at this degree. I don’t totally know what’s in this method, but based on its name it seems like there could be a fast path (100x+) for many normal 2D camera setups. Check if orthographic top-down, check if tilemap isn’t rotated/scaled weirdly, and if so use the fast path.

Not that I can see in the code.

This profiler entry is the top-level but there’s a lot of other things going on here that should be reported to the profiler too so maybe a deep profile would help and/or best looked at in the hierarchy view.

If this is Auto and the bounds have changed then it runs a bounds calculation reported as “TilemapRenderer.CalculateChunkCullingBounds”. It ends with spawning a parallel job which looks potentially like the most intensive part and is reported as “TilemapRenderer.CameraBoundsJob”.

Hope that helps.

@betodamian Would it be possible to file a bug report with your project using the Unity Bug Reporter and post the case number here? That would help a lot, thanks!

In the meantime, could you check if the orientation of your camera and the bounds of your Tilemap make sense to you (Tilemap.bounds)?