Explain what active DOM objects do.
Created attachment 459008 [details] Patch
Created attachment 459009 [details] Patch
Comment on attachment 459009 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=459009&action=review > Introduction.md:1023 > + request.addEventListener("load", () => callback); Nit - this should either be ``` request.addEventListener("load", () => callback()); ``` or ``` request.addEventListener("load", callback); ``` > Introduction.md:1029 > +In WebKit, we consider these objects has a *pending activity*. "these objects has a" doesn't read quite so well.
Comment on attachment 459009 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=459009&action=review This is good but I think we should mention that ActiveDOMObject::virtualHasPendingActivity() should return true (or we should be hold a PendingActivity) as long as we may fire events at the object. This is a big source of confusion for people who sometimes think they only need a pending activity when they're about to fire an event (e.g. queueing an event). Fact is if you don't hold a pending activity as soon as your object is created, then its JS wrapper may get garbage collected before we even get a chance to queue an event. >> Introduction.md:1029 >> +In WebKit, we consider these objects has a *pending activity*. > > "these objects has a" doesn't read quite so well. *have
(In reply to Chris Dumez from comment #4) > Comment on attachment 459009 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=459009&action=review > > This is good but I think we should mention that > ActiveDOMObject::virtualHasPendingActivity() should return true (or we > should be hold a PendingActivity) as long as we may fire events at the > object. This is a big source of confusion for people who sometimes think > they only need a pending activity when they're about to fire an event (e.g. > queueing an event). Fact is if you don't hold a pending activity as soon as > your object is created, then its JS wrapper may get garbage collected before > we even get a chance to queue an event. Okay. How about something like this: Note that virtualHasPendingActivity should return true so long as there is a possibility of dispatching an event or invoke JavaScript in any way in the future. In other words, a pending activity should exit while an object is doing some work in C++ well before any event dispatching is scheduled. Anytime there is no pending activity, JS wrappers of an object can get deleted by the garbage collector.
> In other words, a pending activity should exit You probably mean “exist” but otherwise yes, lgtm.
(In reply to Wenson Hsieh from comment #3) > Comment on attachment 459009 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=459009&action=review > > > Introduction.md:1023 > > + request.addEventListener("load", () => callback); > > Nit - this should either be > ``` > request.addEventListener("load", () => callback()); > ``` > or > ``` > request.addEventListener("load", callback); > ``` Oops, will do the latter. > > Introduction.md:1029 > > +In WebKit, we consider these objects has a *pending activity*. > > "these objects has a" doesn't read quite so well. Rephrased it to: In WebKit, we consider such an object to have a *pending activity*. Expressing the presence of such a pending activity is a primary use case of [`ActiveDOMObject`](https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/ActiveDOMObject.h).
(In reply to Chris Dumez from comment #6) > > In other words, a pending activity should exit > > You probably mean “exist” but otherwise yes, lgtm. Fixed.
Created attachment 459093 [details] Patch for landing
Committed r293999 (250435@trunk): <https://commits.webkit.org/250435@trunk>
<rdar://problem/93006333>