Fix macOS Retina startup bugs on 1.21.1 (unsupported-resolution dialog + invisible first-person hand)#78
Open
seapancakes1 wants to merge 1 commit into
Open
Conversation
On macOS Retina, MixinWindow.scale() returned 0 whenever CommonClass.getInstance() was null - exactly the case during MC's bootstrap before the mod entrypoint runs. With Window.getWidth/ getHeight returning 0 in that window, vanilla MC's "supported resolution" check fired against the real GLFW framebuffer (e.g. 1708x960) as if it were unsupported, and the main render target got sized to 0x0 - causing the first-person hand to remain invisible until a manual window resize triggered MC's framebuffer resync. Three changes: 1. MixinWindow: return the original value instead of 0 when CommonClass isn't yet initialized. This is the load-bearing fix - mirrors the change in stonecutter commit 8de1073. 2. CommonClass: clamp window.getWidth()/getHeight() to >= 1 in setShouldScale, resize(RenderTarget), resize(PostChain). Defense in depth so any latent zero can't recreate a zero- sized target. 3. MixinGameRenderer: when the existing 5-frame counter expires, also fire Minecraft.getInstance().resizeDisplay() once. Re-runs MC's full framebuffer-resize chain against the real GLFW size, hardening against the hand-glitch path on systems where MC sized its mainRenderTarget against a stale 0x0 window. Tested on macOS 15 (Apple Silicon Retina) with Minecraft 1.21.1 NeoForge 21.1.x: no more "unsupported resolution" dialog on launch, hand renders from frame 1.
e6cc278 to
c7af079
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On macOS Retina displays, RenderScale 1.3.5 on the
1.21.1branch causes two cosmetic-but-disruptive startup bugs:Both have the same root cause and a single load-bearing fix.
Root cause
MixinWindow.scale(int)had:The mixin runs from MC's bootstrap path before the loader entrypoint has called
CommonClass.init(). During that window,Window.getWidth()andWindow.getHeight()mixin-return0, which propagates into:mainRenderTargetat 0×0 until a real GLFW framebuffer-resize event fires (the manual one-pixel nudge users do as a workaround).The same
return 0;was changed toreturn value;on the stonecutter branch in commit 8de1073 ("Better scaling implementation"), but that commit was part of a larger 1.21.5+GpuTexturerewrite and never landed on the1.21.1branch.Changes (3 files, +14 −5)
1.
common/.../mixin/MixinWindow.java— load-bearing fix.return 0;→return value;so callers that hitscale()beforeCommonClass.init()get a sane value back instead of zeroing out.2.
common/.../CommonClass.java— defense in depth. Wrapped everywindow.getWidth()/getHeight()insetShouldScale,resize(RenderTarget), andresize(PostChain)withMath.max(1, …)so any latent zero can't recreate a zero-sized target. Also incidentally protects against issue #23 (scale factor 0.0 causing 0×0 windows).3.
common/.../mixin/MixinGameRenderer.java— when the existing 5-frame counter expires, also fireMinecraft.getInstance().resizeDisplay()once. That re-runs MC's full framebuffer-resize chain against the real GLFW size — same chain a real window-drag triggers — to harden against the hand-glitch path on systems where MC sized itsmainRenderTargetagainst a stale 0×0 window beforeCommonClass.init()ran.Test plan
Tested by the reporter on macOS 15 / Apple Silicon Retina, MC 1.21.1, NeoForge 21.1.x, RenderScale built from this branch:
onResolutionChangedcleanly.Suggested additional CI / cross-platform checks before merging:
1.21.1branch (tested NeoForge locally; Fabric not tested butcommon/changes are loader-agnostic).Math.max(1, …)clamps don't regress anything (they shouldn't — they only kick in when the existing code would already have been passing 0).Notes / out of scope
stonecutterbranch — those have the same fix already (8de10736covered the analogous code on the 1.21.5+ pipeline).