[1.19] HUD renders many times per frame, dramatically reducing performance
LuminaSapphira opened this issue ยท 0 comments
The check for the appropriate overlay appears to have been removed when updating to 1.19:
This causes the overlay to render many times, which according to a Spark report, causes a large performance hit. I was able to confirm that checking for the overlay does improve performance (sample code below). However, the more appropriate solution would likely be to use Forge's register gui overlay event to create your own overlay to render from, rather than using the Forge event bus. See net.minecraftforge.client.event.RegisterGuiOverlaysEvent for more information on that.
Sample checking code to quickfix:
private NamedGuiOverlay overlay = null;
@SubscribeEvent
public void onRenderGameOverlay(RenderGuiOverlayEvent.Post event) {
if (overlay == null) {
overlay = GuiOverlayManager.findOverlay(new ResourceLocation("minecraft", "armor_level"));
} else {
if (overlay != event.getOverlay()) return;
}
// .....