Skip to content

fix: SG-42334: Fix random crashes involving SoundTrackIPNode#1152

Merged
bernie-laberge merged 1 commit intoAcademySoftwareFoundation:mainfrom
bernie-laberge:fix_SoundTrackIPNode_random_crashes
Mar 6, 2026
Merged

fix: SG-42334: Fix random crashes involving SoundTrackIPNode#1152
bernie-laberge merged 1 commit intoAcademySoftwareFoundation:mainfrom
bernie-laberge:fix_SoundTrackIPNode_random_crashes

Conversation

@bernie-laberge
Copy link
Copy Markdown
Contributor

fix: SG-42334: Fix random crashes involving SoundTrackIPNode

Linked issues

NA

Summarize your change.

  • Fixed race conditions in SoundTrackIPNode that caused random crashes due to unsynchronized access to m_fb across threads.
  • evaluateAudioTexture() now uses a short lock-around-read pattern to safely snapshot m_fb before use, and re-checks it under lock before dereferencing to construct the
    IPImage — guarding against propertyChanged() clearing m_fb on the main thread between the two access points.
  • propertyChanged() now acquires m_fblock before allocating or restructuring m_fb, preventing data races during waveform texture resize.
  • clearFB() now acquires m_fblock for the duration of the pixel clear and stats reset, making it fully thread-safe.

Root Cause

m_fb (the waveform framebuffer) was read and written from multiple threads without synchronization. evaluateAudioTexture() ran on the audio/render thread while
propertyChanged() and clearFB() ran on the main thread. A m_fb pointer that was valid at the check could be freed mid-use, leading to use-after-free crashes.

Describe the reason for the change.

Random crashes had been reported originating from SoundTrackIPNode.

Describe what you have tested and on which operating system.

Successfully tested on macOS.

Test Plan

  • Enable the Timeline Magnifier via the RV/Tools/Timeline Magnifier menu
  • Load media that contains audio
  • Play media with audio waveform display enabled and rapidly scrub / resize the timeline — no crash
  • Trigger property changes (e.g., resize the waveform panel) during active audio playback — no crash

Add a list of changes, and note any that might need special attention during the review.

If possible, provide screenshots.

Comment thread src/lib/ip/IPCore/SoundTrackIPNode.cpp Outdated
Comment thread src/lib/ip/IPCore/SoundTrackIPNode.cpp Outdated
@bernie-laberge bernie-laberge force-pushed the fix_SoundTrackIPNode_random_crashes branch from a338bec to 0d20272 Compare February 27, 2026 18:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes random crashes in SoundTrackIPNode by adding synchronization around waveform framebuffer (m_fb) usage and by centralizing the default audio packet size into a shared constant.

Changes:

  • Add mutex protection around m_fb allocation/restructure/clearing and re-check m_fb under lock before dereference in evaluateAudioTexture().
  • Introduce TWEAK_AUDIO_DEFAULT_PACKET_SIZE (2048) and replace hardcoded packet-size defaults across audio/cache/movie components.
  • Update IPGraph to use the shared default packet size instead of platform-specific hardcoded defaults.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lib/ip/IPCore/SoundTrackIPNode.cpp Adds locking around framebuffer access/clear and re-checks m_fb before creating the waveform IPImage.
src/lib/ip/IPCore/IPGraph.cpp Uses TWEAK_AUDIO_DEFAULT_PACKET_SIZE for m_audioPacketSize and includes TwkAudio/Audio.h.
src/lib/image/MovieRV_FBO/MovieRV_FBO/MovieRV_FBO.h Replaces default audioPacketSize argument with TWEAK_AUDIO_DEFAULT_PACKET_SIZE.
src/lib/image/MovieRV_FBO/MovieRV_FBO.cpp Updates member default m_audioPacketSize to TWEAK_AUDIO_DEFAULT_PACKET_SIZE.
src/lib/image/MovieRV/MovieRV/MovieRV.h Replaces default audioPacketSize argument with TWEAK_AUDIO_DEFAULT_PACKET_SIZE.
src/lib/image/MovieRV/MovieRV.cpp Updates member default m_audioPacketSize to TWEAK_AUDIO_DEFAULT_PACKET_SIZE.
src/lib/audio/TwkAudio/TwkAudio/Audio.h Defines and documents TWEAK_AUDIO_DEFAULT_PACKET_SIZE (2048).
src/lib/audio/TwkAudio/AudioCache.cpp Uses TWEAK_AUDIO_DEFAULT_PACKET_SIZE as the default cache packet size.

Comment thread src/lib/ip/IPCore/SoundTrackIPNode.cpp
Comment thread src/lib/ip/IPCore/SoundTrackIPNode.cpp
Signed-off-by: Bernard Laberge <bernard.laberge@autodesk.com>
@bernie-laberge bernie-laberge force-pushed the fix_SoundTrackIPNode_random_crashes branch from 0d20272 to e4613e0 Compare February 27, 2026 21:47
@bernie-laberge bernie-laberge merged commit 75bfcc7 into AcademySoftwareFoundation:main Mar 6, 2026
20 checks passed
@bernie-laberge bernie-laberge deleted the fix_SoundTrackIPNode_random_crashes branch March 6, 2026 21:03
eloisebrosseau pushed a commit to eloisebrosseau/OpenRV that referenced this pull request Apr 1, 2026
…SoftwareFoundation#1152)

### fix: SG-42334: Fix random crashes involving SoundTrackIPNode

### Linked issues
NA

### Summarize your change.

- Fixed race conditions in SoundTrackIPNode that caused random crashes
due to unsynchronized access to m_fb across threads.
- evaluateAudioTexture() now uses a short lock-around-read pattern to
safely snapshot m_fb before use, and re-checks it under lock before
dereferencing to construct the
IPImage — guarding against propertyChanged() clearing m_fb on the main
thread between the two access points.
- propertyChanged() now acquires m_fblock before allocating or
restructuring m_fb, preventing data races during waveform texture
resize.
- clearFB() now acquires m_fblock for the duration of the pixel clear
and stats reset, making it fully thread-safe.

  Root Cause

m_fb (the waveform framebuffer) was read and written from multiple
threads without synchronization. evaluateAudioTexture() ran on the
audio/render thread while
propertyChanged() and clearFB() ran on the main thread. A m_fb pointer
that was valid at the check could be freed mid-use, leading to
use-after-free crashes.

### Describe the reason for the change.
Random crashes had been reported originating from SoundTrackIPNode.

### Describe what you have tested and on which operating system.
Successfully tested on macOS.

Test Plan

- Enable the Timeline Magnifier via the RV/Tools/Timeline Magnifier menu
- Load media that contains audio
- Play media with audio waveform display enabled and rapidly scrub /
resize the timeline — no crash
- Trigger property changes (e.g., resize the waveform panel) during
active audio playback — no crash

### Add a list of changes, and note any that might need special
attention during the review.

### If possible, provide screenshots.

Signed-off-by: Bernard Laberge <bernard.laberge@autodesk.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.

4 participants