- From: Jonas Sicking <jonas@sicking.cc>
- Date: Fri, 6 Jul 2012 16:50:25 -0700
- To: Adam Barth <w3c@adambarth.com>
- Cc: olli@pettay.fi, Ryosuke Niwa <rniwa@webkit.org>, public-webapps <public-webapps@w3.org>, Ojan Vafai <ojan@chromium.org>, Ehsan Akhgari <ehsan@mozilla.com>, Erik Arvidsson <arv@chromium.org>, Sukolsak Sakshuwong <sukolsak@gmail.com>, Aryeh Gregor <ayg@aryeh.name>
On Thu, Jul 5, 2012 at 7:15 AM, Adam Barth <w3c@adambarth.com> wrote: > On Thu, Jul 5, 2012 at 1:37 AM, Olli Pettay <Olli.Pettay@helsinki.fi> wrote: >> On 07/05/2012 08:00 AM, Adam Barth wrote: >>> On Wed, Jul 4, 2012 at 5:25 PM, Olli Pettay <Olli.Pettay@helsinki.fi> >>> wrote: >>>> On 07/05/2012 03:11 AM, Ryosuke Niwa wrote: >>>> So, it is very much implementation detail. >>>> >>>> (And I still don't understand how a callback can be so hard in this case. >>>> There are plenty of different kinds of callback objects. >>>> new MutationObserver(some_callback_function_object) ) >>> >>> I haven't tested, by my reading of the MutationObserver implementation >>> in WebKit is that it leaks. Specifically: >>> >>> MutationObserver --retains--> MutationCallback --retains--> >>> some_callback_function_object --retains--> MutationObserver >>> >>> I don't see any code that breaks this cycle. >> >> Ok. In Gecko cycle collector breaks the cycle. But very much an >> implementation detail. >> >>> DOM events >> >> Probably EventListeners, not Events. >> >>> have a bunch of delicate code to avoid break these >>> reference cycles and avoid leaks. We can re-invent that wheel here, >> >> Or use some generic approach to fix such leaks. >> >>> but it's going to be buggy and leaky. >> >> In certain kinds of implementations. >> >>> I appreciatie that these jQuery-style APIs are fashionable at the >>> moment, but API fashions come and go. If we use this approach, we'll >>> need to maintain this buggy, leaky code forever. >> >> Implementation detail. Very much so :) > > Right, my point is that this style of API is difficult to implement > correctly, which means authors will end up suffering low-quality > implementations for a long time. Callbacks are indeed hard to implement. But it's something that you already must have solved when implementing event listeners. Ryosuke's point seems to be that this is a callback with two callback methods rather than one, which doesn't affect memory management at all. / Jonas
Received on Friday, 6 July 2012 23:51:23 UTC