-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Bug 1291709 - PdfjsChromeUtils.jsm leaks browser.xul windows. #7521
Conversation
Looks good to me after reading about how |
This seems fine to me, but the question is why it's actually necessary!? Unless I'm mistaken, when the viewer unloads (see Why is the existing code not working as intended? |
Good point, looking a bit closer it seems we never receive the message PDFJS:Parent:removeEventListener in pdfjschromeutils.jsm. I see it being sent from pdfstreamconverter side though. |
I've also done some quick testing, and it seems that things work as expected when navigating away from the PDF viewer (i.e. by going to a new web page in the same tab as the PDF viewer).
There must be some kind of |
I think you can listener to the "unload" event on the browser window. This is the browser.xul window. Its not clear to me exactly what this corresponds to in the pdfjs extension, though. We added something similar to AutoCompleteE10S.jsm: https://dxr.mozilla.org/mozilla-central/source/toolkit/components/satchel/AutoCompleteE10S.jsm#97 I agree its better to just listen for the unload instead of using WeakSet. |
In auto complete code the "browser window" is coming from https://dxr.mozilla.org/mozilla-central/source/toolkit/components/satchel/AutoCompleteE10S.jsm#199 |
There was a comment that appears to have been deleted, but just to clarify: I believe you have to listen for tab close and window close separately. This sucks and I would prefer that closing the window trigger tab closes as well, but it doesn't currently do it. Not sure if we can add that without breaking code that does not expect to get two close events. |
Sorry about that; I removed my previous comment since I didn't really think it through properly.
That's unfortunate, and it confirms what I've seen when testing this. Trying to call e.g. |
Should we merge the patch in its current form? It would be good to stop leaking windows and from the comments above other approaches have obvious downsides. What do you think? |
I'd be in favour of taking this PR in its current form as a temporary fix, so that we at least won't keep old |
FWIW, I filed a bug to create a new event type that is fired for either tab close or window close: https://bugzilla.mozilla.org/show_bug.cgi?id=1296099 Seems like the best long term solution to me. In the meantime, though, it would be nice to land the WeakSet(). I ran into this leak through normal browsing again today. |
https://bugzilla.mozilla.org/show_bug.cgi?id=1291709