RESOLVED CONFIGURATION CHANGED 276167
Audit all uses of IsStrongCallback
https://bugs.webkit.org/show_bug.cgi?id=276167
Summary Audit all uses of IsStrongCallback
Ryan Reno
Reported 2024-07-02 23:26:21 PDT
As of 280611@main callbacks are now Weak by default. The owning JS wrapper/C++ object needs to manage the callback lifetime. In the interim, the prior behavior of callbacks being Strong GC roots is maintained via the IsStrongCallback attribute. We should audit all of these callbacks and properly manage the lifetime of the object via visitAdditionalChildren/WebCore Opaque Roots, and any other lifetime management scheme we have available to us. Strong callbacks are a bit of a memory leak trap so ideally we can remove all uses of IsStrongCallback in time.
Attachments
Radar WebKit Bug Importer
Comment 1 2024-07-02 23:26:29 PDT
Ryan Reno
Comment 2 2024-07-05 14:24:29 PDT
I'm learning that it's probably not ideal to remove ALL uses of IsStrongCallback. I've found two legitimate uses so far. One is when the callback is "ephemeral". In other words, if there is no owning object and it is scheduled to run in the next run loop/upon promise resolution (examples are requestAnimationFrame's callback and Notification.requestPermission, respectively). Additionally, if the owning object is an ActiveDOMObject, we can remove the Ref/RefPtr to the callback in ActiveDOMObject::stop which greatly simplifies lifetime management over using JSC::Weak and visitAdditionalChildren.
Ryan Reno
Comment 3 2024-07-16 10:49:53 PDT
After discussing with rniwa we settled on a design which allows us to remove IsStrongCallback entirely which landed in 280975@main
Note You need to log in before you can comment on or make changes to this bug.