Closed
Bug 899354
Opened 11 years ago
Closed 11 years ago
BrowserElementParent isn't unregistering visibilityChangeHandler event listeners
Categories
(Firefox OS Graveyard :: Gaia, defect, P1)
Tracking
(blocking-b2g:leo+, firefox23 wontfix, firefox24 wontfix, firefox25 fixed, b2g18 fixed, b2g18-v1.0.0 wontfix, b2g18-v1.0.1 wontfix, b2g-v1.1hd fixed)
People
(Reporter: mccr8, Assigned: justin.lebar+bug)
References
Details
(Keywords: perf, Whiteboard: [MemShrink] [c=memory u=1.1] QARegressExclude)
Attachments
(1 file)
See bug 898990 for STR. After around 3 days of running there are around 7400 event listeners that appears to be from BEP registered on a single nsGlobalWindow. These are visibilityChangeHandler, ignoreClearCacheOn and ignoreClearCacheOff. The latter two do not appear in any Mozilla repo, so it isn't clear where they are from, but they look like they are some other BEP event listener. There are the same number of each of the three.
visibilityChangeHandler comes from here:
http://mxr.mozilla.org/mozilla-central/source/dom/browser-element/BrowserElementParent.jsm#70
Assignee | ||
Comment 1•11 years ago
|
||
The visibilityChangeHandler is meant to hang around for as long as the BEP hangs around. So what we do is, when we get a visibilitychange notification, we check whether the BEP is still alive (using a weak ref). If it's not alive, we unregister the listener.
It's not clear to me how to do better than this, without some sort of notification when an object goes away, or without an iterable weakset.
Reporter | ||
Updated•11 years ago
|
Whiteboard: [MemShrink]
Bug 887781 might be useful here.
Assignee | ||
Comment 3•11 years ago
|
||
Andrew suggested that, as a hack, we could keep a list of weakrefs and iterate over it every time we add to it. That might be sufficient, and a sufficiently small change to be OK for b2g18.
Reporter | ||
Comment 4•11 years ago
|
||
I think it is okay to use Cu.nondeterministicWeakMapKeys. It was intended to just be a testing function, but using that seems less hacky than some kind of set of XPCOM weak references that we have to manually purge. It is worrying that we can't implement this pattern in "real" JS.
Assignee | ||
Comment 5•11 years ago
|
||
I'm not going to try to fix the ignoreClearCache{On,Off} business, since that's a partner customization which we don't even have the complete source code for. It's not even clear to me whether we should be looking at that source code, given that it's not being provided in compliance with the MPL.
Summary: BrowserElementParent isn't unregistering visibilityChangeHandler event listeners (plus two others?) → BrowserElementParent isn't unregistering visibilityChangeHandler event listeners
Assignee | ||
Updated•11 years ago
|
Assignee: nobody → justin.lebar+bug
Assignee | ||
Comment 6•11 years ago
|
||
This prevents a leak when we run tests that create thousands of BrowserElementParents without ever turning the screen off.
Attachment #783343 -
Flags: review?(khuey)
Comment on attachment 783343 [details] [diff] [review]
Patch, v1: Only ever add one visibilitychange listener to BrowserElementParent's owner window.
Review of attachment 783343 [details] [diff] [review]:
-----------------------------------------------------------------
Fun.
Attachment #783343 -
Flags: review?(khuey) → review+
Assignee | ||
Comment 8•11 years ago
|
||
When you uplift this, you'll need to change 'visibilitychange' to 'mozvisibilitychange' in two places. Merge conflicts should point this out, and this should be the only non-trivial merge conflict.
Assignee | ||
Comment 9•11 years ago
|
||
Reporter | ||
Comment 11•11 years ago
|
||
On a side note, jlebar and I noticed that nsObserverService actually has a similar problem: weakly registered observers won't be cleared unless a notification happens. nsObserverService has the advantage that every observer gets notified for all topics, compared to event listeners, where only things for a particular event get triggered.
Updated•11 years ago
|
Comment 12•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Comment 13•11 years ago
|
||
Needs a branch-specific patch for uplift.
status-b2g18:
--- → affected
status-b2g18-v1.0.0:
--- → wontfix
status-b2g18-v1.0.1:
--- → wontfix
status-b2g-v1.1hd:
--- → affected
status-firefox23:
--- → wontfix
status-firefox24:
--- → wontfix
status-firefox25:
--- → fixed
Flags: needinfo?(justin.lebar+bug)
Keywords: branch-patch-needed
Target Milestone: --- → 1.1 QE5
Assignee | ||
Comment 14•11 years ago
|
||
> Needs a branch-specific patch for uplift.
I think it was just what was described in comment 8.
https://hg.mozilla.org/releases/mozilla-b2g18/rev/11bb1b0eefff
Flags: needinfo?(justin.lebar+bug)
Assignee | ||
Updated•11 years ago
|
Comment 15•11 years ago
|
||
Keywords: branch-patch-needed
Updated•11 years ago
|
Whiteboard: [MemShrink] [c=memory u=1.1] → [MemShrink] [c=memory u=1.1] QARegressExclude
You need to log in
before you can comment on or make changes to this bug.
Description
•