Skip to content

Renderer: fix texture lookup paths + skip garbage Tile slots (r3) - #3

Merged
j92580498-max merged 1 commit into
mainfrom
devin/1778783937-mavericks-r3-textures
May 14, 2026
Merged

Renderer: fix texture lookup paths + skip garbage Tile slots (r3)#3
j92580498-max merged 1 commit into
mainfrom
devin/1778783937-mavericks-r3-textures

Conversation

@j92580498-max

Copy link
Copy Markdown
Owner

Fixes the two issues #2 reported running r2 on real Mavericks hardware.

1. All PNG textures rendered as flat coloured rectangles

loadTexture("gui/gui.png") was stripping both the directory and the extension before handing the result to [NSBundle pathForResource:ofType:]. Two problems with that:

  • pathForResource:ofType: only looks in top-level Resources/ (and *.lproj children), but our bundle keeps the handheld/data/ layout, so the real files are at Resources/images/gui/gui.png, Resources/images/font/default8.png, Resources/images/terrain.png, etc.
  • After stripping, two different files (gui/gui.png and gui/gui2.png) would also collide on the same lookup key.

Every texture call therefore fell to the LOGI("Couldn't find file:") branch and the renderer used its random-noise fallback — which is exactly the "buttons are coloured rectangles, no text" symptom the user reported.

Fix: keep the subdirectory and search a few likely Resources-relative directories with pathForResource:ofType:inDirectory:, falling back to the flat lookup for any iOS-style bundles, then to the dev-time data/images/ layout.

2. SIGSEGV in Chunk::rebuild() after loading any world

Crash log from #2 shows:

Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000001d10
Thread 0 Crashed:
0   com.mojang.minecraftpe.osx  Chunk::rebuild() + 640
1   com.mojang.minecraftpe.osx  LevelRenderer::updateDirtyChunks(...) + 414
2   com.mojang.minecraftpe.osx  GameRenderer::renderLevel(float) + 653

Disassembly of Chunk::rebuild + 640 lands on mov rax, qword ptr [rbx] where rbx is the value of Tile::tiles[tileId]. The slot isn't NULL — it's page-zero garbage (0x1d10). Boot diagnostics already warn that a few slots are inconsistent (Error: Missing category for tile 95/255), so the renderer now guards against both NULL and obviously-bogus sub-0x10000 pointers before dereferencing the vtable.

Test

  • Cross-built via OSXCross + MacOSX10.9.sdk, -arch x86_64 -mmacosx-version-min=10.9 -stdlib=libstdc++.
  • Output is Mach-O 64-bit x86_64 (NOUNDEFS | DYLDLINK | TWOLEVEL | WEAK_DEFINES | BINDS_TO_WEAK | PIE), 3.1 MB release.
  • Bundle resources are confirmed nested correctly (Contents/Resources/images/gui/gui.png, etc.).
  • Real-hardware verification has to be done by the issue reporter — I'll publish an r3 release tarball + checksums and ping Loading world crashes + not working textures i don't know why #2.

Two issues showed up running r2 on real Mavericks hardware (issue #2):

1. Every PNG was rendering as a flat random-coloured rectangle. The
   iOS-style loadTexture() was stripping both the directory and the
   extension before passing the name to NSBundle's pathForResource:,
   but our app bundle keeps the data/ layout from the engine repo
   (Contents/Resources/images/gui/gui.png, font/default8.png, etc.).
   pathForResource: only finds top-level Resources/ + *.lproj, so every
   call failed and the renderer fell back to its noise texture. Keep
   the subdirectory now and try a few likely Resources-relative
   directories with pathForResource:ofType:inDirectory:.

2. Loading any newly-created world crashed with SIGSEGV in
   Chunk::rebuild() inside the renderer thread. Disassembly showed the
   crash at 'mov rax, [rbx]' where rbx came straight out of
   Tile::tiles[tileId] — the slot wasn't NULL, it held an obvious
   page-zero garbage pointer (0x1d10). Boot diagnostics already warn
   about a few stale slots ('Missing category for tile 95/255'), so
   just guard Chunk::rebuild() against tile IDs that map to NULL or
   to a sub-0x10000 pointer instead of letting the vtable load fault.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@j92580498-max
j92580498-max merged commit f216915 into main May 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant