mojira.dev
MC-307404

`DebugScreenOverlay.extractRenderState()` calls `nextStratum()` unconditionally when `currentlyEnabled` is non-empty, even if no content is rendered

DebugScreenOverlay.extractRenderState() calls graphics.nextStratum() based solely on whether getCurrentlyEnabled() is non-empty, without checking if any entry actually produced output. Empty strata corrupt the GUI render layer ordering, causing other GUI elements added via GuiGraphicsExtractor.text() to become invisible.

The problematic code:

Collection<Identifier> visibleEntries = this.minecraft.debugEntries.getCurrentlyEnabled();

if (!visibleEntries.isEmpty()) {
    graphics.nextStratum();   
    // unconditional
    // ... entries may produce zero output ...
    
    this.extractLines(graphics, leftLines, true);
    this.extractLines(graphics, rightLines, false);
    graphics.nextStratum();   
    // unconditional again
}

This occurs in vanilla when debug-profile.json retains entry IDs from a previous version after migration. getCurrentlyEnabled() returns these IDs, but getEntry() returns null (entry no longer registered). The for-loop skips null entries, but nextStratum() already fired, creating empty strata that displace subsequent GUI rendering.

Suggested fix — guard nextStratum() behind actual content:

if (!leftLines.isEmpty() || !rightLines.isEmpty()) {
      graphics.nextStratum();
      this.extractLines(graphics, leftLines, true);
      this.extractLines(graphics, rightLines, false);
      graphics.nextStratum();
  }


Also affects 26.1, 26.1.1, 26.1.2-rc1

Comments 5

Can confirm in 26.2 Snapshot 2 as well:

Collection<Identifier> visibleEntries = this.minecraft.debugEntries.getCurrentlyEnabled();
if (visibleEntries.isEmpty()) {
    return;
}
graphics.nextStratum();
for (Identifier identifier : visibleEntries) {
    DebugScreenEntry debugScreenEntry = DebugScreenEntries.getEntry(identifier);
    if (debugScreenEntry != null) {
        debugScreenEntry.display(debugScreenDisplayer, level, this.getClientChunk(), this.getServerChunk());
    }
}
this.extractLines(graphics, list, true);
this.extractLines(graphics, list2, false);
graphics.nextStratum();

Thanks for the report!

“Empty strata corrupt the GUI render layer ordering”

That would be the real bug here. But I can not reproduce the corruption. Just adding a couple of calls to “nextStratum” in random places did not make the UI render in any way incorrectly for me. Could you explain the mechanism of that corruption?

Triggering the specific repro case with empty DebugScreenOverlay also broke nothing.

▎ Hi Timur,
▎
▎ Thanks for the follow-up. I'm now also unable to reproduce the visual symptom on my end — vanilla MC 26.1.1's datafixer correctly handles the version migration path I originally suspected (inF3 → inOverlay enum rename, plus dropping unrecognized entries). The exact triggering state from April has been
▎ lost since I rebuilt the vanilla debug-profile.json to fix it locally.
▎
▎ However, BugTracker_'s 2026-04-11 confirmation in 26.2 Snapshot 2 (vanilla source quoted in the comment) and the ticket's Community Consensus status both indicate the issue is recognized at the code level even when end-to-end reproduction is currently elusive.
▎
▎ The core issue stands as a defensive gap regardless of current reachability:
▎
▎ if (!visibleEntries.isEmpty()) {
▎ graphics.nextStratum(); // unconditional — fires even if all entries no-op
▎ // ...
▎ graphics.nextStratum(); // unconditional again
▎ }
▎
▎ Any future entry whose display() becomes runtime-conditional, any third-party mod registering entries with conditional output, or any future migration scenario datafixer doesn't yet cover, can re-trigger this. The suggested guard (if (!leftLines.isEmpty() || !rightLines.isEmpty())) is zero-cost and
▎ removes the entire class of edge cases.
▎
▎ The sodium-extra ecosystem mitigation already shipped via FlashyReese/sodium-extra#531, but the vanilla-side guard remains the cleanest fix for long-term robustness.
▎
▎ Feel free to close as Cannot Reproduce if visual repro is required, or apply the guard as a defensive cleanup based on the code analysis. Either resolution is reasonable from my side — the goal is just preventing the class of bug, not necessarily this specific manifestation.

My point is that calling nextStratum as many times as you want without submitting anything in between should be totally safe, with the only impact being a negligible performance hit. As far as I can see, this is the case.

But your bug report claims that there is an impact: “other GUI elements added via GuiGraphicsExtractor.text() to become invisible.“
If that’s the case, then nextStratum logic is broken and should be fixed.

Just having an unconditional nextStratum is a very minor thing in comparison. I manually changed the keys in the debug-profile.json to non-existent ones and did not see any impact from that.

So if you could provide more detail on how an extra stratum can impact things, I would be very grateful.

If a mod changes the implementation of nextStratum, it should follow the same contract of it being safe to call multiple times without any GUI element submits in between.

loong0x00

Timur Nazarov

Community Consensus

Platform G

Important

Debug, Rendering

26.1.2, 26.2 Snapshot 1, 26.2 Snapshot 2

Retrieved