Closed Bug 779224 Opened 13 years ago Closed 13 years ago

Error on content-proxy.js when a listener added to DOM element in a content script is executed

Categories

(Add-on SDK Graveyard :: General, defect, P1)

x86
macOS
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 764831

People

(Reporter: zer0, Assigned: ochameau)

Details

If in a content script we add a listener on a DOM element, when the listener is executed the web console shows the follow error: [20:05:47.219] Error: Failed to preserve wrapper of wrapped native weak map key. @ resource://jid1-swnnezz3sdbmxw-at-jetpack/api-utils/lib/loader.js -> resource://jid1-swnnezz3sdbmxw-at-jetpack/api-utils/lib/sandbox.js -> resource://jid1-swnnezz3sdbmxw-at-jetpack/api-utils/lib/content/content-proxy.js:344 Notice that the listener is properly executed, even if this error is raised. A simple add-on that reproduces the issue: require("tabs").open({ url: "data:text/html;charset=utf-8,<div>Hello</div>", onReady: function(tab) { tab.attach({ contentScript: "new " + function() { document.querySelector("div").addEventListener("click", function(){ console.log("I'm working."); }) } }) } }); Then open the web console on Firefox and click on the div, the error should be raised. Verified on Firefox 14 and 16 (OS X).
I'd guess that this error appeared with following revision: https://github.com/mozilla/addon-sdk/commit/7482b9b05283e594b6763beda520839a005f816a We are now seing many such error messages while running cfx testall but nothing seems to be broken so far. In anycase, we shouldn't be triggering error in JS console as it may block addons from being reviewed in AMO. Irakli, You faced some issues with WeakMaps while working with Namespace. Any idea what's going on and what could we do to avoid these messages?
(In reply to Alexandre Poirot (:ochameau) from comment #1) > I'd guess that this error appeared with following revision: > > https://github.com/mozilla/addon-sdk/commit/ > 7482b9b05283e594b6763beda520839a005f816a > > We are now seing many such error messages while running cfx testall but > nothing seems to be broken so far. In anycase, we shouldn't be triggering > error in JS console as it may block addons from being reviewed in AMO. > > Irakli, You faced some issues with WeakMaps while working with Namespace. > Any idea what's going on and what could we do to avoid these messages? I have not seeing anything similar, before it used to just remove key, values on GC. In order to workaround that, I was using gc-able references, which I don't think will help here. Gabor made a fix for Bug 673468, that solved mentioned misbehavior of weak maps maybe he may have a better input on this ?
Assignee: nobody → gkrizsanits
Whiteboard: [triage:followup]
It is quite unrelated to Bug 673468. And this is a problem. See: Bug 761620. We should not add anything to the weakmap that is not 'preservable' so basically not a node (if native). Because if we do that key (which is a wrapper in this case) might be simply just gc-ed... this should be fixed, and soon when patch 761620 lands this is going to throw, which would be the correct behavior.
By fix I mean not putting any native in the weakmap as key that is not a node.
Assignee: gkrizsanits → poirot.alex
Priority: -- → P1
We reverted the patch using weakmap in bug 764831, but we need to find a way to prevent leaks.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → DUPLICATE
Whiteboard: [triage:followup]
You need to log in before you can comment on or make changes to this bug.