Skip to content
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

More Image Leaks #1486

Open
wants to merge 2 commits into
base: v0.4
Choose a base branch
from
Open

Conversation

psycotica0
Copy link
Contributor

While building animated gifs I had some tracing on to make sure I wasn't introducing any leaks, and found some more that were pre-existing, but unrelated to animated GIFs.

The first was a cycle where hooking up the overlay in the file widget introduced a cycle that kept the file widget around even when the parent view was destroyed. I believe this one actually kinda works as-is, because the parent view in practice calls dispose() manually on the children, but that's a bit fragile and still isn't quite the same. But then when I implemented #1483 the parent became a standard Expander widget with no special handling, and then it was really broken. So this makes it so any standard widget can be the parent.

The second was the "FileSendOverlay" which was created as a stack variable and then not referenced anywhere else. So that should have crashed immediately, but the leaking from the two callbacks in scope kept it around forever instead. So what I did here was actually reference it from the conversation view controller and then explicitly clear it after the overlay closes (with a slight delay, since that's in a handler on a signal on that object, and it crashes if I free it from that context). I can be a bit looser here because this this in this context is the ConversationViewController, which appears to functionally be a singleton.

The gesture and overlay handlers both had lambdas, which appear to hold
"this" open, which prevented this from getting cleaned up when the
widget was removed from the tree.

Currently the level above this is always FileWidget, and FileWidget is
hard-coded to call "dispose" manually, but if this widget gets put into
another Widget that isn't special, it leaks.

This fixes this.
Previously the Overlay was a stack variable, and the only reason it
showed up was because it was leaked in the lambdas.

But making the references weak just exposes that this currently doesn't
have an obvious owner. So I made the view controller the owner, and then
in close I just clear that reference out so it can be reaped.

But, I can't free it out while in a handler on its own signal or it
crashes, so I have to wait for the next tick first.
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.

None yet

1 participant