-
Notifications
You must be signed in to change notification settings - Fork 9
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
Ghost window memory leak on Pale Moon 31.3.0.1 #50
Comments
it's only my 5 cents. I also noticed a problem with eating memory, and in addition, even after loading another page on github (different from github), cyclic jumps of cpu use. The problem also occurs on github-wc-polyfill-1.2.19.[1/2/3]-unofficial. I partially work around this by blocking one script ( |
Very interesting. I've never really noticed anything getting worse with Palefill, there are lots of memory problems in the current DOM handling anyway. I think this may be related to templates since it is most extreme on Youtube (can't watch a stream with chat or chat replay open for example - each message eats a few megabytes, permanently). I see nothing in the Palefill code that even interacts with the content windows. The polyfills obviously do, but they live entirely inside the window and should be freed with them. Edit: But I can reproduce your test, so there is that. |
This is weird. Github is the only site I can reproduce the leak on. Even a test rule that just injects |
I think I've been able to [sporadically] reproduce what seems like a similar issue in Proton Mail without Palefill since reporting this issue, so it does seem very likely that it could actually be UXP related. Unfortunately, some research into ghost windows on the Pale Moon forum seems to suggest that flaws like this are pretty common and aren't likely to get solved any time soon in UXP, as Moonchild tries very hard to shift the blame onto the web instead. Maybe it could be possible to implement something within Palefill to work around the issues with the "turbo" script pointed out by AroKol78 (I think maybe blocking the original script and then writing some kind of shim to be able to fix whatever usability features are broken by blocking it would work? I don't think GitHub exactly needs soft navigation...) This is a very wild guess, but maybe the nature of soft navigation could mean that there's something in the JS that is still holding a reference to elements -- maybe even webcomponent-related stuff -- that would've been in the page before the navigation occurred...or something. EDIT: Yep, it's UXP alright. I managed to reproduce the issue even without Palefill and |
Thank you for investigating further!
That should work for now: Turbo-Drive can be disabled by a data attribute.
Do they use custom elements, maybe with a self-hosted polyfill? Or is it entirely independent?
Oh, so it's not (just) in the polyfill either. Things I can think of:
Some of that would explain why regular custom elements from Youtube also leak, even if they don't cause ghost windows. I'd say that increases the chances, if we can come up with a simple reproducer. GC issues are hard enough to debug as it is... but being able to say "this specific thing leaks and it shouldn't" helps a lot. May even be able to find a related Mozilla report. |
it could also be helpful to determine whether this leak happened in older palemoon versions, and if not bisect the commit in UXP that introduced it. |
I do have the same memory leak problem also using other UXP builds. |
Of course it isn't that easy, but it is possible and indeed, the leaks go away. Current hypothesis: something about removing custom elements (with attached shadows?) from the DOM doesn't fully detach them, and then that something keeps the Window alive. |
Just to give some feedback on the above commit: it seems to have completely fixed the CPU spikes I was observing since a couple months ago I guess(?) which made scrolling thru simple html pages very jarring. My three day-old Palemoon running process is currently only consuming So kudos and many thanks for that martok. HUGE fix. |
This workaround is modify from 5e1c7d8, just work, is not the preciseness: document.addEventListener("DOMContentLoaded", () => {
const dummy = () => false,
turboFrameDelegateConstructor = document.createElement("turbo-frame").constructor.delegateConstructor,
elementIsNavigatable = Turbo.session.elementIsNavigatable,
willFollowLinkToLocation = Turbo.session.willFollowLinkToLocation,
shouldInterceptNavigation = turboFrameDelegateConstructor.prototype.shouldInterceptNavigation,
turboOn = () => {
Turbo.session.elementIsNavigatable = elementIsNavigatable;
Turbo.session.formMode = "on";
Turbo.session.willFollowLinkToLocation = willFollowLinkToLocation;
turboFrameDelegateConstructor.prototype.shouldInterceptNavigation = shouldInterceptNavigation;
},
turboOff = () => {
Turbo.session.elementIsNavigatable = dummy;
Turbo.session.formMode = "off";
Turbo.session.willFollowLinkToLocation = dummy;
turboFrameDelegateConstructor.prototype.shouldInterceptNavigation = dummy;
};
document.addEventListener("visibilitychange", () => {
if (document.hidden) turboOff(); else turboOn();
});
window.addEventListener("beforeunload", () => {
turboOff();
});
}, {once: true}); |
... Thanks for your code, but how exactly is that supposed to "just work"? |
If it was posted as a |
My PC stay at Windows 7, there is no
That caused by 5e1d254, I do not use palefill, and forgot that. Here is the patch: const element = mutation.target;
+ if (element.tagName === "TURBO-FRAME") continue;
const CEdef = element.__CE_definition; @martok This patch is work, means that the observer from CE polyfill has not completely stopped working. Maybe there are more issues which caused by it. |
Not trying to be a jackass here but as a heads-up, there are plenty of working, XP backwards compatible GNU |
I am on Windows Vista SP2 32-bit in my old laptop, Also, Remember this (generated on Vista SP2 32-bit) ? Thanks all the same 😄 ... PS: @garoto beat me to it... |
Yes, you are right, I know here it is, but I will not use it. :) |
None of this has anything to do with the issue here. |
I've moved the hard disabling into a separate fix for the last release since it used to be lumped in with four others that are completely not needed anymore. |
This issue seems easiest to reproduce using GitHub. With Palefill installed and enabled, GitHub's navigation is performed mostly via JavaScript (clicking on UI buttons like "Issues" or "Pull requests" or navigating directories in the source tree of a repository provides a blue loading bar at the top of the page and navigation occurs without seemingly ever triggering a new page load in the classic sense).
This works fine, but if you create a fresh profile in Pale Moon 31.3.0.1 with only Palefill installed and load up, for example, this repository, and start clicking on buttons for a while to trigger as many of these soft navigations as possible (Try clicking on the issues tab, then an issue, then back to the issues tab, then to the code tab, and navigate the code for a short while, for example), and then close all of your GitHub tabs completely and go to
about:memory
and click all of the manual GC buttons (at least two times each for good measure -- GC, CC and minimize memory usage) and then create a memory report by clicking the Measure button, you'll see that every GitHub page you navigated to has now become a ghost window, consuming a chunk of memory forever.According to various Mozilla Bugzilla posts (https://bugzilla.mozilla.org/show_bug.cgi?id=1143912 for example) these ghost windows are usually caused by misbehaving add-ons maintaining references to unattached windows long after they've been closed. As this issue occurs with only Palefill installed, and only on a site that Palefill operates on, it's possible something is wrong with the way Palefill handles the page and probably deserves some analysis, although it could be a bug in Pale Moon too.
The ghost windows persist if you continue using the browser for other sites long after closing the GitHub tabs. In fact, if you re-use the same tab you used for GitHub to navigate to another site (e.g
startpage.com
), sometimes all of the pages navigated to from within that tab keep becoming ghost windows, so you can quickly accumulate dozens of ghost windows for every single website you've ever visited in that tab since using GitHub. This can fairly easily result in gigabytes of memory usage.Issue occurs with Palefill 1.21 and 1.22, I haven't tested any versions below that.
The text was updated successfully, but these errors were encountered: