Skip to content

fix: resolve CRI Mana video crash from thread-unsafe API calls#9

Open
Monstrofil wants to merge 1 commit into
wowp-compat-display-object-propsfrom
fix/cri-mana-video-crash
Open

fix: resolve CRI Mana video crash from thread-unsafe API calls#9
Monstrofil wants to merge 1 commit into
wowp-compat-display-object-propsfrom
fix/cri-mana-video-crash

Conversation

@Monstrofil

Copy link
Copy Markdown

Summary

  • Remove unsafe criManaPlayer_ExecuteMain calls from decode thread — CRI Mana 2019 with CRIMANA_THREAD_MODEL_MULTI creates its own internal decode thread; criMana_ExecuteMain() from the main thread already calls criManaPlayer_ExecuteMain internally for all handles, making Scaleform's background calls redundant and causing race conditions that corrupt CRI internal state
  • Register metadata work allocator via criManaPlayer_SetMetaDataWorkAllocator in Init() so seek/cuepoint features can allocate internal work buffers, fixing "Meta data work allocator is not set" warning
  • Add criManaPlayer_StopAndWaitCompletion before Destroy in destructor to ensure CRI's internal thread has finished with the player handle

Test plan

  • Verify .usm video playback works without CRI errors (sparkles.usm, loginVideo.usm, hangar videos)
  • Verify no "PutInputChunk before AllocateWorkBuffer" or "Decoder core error" in logs
  • Verify no "Meta data work allocator is not set" warnings
  • Verify multiple simultaneous videos play without crashes
  • Verify video stop/seek/restart works correctly

🤖 Generated with Claude Code

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>
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