WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
142225
[GTK] WebView should hold a reference on WebContext because non-default contexts are a reality
https://bugs.webkit.org/show_bug.cgi?id=142225
Summary
[GTK] WebView should hold a reference on WebContext because non-default conte...
Debarshi Ray
Reported
2015-03-03 10:38:16 PST
Now that we can create our own non-default WebKitWebContexts (see
bug 138826
), it is possible that the reference on the context is dropped before the WebKitWebView that is using it is destroyed. eg., in gnome-online-accounts, we have a custom composite widget that contains a context and a view. During destruction of the widget hierarchy, the reference on the context gets dropped in the widget's dispose before the widget's parent actually destroys the widget. This leads to a crash. WebKitWebViews should therefore hold a reference to the WebKitWebContext to avoid this. Patch will follow.
Attachments
Patch
(8.92 KB, patch)
2015-03-03 11:14 PST
,
Debarshi Ray
no flags
Details
Formatted Diff
Diff
Archive of layout-test-results from ews106 for mac-mavericks-wk2
(711.76 KB, application/zip)
2015-03-03 12:07 PST
,
Build Bot
no flags
Details
Patch
(9.56 KB, patch)
2015-03-04 03:47 PST
,
Debarshi Ray
no flags
Details
Formatted Diff
Diff
Patch
(9.58 KB, patch)
2015-03-04 05:24 PST
,
Debarshi Ray
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Debarshi Ray
Comment 1
2015-03-03 11:14:51 PST
Created
attachment 247772
[details]
Patch
WebKit Commit Bot
Comment 2
2015-03-03 11:16:54 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See
http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Martin Robinson
Comment 3
2015-03-03 11:42:54 PST
Comment on
attachment 247772
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=247772&action=review
> Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:70 > + GRefPtr<WebKitWebContext> webContext = webkit_web_context_new(); > + GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webContext.get()));
I think you might be leaking webContext here, because you didn't use adoptGRef.
Michael Catanzaro
Comment 4
2015-03-03 11:46:24 PST
Thank you! It's not really clear from the test how it works, so I would add a comment at least. I guess the test crashes without your patch applied because the web view tries to use the context in dispose. So the test relies on an implementation detail, which is OK, but not great, especially since it is easy to test without relying on that. It also would be more obvious how the test works if you actually get the context from the web view after you've unreffed your copy of the context, and try to do something with the context. Also not a bad idea to use assertObjectIsDeletedWhenTestFinishes() in a lifetime test, to test for a potential future leak. (Or an actual present tense leak, as Martin has pointed out. :)
Build Bot
Comment 5
2015-03-03 12:07:52 PST
Comment on
attachment 247772
[details]
Patch
Attachment 247772
[details]
did not pass mac-wk2-ews (mac-wk2): Output:
http://webkit-queues.appspot.com/results/5110226772557824
New failing tests: fast/css/object-fit/object-fit-canvas.html
Build Bot
Comment 6
2015-03-03 12:07:55 PST
Created
attachment 247777
[details]
Archive of layout-test-results from ews106 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Carlos Garcia Campos
Comment 7
2015-03-03 23:13:40 PST
Comment on
attachment 247772
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=247772&action=review
r- only because of the unit tests leaking.
> Source/WebKit2/ChangeLog:3 > + WebView should hold a reference on WebContext because non-default contexts are a reality
Please use the bug title here, prepare-ChangeLog should do that automatically.
>> Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:70 >> + GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webContext.get())); > > I think you might be leaking webContext here, because you didn't use adoptGRef.
Yes, I think in this particular case that we are going to explicitly unref the object, the test is more obvious if it doesn't use "smart" pointers. Even more in the case of the WebView that is a widget and it's normally deleted with gtk_widget_destroy(). We should also use assertObjectIsDeletedWhenTestFinishes() with both the context and the web view to make sure we don't leak any of those.
> Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:77 > + webContext = webkit_web_context_new(); > + webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webContext.get())); > + webView = nullptr; > + webContext = nullptr;
What's the point of doing it twice?
Debarshi Ray
Comment 8
2015-03-04 03:20:37 PST
(In reply to
comment #7
)
> > Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitWebView.cpp:77 > > + webContext = webkit_web_context_new(); > > + webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(webContext.get())); > > + webView = nullptr; > > + webContext = nullptr; > > What's the point of doing it twice?
The idea was to make sure that nothing untoward happens if the context is destroyed before with view and the other way round.
Debarshi Ray
Comment 9
2015-03-04 03:31:08 PST
(In reply to
comment #7
)
> Comment on
attachment 247772
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=247772&action=review
> > r- only because of the unit tests leaking. > > > Source/WebKit2/ChangeLog:3 > > + WebView should hold a reference on WebContext because non-default contexts are a reality > > Please use the bug title here, prepare-ChangeLog should do that > automatically.
I added the [GTK] prefix to the bug title afterwards, which might have confused the scripts. Let me see if I can convince the scripts now. :)
Debarshi Ray
Comment 10
2015-03-04 03:47:53 PST
Created
attachment 247851
[details]
Patch
Debarshi Ray
Comment 11
2015-03-04 05:24:57 PST
Created
attachment 247854
[details]
Patch
Carlos Garcia Campos
Comment 12
2015-03-04 05:35:46 PST
Comment on
attachment 247854
[details]
Patch Thanks!
WebKit Commit Bot
Comment 13
2015-03-04 06:20:11 PST
Comment on
attachment 247854
[details]
Patch Clearing flags on attachment: 247854 Committed
r180998
: <
http://trac.webkit.org/changeset/180998
>
WebKit Commit Bot
Comment 14
2015-03-04 06:20:16 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug