Open Bug 1359201 Opened 5 years ago Updated 1 year ago

Add a nukeable proxy for HttpBaseChannel::mCallbacks

Categories

(Core :: Networking: HTTP, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: mccr8, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [MemShrink:P2][necko-next])

Billm suggested that we could have a nukeable proxy for C++ references "outside" the DOM to references in the DOM. A proxy would be associated with a particular window, and would act like a strong reference until the window got nuked, on page close, when it would get cleared out. This is like a weak reference, except with a specified lifetime. This could prevent many kinds of ghost windows.

While this would be a big project to convert everything, I think implementing this just for HttpBaseChannel::mCallbacks could be a big help. Channels aren't cycle collected, and these callbacks can be implemented in JS, so it is very easy to create a cycle through content, leaking the page forever. We also don't seem to test the case of JS implemented mCallbacks very well, but they are heavily used in addons like AdblockPlus, so any bugs there can cause really bad leaks for many users.
Summary: Add a nukable proxy for HttpBaseChannel::mCallbacks → Add a nukeable proxy for HttpBaseChannel::mCallbacks
This doesn't seem completely insane.

That said, the channel contract is supposed to be that once you call AsyncOpen the channel will drop the mCallbacks pointer at some point; either before returning from AsyncOpen (on failure return) or after calling OnStopRequest (on successful return from AsyncOpen).  Now channel's haven't always _fulfilled_ this contract...
Whiteboard: [MemShrink] → [MemShrink][necko-next]
Whiteboard: [MemShrink][necko-next] → [MemShrink:P2][necko-next]
Bulk change to priority: https://bugzilla.mozilla.org/show_bug.cgi?id=1399258
Priority: -- → P2
Moving to p3 because no activity for at least 1 year(s).
See https://github.com/mozilla/bug-handling/blob/master/policy/triage-bugzilla.md#how-do-you-triage for more information
Priority: P2 → P3

Bug 1658571 is an example of bad leaks due to callbacks. I think that's nsInputStreamChannel, which is not a subclass of HttpBaseChannel.

I implemented something similar to this for service worker references to promises in bug 1409115, though it looks like the uses of it got removed at some point.

See Also: → 1658571
You need to log in before you can comment on or make changes to this bug.