RESOLVED FIXED 141641
[GTK] WebKitFrame objects are never released
https://bugs.webkit.org/show_bug.cgi?id=141641
Summary [GTK] WebKitFrame objects are never released
Carlos Garcia Campos
Reported 2015-02-16 05:08:32 PST
We relay on willDestroyFrame callback of WKBundlePageLoaderClient, but this callback is never emitted and can't be emitted. It was my fault, I thought I had tested it when I added it, but the thing is that willDestroyFrame is called from WebFrameLoaderClient::frameLoaderDestroyed(), but at that point the frame has already been detached from the page, so WebFrame::page() always returns nullptr at that point. But even if we had a WebPage pointer at that time, when the page is closed, the loader client is reset before FrameLoader::detachFromParent() si called, so when WebFrameLoaderClient::frameLoaderDestroyed() is called then loader client doesn't have callbacks attached.
Attachments
Patch (10.83 KB, patch)
2015-02-16 05:15 PST, Carlos Garcia Campos
mrobinson: review+
Carlos Garcia Campos
Comment 1 2015-02-16 05:15:23 PST
Martin Robinson
Comment 2 2015-02-16 08:12:45 PST
Comment on attachment 246647 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=246647&action=review > Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:81 > +class WebKitFrameWrapper final: public FrameDestructionObserver { I wonder if it makes sense to simply add the FrameDestructionObserver as a member of WebKitFrame? I worry about the possibility of introducing reference cycles, by wrapping the frame itself. > Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:123 > +static void webkitFrameDestroy(WebFrame* webFrame) > +{ > + webFrameMap().remove(webFrame); This should probably be called webkitFrameDestroyed or webkitFrameDestroyedCallback, I think. It doesn't destroy the frame, it just responds to the destruction.
Carlos Garcia Campos
Comment 3 2015-02-16 08:28:04 PST
(In reply to comment #2) > Comment on attachment 246647 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=246647&action=review > > > Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:81 > > +class WebKitFrameWrapper final: public FrameDestructionObserver { > > I wonder if it makes sense to simply add the FrameDestructionObserver as a > member of WebKitFrame? I worry about the possibility of introducing > reference cycles, by wrapping the frame itself. There's no possibility of ref cycles, because the only reference of WebKitFrame is owned by the wrapper that is deleted when the WebCore::Frame is destroyed. That hasn't actually changed, since current the only references is owned by the WebFrameMap. The only difference is that now the WebFrameMap contains a WebKitFrameWrapper instead of a WebKitFrame directly. The destructor is in WebKitWebPage because frames are created in WebKitWebPage, which is where the WebFrameMap is. > > Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:123 > > +static void webkitFrameDestroy(WebFrame* webFrame) > > +{ > > + webFrameMap().remove(webFrame); > > This should probably be called webkitFrameDestroyed or > webkitFrameDestroyedCallback, I think. It doesn't destroy the frame, it just > responds to the destruction. It's confusing, it responds to a WebCore::Frame destruction to destroy the WebKitFrame object. But I agree it's confusing, webFrameDestroyed() could work better.
Martin Robinson
Comment 4 2015-02-16 08:38:54 PST
Comment on attachment 246647 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=246647&action=review >>> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:123 >>> + webFrameMap().remove(webFrame); >> >> This should probably be called webkitFrameDestroyed or webkitFrameDestroyedCallback, I think. It doesn't destroy the frame, it just responds to the destruction. > > It's confusing, it responds to a WebCore::Frame destruction to destroy the WebKitFrame object. But I agree it's confusing, webFrameDestroyed() could work better. webFrameDestroyed sounds like a good name as well.
Carlos Garcia Campos
Comment 5 2015-02-16 11:03:10 PST
(In reply to comment #4) > Comment on attachment 246647 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=246647&action=review > > >>> Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:123 > >>> + webFrameMap().remove(webFrame); > >> > >> This should probably be called webkitFrameDestroyed or webkitFrameDestroyedCallback, I think. It doesn't destroy the frame, it just responds to the destruction. > > > > It's confusing, it responds to a WebCore::Frame destruction to destroy the WebKitFrame object. But I agree it's confusing, webFrameDestroyed() could work better. > > webFrameDestroyed sounds like a good name as well. Ok, that's what I proposed, so any other concern?
Martin Robinson
Comment 6 2015-02-16 14:13:00 PST
Comment on attachment 246647 [details] Patch No, this looks okay.
Carlos Garcia Campos
Comment 7 2015-02-16 23:06:26 PST
(In reply to comment #6) > Comment on attachment 246647 [details] > Patch > > No, this looks okay. Thank you!
Carlos Garcia Campos
Comment 8 2015-02-16 23:34:45 PST
Note You need to log in before you can comment on or make changes to this bug.