Closed Bug 339415 Opened 18 years ago Closed 18 years ago

In <builtinURLs.js>, |var SinkObserver| leaks once, as reported by Leak Monitor extension

Categories

(SeaMonkey :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
seamonkey1.1alpha

People

(Reporter: philip.chee, Assigned: neil)

References

Details

(Keywords: helpwanted, memory-leak, Whiteboard: [helpwanted: TB port of p.224438])

Attachments

(7 files, 3 obsolete files)

Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060526 SeaMonkey/1.5a 1. Install the Leak Detector Extension on SeaMonkey trunk. 2. Restart SeaMonkey 3. Open a new window (CTRL+1) 4. Close the original window. 5. Leak Detector window opens with the following report: [+] [leaked object] (a58128) = [object Object] [+] onBeginLoad (a58120, chrome://communicator/content/builtinURLs.js, 12-14) = function (aSink) { gDataSourceState = (gDataSourceState | 1); debug_dump("\n-> SinkObserver:onBeginLoad: " + aSink + ", gDataSourceState=" + gDataSourceState + "\n"); } [ ] prototype (9c1540) = [object Object] [+] onInterrupt (a58050, chrome://communicator/content/builtinURLs.js, 17-19) = function (aSink) { gDataSourceState = (gDataSourceState | 2); debug_dump("\n-> SinkObserver:onInterrupt: " + aSink + ", gDataSourceState=" + gDataSourceState + "\n"); } [ ] prototype (9c15b8) = [object Object] [+] onResume (a58048, chrome://communicator/content/builtinURLs.js, 22-24) = function (aSink) { gDataSourceState = (gDataSourceState & -3); debug_dump("\n-> SinkObserver:onResume: " + aSink + ", gDataSourceState=" + gDataSourceState + "\n"); } [ ] prototype (9c1658) = [object Object] [+] onEndLoad (a58038, chrome://communicator/content/builtinURLs.js, 27-40) = function (aSink) { gDataSourceState = (gDataSourceState | 4); gDataSourceLoaded = (gDataSourceState == 5); debug_dump("\n-> onEndLoad: " + aSink + ", gDataSourceState=" + gDataSourceState + ", gDataSourceLoaded=" + gDataSourceLoaded + "\n"); if (!gDataSourceLoaded) { debug_dump("\n-> builtin URLs not loaded!\n"); return; } gBuiltinUrlsDataSource = aSink.QueryInterface(Components.interfaces.nsIRDFDataSource); debug_dump("Got gBuiltinUrlsDataSource " + gBuiltinUrlsDataSource + " with gTitleArc " + gTitleArc + " and gContentArc " + gContentArc + "\n"); } [ ] prototype (9c1670) = [object Object] [+] onError (a57c10, chrome://communicator/content/builtinURLs.js, 43-46) = function (aSink, aStatus, aErrMsg) { gDataSourceState = (gDataSourceState | 8); debug_dump("\n-> SinkObserver:onError: " + aSink + ", status=" + aStatus + ", errMsg=" + aErrMsg + ", gDataSourceState=" + gDataSourceState + "\n"); } [ ] prototype (9c1688) = [object Object]
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1a2) Gecko/20060517 SeaMonkey/1.1a] (nightly) (W98SE) Confirmed with SMv1.1a branch. This happens (only) "when closing the _first loaded_ window (either browser or jsconsole, depending on the command line I use)".
Keywords: mlk
Same leak if I startup [SMv1.1a] with "-mail" only.
The leak only happens on the first window because once that particular data source has loaded it is no longer necessary to watch for it to load. There seem to be at least three approaches to resolve this bug: 1. As documented in nsIRDFXMLSink.xml, the observer needs to be removed when it is no longer needed. 2. Instead of watching for the data source to load, check the load state manually each time we need the data source. 3. Instead of waiting for the data source to load, load the data source synchronously the first time we need it.
I had a look at <http://developer.mozilla.org/en/docs/RDF_in_Mozilla_FAQ>: 3. "You should never do a synchronous load unless you really know what you're doing: this will freeze the UI until the load completes!" Then, would it be acceptable in our case as the source is tiny and local ? Would it have any (negative/positive) (startup) performance impact ? (little gain on startup, little loss on/if first usage !?) 1. "Note that the observer will remain attached to the RDF/XML datasource unless removeXMLSinkObserver is called." No example :-< But adding |aSink.removeXMLSinkObserver(this);| works easily enough ;-> 2. I would think one of the two other options are better... Which has your preference ? *** <http://lxr.mozilla.org/mozilla/search?string=builtinURLs.js> {{ builtinURLs.js /editor/ui/dialogs/content/EdSpellCheck.xul, line 55 -- <script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/> /mail/base/content/utilityOverlay.xul, line 18 -- <script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/> /mail/components/preferences/compose.xul, line 55 -- <script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/> /mail/config/mail-jar.mn, line 41 -- content/communicator/builtinURLs.js, comm/content/communicator/builtinURLs.js /xpfe/communicator/resources/content/utilityOverlay.xul, line 24 -- src="chrome://communicator/content/builtinURLs.js"/> /xpfe/communicator/jar.mn, line 52 -- content/communicator/builtinURLs.js (resources/content/builtinURLs.js) }} (The loaders are few.) <http://lxr.mozilla.org/mozilla/search?string=loadXURL> {{ loadXURL /xpfe/communicator/resources/content/builtinURLs.js, line 153 -- function loadXURL(key) /xpfe/communicator/resources/content/builtinURLs.js, line 155 -- debug_dump("loadXURL call with " + key + "\n"); }} This function seems to be dead code: can it be deleted !? (Actually, that file calls for a few space and code improvements...) *** (for the record) [Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1a2) Gecko/20060524 SeaMonkey/1.1a] (nightly) (W98SE) I activated the |function debug_dump(msg)| feature: The .js file is loaded 1 time for each window (browser and jsconsole, in my case) during startup. I can get all the SinkObserver messages doubled if I use "Pause" in the console after the "loadDS() called". {{ -->loadDS() called for [object XULDocument] <-- -> SinkObserver:onBeginLoad: [xpconnect wrapped nsIRDFXMLSink], gDataSourceState=1 -> SinkObserver:onResume: [xpconnect wrapped nsIRDFXMLSink], gDataSourceState=1 -> SinkObserver:onInterrupt: [xpconnect wrapped nsIRDFXMLSink], gDataSourceState=3 -> SinkObserver:onResume: [xpconnect wrapped nsIRDFXMLSink], gDataSourceState=1 -> onEndLoad: [xpconnect wrapped nsIRDFXMLSink], gDataSourceState=5, gDataSourceLoaded=true Got gBuiltinUrlsDataSource [xpconnect wrapped (nsISupports, nsIRDFXMLSink, nsIRDFDataSource)] with gTitleArc [xpconnect wrapped nsIRDFResource] and gContentArc [xpconnect wrapped nsIRDFResource] }}
Assignee: general → gautheri
Summary: Memory leak in builtinURLs.js detected by Leak Detector Extension → In <builtinURLs.js>, |var SinkObserver| leaks once, as reported by Leak Detector Extension
Target Milestone: --- → seamonkey1.1alpha
> 1. "Note that the observer will remain attached to the RDF/XML datasource > unless removeXMLSinkObserver is called." > No example :-< But adding |aSink.removeXMLSinkObserver(this);| works > easily enough ;-> > Which has your preference ? I vote for [1]. Should this be done in the onEndLoad method? Don't you have to QI the interface first before invoking removeXMLSinkObserver?
{{ onEndLoad: function(aSink) { // Unhook observer. aSink.removeXMLSinkObserver(this); }} works fine ... You can find other examples with LXR.
Status: NEW → ASSIGNED
Attached patch Proposed patch v0.1 (obsolete) — Splinter Review
Something like this perhaps?
Attached patch Proposed patch v0.2 (obsolete) — Splinter Review
Drat, wrong whitespace.
Attachment #223551 - Attachment is obsolete: true
Comment on attachment 223552 [details] [diff] [review] Proposed patch v0.2 Yes, or preferably before the |if ... return;|. I'm waiting for neil's answers to prepare a patch with this and other fixes to this file...
(In reply to comment #6) > onEndLoad: function(aSink) { > // Unhook observer. > aSink.removeXMLSinkObserver(this); > works fine ... You can find other examples with LXR. Looks good to me.
(Not this bug patch, but another file needed a similar fix.) Unset the sink, |onError| too, and space nits.
Attachment #223566 - Flags: superreview?(neil)
Attachment #223566 - Flags: review?(neil)
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1a2) Gecko/20060524 SeaMonkey/1.1a] (nightly) (W98SE) This adds the 2 missing |removeXMLSinkObserver()| calls, and actually rewrite the wole file, getting rid of what looked like a "tutorial" code (back at that time).
Attachment #223552 - Attachment is obsolete: true
Attachment #223574 - Flags: superreview?(neil)
Attachment #223574 - Flags: review?(neil)
(In reply to comment #12) >Created an attachment (id=223574) Well, you certainly cleaned up that file, but before I review I'd just like to know what jag thinks with particular reference to comment 3.
Comment on attachment 223566 [details] [diff] [review] (Bv1) <pref-applications.js> Hmm... do we really want to abort this on error, such as might be caused by a new profile?
(In reply to comment #14) > (From update of attachment 223566 [details] [diff] [review] [edit]) > Hmm... do we really want to abort this on error, such as might be caused by a > new profile? With regard to the code, this is the only "other" file in the /mozilla tree that doesn't release the observer on error: see <http://lxr.mozilla.org/mozilla/search?string=removeXMLSinkObserver>. I understand/guess that onError is a terminal event (as onEndLoad is), is it not ? With regard to the feature, are you saying that we should do additional (which ?) things in the error case ?
(In reply to comment #14) >do we really want to abort this on error, such as might be caused by a new profile? It turns out that this file is ensured to exist. (In reply to comment #15) >I understand/guess that onError is a terminal event (as onEndLoad is), is it not? You always get an onEndLoad, unless of course you remove the observer earlier.
(In reply to comment #16) > (In reply to comment #14) > >do we really want to abort this on error, such as might be caused by a new profile? > It turns out that this file is ensured to exist. ... and is loaded from local/file:// not remote/http://, contrary to the other sinks. > (In reply to comment #15) > >I understand/guess that onError is a terminal event (as onEndLoad is), is it not? > You always get an onEndLoad, unless of course you remove the observer earlier. Ah... Then, I tested renaming the file or modifying its content: I get JS Errors, but onError is not called, always/only onEndLoad. I read at <http://lxr.mozilla.org/mozilla/source/rdf/base/idl/nsIRDFXMLSink.idl#56> that "[onEndLoad is] Called when an RDF/XML load completes successfully.", and I (wrongly) assumed onError would prevent that. Anway, it would seem that this file will never hit the onError case. Then, I shall not add removeXMLSinkObserver here, but add a comment instead maybe !?
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1a3) Gecko/20060603 SeaMonkey/1.1a] (nightly) (W98SE) (Bug still there, with L.M. v0.3.0.)
Summary: In <builtinURLs.js>, |var SinkObserver| leaks once, as reported by Leak Detector Extension → In <builtinURLs.js>, |var SinkObserver| leaks once, as reported by Leak Monitor extension
Comment on attachment 223574 [details] [diff] [review] (Av1) <builtinURLs.js> We're not going to go this route, it's overkill for its purpose. We can simply use a stringbundle instead. Also all the new code belongs in mozilla/suite.
Attachment #223574 - Flags: superreview?(neil)
Attachment #223574 - Flags: superreview-
Attachment #223574 - Flags: review?(neil)
In bug 328988, Pike seems to have found out the Thunderbird uses the xpfe builtinURLs.js through /mail/config/mail-jar.mn, line 41, and for retrieving one single URL from the toolkit builtinURLs.rdf - which might mean we should care not to break Thunderbird in the process. The simple solution for that would be to move our builtinURLs.js to suite/ (which should happen anyways) and make Thunderbird use the unfixed one from xpfe/
Investigation shows that the whole builtinURLS concept introduced by bug 35404 is obsolete and the handful of callers should be converted to normal stringbundle calls to some region.properties files. See http://lxr.mozilla.org/mozilla/search?string=urn%3Aclienturl and http://lxr.mozilla.org/mozilla/search?string=xlateURL for the very few uses of that obsolete mechanism that have to be changed.
This version avoids busting Thunderbird.
Assignee: gautheri → neil
Attachment #224431 - Flags: review?(kairo)
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] This looks good to me for the SeaMonkey editor side, and it still seems to work :)
Attachment #224438 - Flags: review?(kairo) → review+
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] seeking r= or moa=glazou
Attachment #224438 - Flags: superreview?(jag)
Attachment #224438 - Flags: review?(daniel.glazman)
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] r=me Neil, please use daniel@glazman.org for bugmail ; thanks
Attachment #224438 - Flags: review?(daniel.glazman) → review+
[Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1b1) Gecko/20060729 SeaMonkey/1.1a] (nightly) (W98SE) Bug still there; Waiting for "neil: superreview? (jag)"...
Attachment #224438 - Flags: superreview?(jag) → superreview+
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] I guess we still need to track down some consumers e.g. bug 337155 ;-)
True, there is a new consumer in http://lxr.mozilla.org/mozilla/source/mailnews/compose/prefs/resources/content/pref-composing_messages.js#133 which has to be fixed the same way. Additionally, we should probably apply the same fix to our other consumer of xlateURL(), which is at http://lxr.mozilla.org/mozilla/source/suite/common/pref/pref-locales.xul#163 See http://lxr.mozilla.org/mozilla/search?string=xlateURL and http://lxr.mozilla.org/mozilla/search?string=urn%3Aclienturl%3A for all current consumers - it looks to me that the urn:clienturl:toolbar: entries of builtinURLS.rdf are already unused. Should this be all done in this bug or a new one be filed? Once we've removed all users in our code, we also can remove the whole xlateURL()/builtinURLs implementation from suite/ - then Thunderbird will be the only consumers, and there's still their copy of the code in xpfe/communicator/ (which we aren't using any more).
Attachment #231293 - Flags: review?(iann_bugzilla)
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] Checkin: { 2006-07-30 03:15 neil%parkwaycc.co.uk }
Attachment #224438 - Attachment description: Same idea but using a pref. → Same idea but using a pref. [Checkin: Comment 32]
Attachment #224438 - Flags: approval-seamonkey1.1a?
Attachment #224431 - Attachment is obsolete: true
Attachment #224431 - Flags: review?(kairo)
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] Would be nice to obsolete builtinURLs on 1.8 branch as well :)
Attachment #224438 - Flags: approval-seamonkey1.1a? → approval-seamonkey1.1a+
Scott, you may want to port the following patch to Thunderbird, so we could eventually get rid of this "builtinURLs" stuff on both apps: (In reply to comment #24) > Created an attachment (id=224438) [edit] > Same idea but using a pref. (In reply to comment #30) > Once we've removed all users in our code, we also can remove the whole > xlateURL()/builtinURLs implementation from suite/ - then Thunderbird will be > the only consumers, and there's still their copy of the code in > xpfe/communicator/ (which we aren't using any more).
Comment on attachment 224438 [details] [diff] [review] Same idea but using a pref. [Checkin: Comment 32 & 35] Checkin: { 2006-07-31 13:27 neil%parkwaycc.co.uk MOZILLA_1_8_BRANCH }
Attachment #224438 - Attachment description: Same idea but using a pref. [Checkin: Comment 32] → Same idea but using a pref. [Checkin: Comment 32 & 35]
Attachment #231293 - Flags: review?(iann_bugzilla) → review+
Keywords: helpwanted
Whiteboard: [helpwanted: TB port of p.224438]
Comment on attachment 231293 [details] [diff] [review] pref-composing_messages [Checkin: Comment 36 & 38] Checkin: { 2006-08-03 01:47 neil%parkwaycc.co.uk }
Attachment #231293 - Attachment description: pref-composing_messages → pref-composing_messages [Checkin: Comment 36]
Attachment #231293 - Flags: approval-seamonkey1.1a?
Comment on attachment 231293 [details] [diff] [review] pref-composing_messages [Checkin: Comment 36 & 38] Yes, would be nice to have that on branch as well...
Attachment #231293 - Flags: approval-seamonkey1.1a? → approval-seamonkey1.1a+
Comment on attachment 231293 [details] [diff] [review] pref-composing_messages [Checkin: Comment 36 & 38] Checkin: { 2006-08-04 09:50 neil%parkwaycc.co.uk MOZILLA_1_8_BRANCH }
Attachment #231293 - Attachment description: pref-composing_messages [Checkin: Comment 36] → pref-composing_messages [Checkin: Comment 36 & 38]
Hey guys, I've started to get rid of builtinURLS.rdf for Thunderbird as well after reading this bug report. That work is happening in: Bug 328988. It is my understanding that Fx (and Tb) are going to use the following format for the add dictionaries URL: http://addons.mozilla.org/$locale/thunderbird/$appversion/dictionaries/ See: https://bugzilla.mozilla.org/show_bug.cgi?id=343076#c17 I'm wondering if the seamonkey pref should be changed to use the same format? This pref would be non-localized. If so, we could both share the same pref name and I could unfork EdSpellCheck.js if we can make SelectLanguage smart enough to do what it does today for seamonkey, while tossing the URL out to the OS for thunderbird.
mscott: It may be a good idea to do that, and maybe to even unfork the file (though I'm not yet sure where the best border between forking and not forking is in the UI anyways). Actually, I see no problem in using us the code you did in the patch there - as long as we don't have the "new" URL set, it just doesn't replace the values, if I see it correctly. We want to use the URL wanted by AMO people, but I don't feel well by using URLs that don't work yet, as our nightly testers already complain about not finding some dictionaries in the working location we're pointing to atm...
(In reply to comment #39) >If so, we could both share the same pref name and I could unfork >EdSpellCheck.js if we can make SelectLanguage smart enough to do what it does >today for seamonkey, while tossing the URL out to the OS for thunderbird. Although I really think that there should be a core function somewhere that will usefully open a URL, how about this? var ioService = Components.classes["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); uri = ioService.newURI(href, null, null); var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"] .getService(Components.interfaces.nsIExternalProtocolService); if (protocolSvc.isExposedProtocol(uri.scheme)) opener.open(href); else protocolSvc.loadUrl(uri);
I've posted a patch in Bug 328988 which unforks EdSpellCheck.js, uses the JS snippet Neil listed above for running the dictionary url. Currently I've left the seamonkey url in composer.js alone since that url actually works as opposed to the new format. Second, does seamonkey build have a XRE app info object which we use to extract the version when formatting the dictionary url?
Depends on: 328988
This patch fixes pref-locales to also go through a localized pref instead of builtinURLs. With this, we should be ready to kill the whole builtinURLs mechanism in SeaMonkey. I'm using a pref name that goes along with those used by Add-Ons, so that it probably can be reused there once Add-Ons adds a separate section for locale packs (along with switching, like for themes). Currently, it treats Language packs just like other extensions, but there are plans for the future to support them better from there.
Attachment #234600 - Flags: superreview?(neil)
Attachment #234600 - Flags: review?(neil)
Comment on attachment 234600 [details] [diff] [review] fix pref-locales to not use builtinURLs (checked in) >- openTopWin(xlateURL("urn:clienturl:viewmenu:intlwebcontent")); >+ window.open(parent.hPrefWindow.getPref("localizedstring", >+ "extensions.getMoreLocalesURL")); Put this back to openTopWin, in case we get around to making it obey tabbed browsing preferences one day ;-)
Attachment #234600 - Flags: superreview?(neil)
Attachment #234600 - Flags: superreview+
Attachment #234600 - Flags: review?(neil)
Attachment #234600 - Flags: review+
Comment on attachment 234600 [details] [diff] [review] fix pref-locales to not use builtinURLs (checked in) Checked in with Neil's nit fixed. Now I think we just need to remove the builtinURLs mechanism from SeaMonkey code :)
Attachment #234600 - Attachment description: fix pref-locales to not use builtinURLs → fix pref-locales to not use builtinURLs (checked in)
This patch removes the builtinURLs functionality from SeaMonkey now that it's unused. I'm not completely sure about the first hunk - is this file still used by Thunderbird and does it need that line? It might not, but I'm not 100% sure. I've not remove the RDF itself as it sits in xpfe/ where we still have another copy of builtinURLs.js, but it's trivial to kill all that once Thunderbird has removed its use of the mechanism as well.
Attachment #234618 - Flags: superreview?(neil)
Attachment #234618 - Flags: review?(neil)
(In reply to comment #42) > I've posted a patch in Bug 328988 which unforks EdSpellCheck.js, uses the JS > snippet Neil listed above for running the dictionary url. Nice, as you see here, we're also ready for killing builtinURLs completely now (actually, that mechanism is unused in SeaMonkey trunk as of today). > Second, does seamonkey build have > a XRE app info object which we use to extract the version when formatting the > dictionary url? Yes, we do support it in all current SeaMonkey versions.
Comment on attachment 234618 [details] [diff] [review] remove builtinURLs functionality from SeaMonkey >- <script type="application/x-javascript" src="chrome://communicator/content/builtinURLs.js"/> r+sr=me on the rest once Scott has handled this in bug 328988.
Attachment #234618 - Flags: superreview?(neil)
Attachment #234618 - Flags: superreview+
Attachment #234618 - Flags: review?(neil)
Attachment #234618 - Flags: review+
Could the last two patches be ported to the 1.8 branch ?
Serge: Theoretically they could be ported, but we wouldn't approve them to be checked in. One reason for that is that it's too late in the game (L10n for 1.1 is about to be frozen within days), another that the last one isn't even checked in on trunk yet due to the dependency on a shared file (will be fixed on trunk in bug 328988).
checked in the removal of the builtinURLS mechanism on trunk, so this should finally be completely fixed now.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
(In reply to comment #11) > Created an attachment (id=223566) [details] > (Bv1) <pref-applications.js> Serge, your patch is now a year old and has never been reviewed. But the bug is marked FIXED for quite some time. Is the review of this patch still necessary or is your patch now obsolete?
It probably belongs to a different bug, as noted when the patch was filed. Serge, please file a new bug for that patch if it is still valid in current 2.0a1pre nightlies.
Attachment #223566 - Flags: superreview?(neil)
Comment on attachment 223566 [details] [diff] [review] (Bv1) <pref-applications.js> Given the later patches on this bug, and the fact that it is marked as fixed, this request seems no longer necessary. Therefore cancelling request. If the change is still required, please put the patch on a new bug and rerequest review.
Attachment #223566 - Flags: review?(neil)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: