fix: resolve CRI Mana video crash from thread-unsafe API calls#9
Open
Monstrofil wants to merge 1 commit into
Open
fix: resolve CRI Mana video crash from thread-unsafe API calls#9Monstrofil wants to merge 1 commit into
Monstrofil wants to merge 1 commit into
Conversation
The Scaleform video integration was ported from an older CRI Movie SDK where Scaleform managed decode threading itself. CRI Mana 2019 uses CRIMANA_THREAD_MODEL_MULTI by default, creating its own internal decode thread. The existing VideoDecoderThrd was calling criManaPlayer_ExecuteMain() from a second background thread, racing with both CRI's internal thread and the main thread's criMana_ExecuteMain() (which already calls criManaPlayer_ExecuteMain internally for all handles). Per CRI docs, criManaPlayer_ExecuteMain is "not thread safe" and "there is no need to execute it" when criMana_ExecuteMain is called. This produced the crash sequence: CRI-MW ERROR: Can't exec criMvPly_PutInputChunk() before AllocateWorkBuffer CRI-MW ERROR: Decoder core error VideoMovieClip internal error: <video>.usm CRI-MW ERROR: Don't call criMvPly_Destroy() at illegal status Changes: - DecodeFunc: Remove all criManaPlayer_ExecuteMain() calls; the thread now only polls criManaPlayer_GetStatus (documented thread-safe) to detect inactive players and clean up the decoding queue. - CheckHeaderDecoding/Decode: Replace direct criManaPlayer_ExecuteMain with pDecoder->ExecuteDecode() so the single-threaded decoder still works while the threaded decoder safely no-ops. - Init: Register criManaPlayer_SetMetaDataWorkAllocator using the Scaleform heap, fixing "Meta data work allocator is not set" warning that prevented seek/cuepoint buffer allocation. - Destructor: Add criManaPlayer_StopAndWaitCompletion before Destroy to ensure CRI's internal thread has finished with the player handle. Co-Authored-By: Claude Opus 4.6 <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.
Summary
criManaPlayer_ExecuteMaincalls from decode thread — CRI Mana 2019 withCRIMANA_THREAD_MODEL_MULTIcreates its own internal decode thread;criMana_ExecuteMain()from the main thread already callscriManaPlayer_ExecuteMaininternally for all handles, making Scaleform's background calls redundant and causing race conditions that corrupt CRI internal statecriManaPlayer_SetMetaDataWorkAllocatorinInit()so seek/cuepoint features can allocate internal work buffers, fixing "Meta data work allocator is not set" warningcriManaPlayer_StopAndWaitCompletionbeforeDestroyin destructor to ensure CRI's internal thread has finished with the player handleTest plan
.usmvideo playback works without CRI errors (sparkles.usm, loginVideo.usm, hangar videos)🤖 Generated with Claude Code