Repository navigation
totk: fix hardware Opus decoder slot leak ("decoder table full" crash) - #18
Merged
ly05010419 merged 1 commit intoOct 19, 2026
Merged
Conversation
The game can call InitializeHardwareOpusDecoder again on a decoder object without finalizing it first. Each call took a new slot, so after enough cutscenes/streams the 64-entry table filled and the runtime aborted with 'hardware Opus decoder table full' (seen after ~7 and ~30 min of play on 1.0.0). Reuse the existing slot for the same guest object (destroying the old libopus state) and raise the table to 256 as headroom.
ly05010419
added a commit
that referenced
this pull request
Oct 19, 2026
…without Finalize PR #18 reuses the slot; the line tells which session hits that path (our host writes none of the SDK's HardwareOpusDecoderType fields, which the game may test before it initializes). Co-Authored-By: Claude Opus 5.5 <[email protected]>
ly05010419
added a commit
that referenced
this pull request
Oct 19, 2026
…der has a lock for its lifetime Defensive: the game keeps far fewer than 256 decoders alive; issue #9's exit came from repeated Initialize without Finalize, fixed by PR #18. Resolved with main: a header that records no final range (a40bc87) is still decoded without the check, now with the decoder released. The peak line is printed only past the old 64 (at 65 and every power of two) unless TOTK_CODEC_TRACE is set, and the probe checks a zero range is accepted. make test-opus-codec passes with ASan+UBSan and TSan (512 live decoders, 8 threads); 1.4.3 plays audio in the world. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01AZC16EYkS2AmLMgumTJaXJ
0x1233333
pushed a commit
to 0x1233333/MacNativeGames
that referenced
this pull request
Oct 20, 2026
…without Finalize PR ly05010419#18 reuses the slot; the line tells which session hits that path (our host writes none of the SDK's HardwareOpusDecoderType fields, which the game may test before it initializes). Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
On TotK 1.0.0 (clean XCI, M3 Pro, macOS 27), the app aborted twice during normal play, after about 30 and about 7 minutes. The last log line both times was:
initialize()ingames/totk/runtime/opus_codec.calways takes a free slot. If the game callsInitializeHardwareOpusDecoderagain on a decoder object it never finalized, the old slot (and its libopus state) is never released. The 64-entry table then fills up andruntime_failaborts the game.Fix
initialize(), if a live slot already belongs to the same guest decoder object, destroy its old libopus state and reuse that slot instead of taking a new one.MAX_DECODERSfrom 64 to 256 for headroom.finalize(),find()and the decode and integrity checks are unchanged.Testing
I rebuilt the app with
build_app.pyfrom a clean 1.0.0 XCI. Gameplay since the rebuild has had no crash so far, but long sessions are still being tested. I haven't confirmed with logging exactly which call path re-initializes without finalizing.