Controlify

Controlify

609k Downloads

PoseStack leak in `ChatComponentMixin`

homchom opened this issue ยท 0 comments

commented

Describe the problem
The Controlify class dev.isxander.controlify.mixins.feature.chatkbheight.ChatComponentMixin pushes a pose to the passed GuiGraphics instance at the HEAD of ChatComponent::render and pops it at the TAIL. However, looking at the generated bytecode (decompiled), the pop method is called inside an if block and therefore is only run if chat is not hidden. (I have posted a screenshot of the start of this if block below).

So when chat is hidden, a pose is pushed but not popped, which leaks to all subsequent GUI rendering calls. This is not prominent when the mod is by itself, but causes conflicts with other mods that push and pop to GuiGraphics. For example, I noticed this by an incompatibility with recode, my mod.

Mod Info

To Reproduce
Steps to reproduce the behavior:

  1. Start Minecraft with both Controlify and recode (and all dependencies).
  2. Open a world.
  3. Open chat. Observe that the chat input box is translated to the right.

Expected behavior
The chat box is in the vanilla position.

Screenshots
image
2023-07-24_22 10 42

Minecraft Info

  • OS: MacOS Ventura
  • Minecraft Version: 1.20.1
  • Controlify Version: 1.4.4+1.20

Additional context
I believe this can be fixed by changing the HEAD injection point of ChatComponentMixin::translateRender to an INVOKE (with target ChatComponent::isChatHidden) with shift At.Shift.AFTER, but I have not tested this.