We've noticed after upgrading our heavy Paper2D project to 4.22 that tilemap performance has been massively degraded compared to previous versions. After some digging we found out that it's due to a fix to a bug that we've had for a while but successfully worked around.
In short: referencing more than one tilemap in a TileLayer would break the rendering of that TileLayer. We worked around this by just adding more layers, always dedicating a layer to a specific tileset.
The 4.22 rendering rewrite seems to have brought this bug over to PC, and so it was I guess officially detected for the first time, and therefore fixed (yay!). However, this fix totally wrecked performance, especially on mobile platforms. We've worked around this by #ifdeffing so the game runs with the old code on mobile platforms but with the new code on other platforms / the editor etc.
The issue is, simply put: The GetNewBatchMeshes function in PaperRenderSceneProxy now loops through all vertices per batch, adding each vertex separately to the DynamicMeshBuilder. This wrecks performance since the VertexBuffer->Vertices TArray in DynamicMeshBuilder is resized once per AddVertex call.
However, I propose a small code change that improves tilemap performance across all platforms. (I think it's still worse than what we had before, but not by much!)
So the simple fix I propose is this:
Add a Vertices.Reserve() call before the for loop. Since DynamicMeshBuilder doesn't expose the vertices array, I propose:
Add the following method to DynamicMeshBuilder:
In GetNewBatchMeshes, change:
This gets rid of the constant TArray resizing.
Refer to UDN.
There's no existing public thread on this issue, so head over toAnswerHub just mention UE-79052 in the post.