obsproject / obsproject/obs-studio
Crash after changing video capture device, async RefreshProperties to stale property view reference
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 76.4k
- Forks
- 10.2k
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 12
Description
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
Other
OBS Studio Version (Other)
git (7ae6f328), also tried 27.0.1 and 27.1-rc1
OBS Studio Log URL
https://obsproject.com/logs/oRg6FvSD-AdeslDt
OBS Studio Crash Log URL
https://obsproject.com/logs/cdXemrcbygrmybL5
Expected Behavior
Expected no crash or use-after-free.
Current Behavior
Reliably any time I change the device on a Video Capture source, OBS crashes. The crash happens after the actual device change takes place, I can see video from the new device playing in the properties window as soon as I choose the new device. But at this point it's already started crashing, and though the video keeps playing the UI is inoperative at this point.
Steps to Reproduce
- Fresh OBS install and fresh configuration
- Create a Video Capture source. It will start out with an arbitrary device set.
- Open the properties and change the device.
- Crash happens here.
Anything else we should know?
This is a weird one, it happens only on one of my machines but it reliably crashes every single time, and the crash happens the same way on the three versions of OBS that I tested. The main thing that is unique about this machine is that it has a lot of video devices (two blackmagic cards and three usb cameras).
I built OBS from source to test on the latest git, and during this I set some breakpoints on the two asynchronous dispatches to RefreshProperties. Looks like the culprit is WidgetInfo::ControlChanged(), at the very bottom where it queues a RefreshProperties if the setting was modified.
So, my understanding at this point is that during the change of the "device" control, we tried to refresh all properties in that dialog, but because the device had changed the other available properties had also changed, and we end up with an asynchronous call queued on what becomes a stale reference.
I can work around this well enough for my work by commenting out the QMetaObject::invokeMethod(..."RefreshProperties"...) line at the bottom of WidgetInfo::ControlChanged().
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The relevant entry point is WidgetInfo::ControlChanged(), especially its queued RefreshProperties call; reproduce by changing a Video Capture device with multiple devices and inspect the asynchronous property refresh. Done means changing devices no longer crashes or uses a stale property view reference, with the properties dialog remaining usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- audio-video-rtc, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100