-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Avoid crashes when engine leaks canvas items and friends #85520
Avoid crashes when engine leaks canvas items and friends #85520
Conversation
99852f4
to
ab10206
Compare
I also noticed some outdated code that was out of place in relevant files, so I did a little cleanup. Seems like it dates back to 2787ad6#diff-2eaa5fdddb0bc4674976c8bbaeb5aab4c69d5a3c74fb1ead3a00f9e9c06a4f26, but after some additional changes the singleton definition should be moved to the class' own file. Thanks @clayjohn for looking into it 🙃 |
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.
Looks good to me overall.
Waiting for rendering team review to merge.
ab10206
to
34ecfff
Compare
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.
This looks good to me, it makes perfect sense to add this check. It's helped us lots of times on the 3D side.
WARN_PRINT(vformat("%d RIDs of type \"%s\" were leaked.", owned.size(), p_type)); | ||
} | ||
for (const RID &E : owned) { | ||
free(E); |
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.
We don't do this consistantly on the 3D side but if you search you'll see a few places I added it, but seeing that it can be very difficult to find the cause of the leak simply by a count, I check if a description was recorded for the RID (this is a debug/tools build only feature), than we print the description of the resource being leaked.
This also means off course that we need to get more consistent in recording descriptions when the resource is allocated. Something we can improve on over time.
Thanks! |
Cherry-picked for 4.2.2. |
Closes #85495. Code is gently stolen from the Vulkan renderer, which does a similar thing.
Now you'll see this with the MRP on exit:
Plus a lot of other leaks.
What happens, basically, is that when there is a leak we are left with some data in the
RendererCanvasCull
class. When we try to delete it, it attempts to delete all its memory, includingRendererCanvasRender::Item
s it has in store. These contain commands which contain polygons. When you delete polygons, we need to access theRendererCanvasRender
singleton. But this singleton is already null at this point (it is removed when the rendering server is finalized, whereasRendererCanvasCull
is only removed when the rendering server is deleted).So we need to do these things earlier and with more grace, and report to the user that they have a leak.