-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
frontend: Fix canvas removal causing crashes due to recursive remove calls #12756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frontend: Fix canvas removal causing crashes due to recursive remove calls #12756
Conversation
|
Alright did a lot more debugging today and came up with this solution: master...PatTheMav:obs-studio:canvas-memory-management-fix Notes:
|
I think in that version you're still double-releasing the canvas, once in I wanted to maintain the RAII wrapper |
You are right, I missed that In our test case we do the latter, so we ensure that the reference count goes to (For that reason So you are correct that the call to So the call from We definitely need to revisit the entire implementation as there are too many implicit conversions between raw pointers and wrapped objects and some objects are implicitly owners of a pointer without having any impact on reference counting. But that can happen after fixing the immediate issue. I shall now write a bit of Rust or Swift code to get that madness out of my mind.. 🫠 |
Right but that already works correctly, reference counting was never the problem, just recursion resulting in the vector modified/iterated over while in an invalid state. You're adding another |
RytoEX
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per off-thread discussion with @PatTheMav , we'll merge this as-is and then attempt to address the other concerns more comprehensively at a later time.
Description
Makes some changes to how canvas removal is handled to avoid recursion in the middle of an
erase()operation on the vector holding frontend-managed canvases.Also prevents a similar issue when clearing scene data by replacing
.clear()with a dedicated method that also ensures the canvas removal signal is properly fired for each removed canvas.Motivation and Context
See #12728, which this PR superseedes.
How Has This Been Tested?
Reproduced using the following snipped (just added to the end of the
OBSBasicSettings::OBSBasicSettings()constructor):Note that the crash only happens in release builds, not debug.
Types of changes
Checklist: