Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Is the performance impact of DOM Mutation events limited to the document?

1,292 views
Skip to first unread message

Jorge Villalobos

unread,
Mar 28, 2012, 4:06:18 PM3/28/12
to
Hello all,

As many of you know, adding DOM Mutation event listeners can lead to a
significant performance penalty, which is why better alternatives are
being worked on (bug 641821).

In the meantime, we tolerate extensions to use them as long as they are
considered necessary for their functioning and they are limited to
content documents. We base the second requirement in the assumption that
adding DOM Mutation listeners to a content document don't affect the
performance of the main XUL window, and the performance penalty is
limited to the document and will disappear once the document is destroyed.

One add-on developer claims that this isn't the case:

https://forums.mozilla.org/addons/viewtopic.php?f=7&t=3180

He says that adding a DOM Mutation listener on any document affects the
whole browser window permanently. Is this correct? If so, we'll need to
revisit our policies around these listeners.

Thanks,

- Jorge

smaug

unread,
Mar 28, 2012, 4:48:39 PM3/28/12
to Jorge Villalobos
No.
The mutation event related flags are per (content or chrome) JS window
object, and the flags are set to inner window, not to outer window.
I don't know where iann got the idea that flags are in the outer window,
and even in that case using mutation event listeners for
content pages wouldn't really affect to chrome.


-Olli

Justin Dolske

unread,
Mar 28, 2012, 9:10:21 PM3/28/12
to
On 3/28/12 1:48 PM, smaug wrote:

>> https://forums.mozilla.org/addons/viewtopic.php?f=7&t=3180
>>
>> He says that adding a DOM Mutation listener on any document affects the
>> whole browser window permanently. Is this correct?
> No.
> The mutation event related flags are per (content or chrome) JS window
> object, and the flags are set to inner window, not to outer window.
> I don't know where iann got the idea that flags are in the outer window,
> and even in that case using mutation event listeners for
> content pages wouldn't really affect to chrome.

I just skimmed the thread, but I think you're both right because the
terminology in the thread is a little vague. :)

The flag(s?) may be on the inner-window, but I _think_ what that person
was talking about was that once set, they persist for the lifetime of
that window (window the JS global, not window the user interface). ISTR
having heard the same -- even if you remove a mutation listener,
performance of that page's DOM will continue to be crappy. Is this still
true?

[And so the worst-case fear would be an add-on that adds a mutation
listener at every page load. Even if it quickly removes the listener, it
would see as if every page was always slow.]

Justin

Boris Zbarsky

unread,
Mar 28, 2012, 9:37:21 PM3/28/12
to
On 3/28/12 6:10 PM, Justin Dolske wrote:
> The flag(s?) may be on the inner-window, but I _think_ what that person
> was talking about was that once set, they persist for the lifetime of
> that window (window the JS global, not window the user interface). ISTR
> having heard the same -- even if you remove a mutation listener,
> performance of that page's DOM will continue to be crappy. Is this still
> true?

Yes, this is correct. More precisely, performance for the operations
that would have fired that listener will continue to be pretty crappy.

-Boris
0 new messages