Fix crash when a texture file fails to load on an async worker thread - #116
Open
scottsheppeard wants to merge 1 commit into
Conversation
r_tex_c::LoadFile()'s failed-load fallback (missing or unreadable file) called Upload() directly from the texture manager's worker thread. The GL context belongs to the main thread, so this crashes in ANGLE's GL_GenTextures with a null-deref (observed as a startup SIGSEGV on macOS when the PoB passive tree references TreeData/PassiveMasteryConnectedButton.png, which does not exist). Route the placeholder upload through the pending-upload queue exactly like the successful async load path a few lines above, so the main thread performs the GL work in ProcessPendingTextureUploads(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
r_tex_c::LoadFile()'s failed-load fallback (missing or unreadable texture file) callsUpload()directly from the texture manager's worker thread. GL work is only valid on the thread owning the context, which is why the successful async load path enqueues viamanager->EnqueueTextureUpload()and lets the main thread perform the upload inProcessPendingTextureUploads()— but the fallback path bypasses that mechanism.This is easy to hit in practice: PoB's passive tree sprite loading references
TreeData/PassiveMasteryConnectedButton.png, which doesn't exist in the PathOfBuilding repo, so every failed async texture takes this path. On the macOS port (ANGLE/Metal) it's a deterministic startup SIGSEGV inGL_GenTextures:On other backends it's a latent thread-safety bug at best.
Fix
When
TF_ASYNCis set, route the placeholder upload through the same pending-upload queue as the success path; the synchronous path is unchanged.flagsis reset toTF_NOMIPMAPbefore enqueueing to preserve the previousUpload(*raw, TF_NOMIPMAP)GL behaviour.Verified on an M-series MacBook Pro against stevschmid/PathOfBuilding-Mac's engine build (same code): previously crashed deterministically at startup; with the patch, PoE1 and PoE2 dev trees both start and run normally, with the missing file degrading to the default placeholder texture as intended.
🤖 Generated with Claude Code