Bug 220620

Summary: [GTK] webkit_settings_set_enable_plugins deprecation warning breaks unit tests
Product: WebKit Reporter: Michael Gratton <mike>
Component: WebKitGTKAssignee: Michael Catanzaro <mcatanzaro>
Status: RESOLVED FIXED    
Severity: Normal CC: berto, bugs-noreply, cgarcia, ews-watchlist, gustavo, mcatanzaro
Priority: P3 Keywords: Gtk
Version: WebKit Nightly Build   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Michael Gratton 2021-01-14 02:43:27 PST
Geary unit tests are currently failing on Fedora because the warning printed about calling `webkit_settings_set_enable_plugins` (Geary sets it to false) is presumably using g_warning(), causing the test harness to bail out:

> Bail out! FATAL-WARNING: webkit_settings_set_enable_plugins is deprecated and does nothing. Plugins are no longer supported.

Please don't do this. There's no way I can keep that disabled for older versions and not get the warning with new versions without resorting to hasty hacks like preprocessor conditionals.
Comment 1 Michael Catanzaro 2021-01-15 14:02:09 PST
There's also a warning for webkit_settings_set_enable_private_browsing(), but that one looks safe to keep since it's been quite a long time since it was deprecated, and using it surely indicates an application bug.
Comment 2 Michael Catanzaro 2021-01-15 14:08:08 PST
Created attachment 417735 [details]
Patch
Comment 3 EWS Watchlist 2021-01-15 14:09:06 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 https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 4 Carlos Garcia Campos 2021-01-18 00:32:16 PST
You can temporary change the log fatal flag before calling webkit_settings_set_enable_plugins() and restore it after the call. That's what we do in WebKit tests too, using g_log_set_always_fatal().
Comment 5 Michael Gratton 2021-01-18 02:14:01 PST
> You can temporary change the log fatal flag before calling webkit_settings_set_enable_plugins() and restore it after the call.

Sure, but this call is made by an abstract base class that gets used in a lot of different places and hence different tests, so either it has to get disabled for all tests (what's the point having it then?) or it's disabled for a bunch of seemingly unrelated tests (more random boilerplate), and still requires a code fix to unbreak CI.

So I reckon it's much better that libraries just not break existing, non-problematic code in the first place.

Isn't there a convention like defining `GTK_DISABLE_DEPRECATED` for people who are interested in that?
Comment 6 Carlos Garcia Campos 2021-01-18 02:22:59 PST
(In reply to Michael Gratton from comment #5)
> > You can temporary change the log fatal flag before calling webkit_settings_set_enable_plugins() and restore it after the call.
> 
> Sure, but this call is made by an abstract base class that gets used in a
> lot of different places and hence different tests, so either it has to get
> disabled for all tests (what's the point having it then?) or it's disabled
> for a bunch of seemingly unrelated tests (more random boilerplate), and
> still requires a code fix to unbreak CI.

I see.

> So I reckon it's much better that libraries just not break existing,
> non-problematic code in the first place.

Sure, a g_warning is supposed to be harmless, tough, but it's true it's problematic for unit tests. So, maybe we can just turn that into a normal printf.

> Isn't there a convention like defining `GTK_DISABLE_DEPRECATED` for people
> who are interested in that?

We don't print a warning for every deprecated method, only when they become noop.
Comment 7 Michael Catanzaro 2021-01-18 07:15:25 PST
(In reply to Michael Gratton from comment #5)
> Isn't there a convention like defining `GTK_DISABLE_DEPRECATED` for people
> who are interested in that?

G_ENABLE_DIAGNOSTIC controls runtime deprecation warnings for properties and signals, so it seemed like a good fit for this to me....
Comment 8 Michael Gratton 2021-01-18 15:15:06 PST
Yeah the patch as-is sounds like decent practice in general.
Comment 9 Carlos Garcia Campos 2021-01-19 00:59:39 PST
Well, this is not a "normal" deprecation warning saying that the functionality will be removed in a future version, it has already been removed, and it's important to let applications know it. I don't think it's common to run applications with G_ENABLE_DIAGNOSTIC=1, what makes the warning useless. Why not just making the call conditional to the WebKit version in Geary?
Comment 10 Michael Catanzaro 2021-02-02 15:59:24 PST
The argument for not making it conditional in Geary is:

(In reply to Michael Gratton from comment #5)
> Sure, but this call is made by an abstract base class that gets used in a
> lot of different places and hence different tests, so either it has to get
> disabled for all tests (what's the point having it then?) or it's disabled
> for a bunch of seemingly unrelated tests (more random boilerplate), and
> still requires a code fix to unbreak CI.

I don't think it's important to let applications know the functionality has been removed if they are trying to *disable* plugins. That's why the proposed patch still warns only if applications are trying to *enable* plugins.
Comment 11 Carlos Garcia Campos 2021-02-03 01:33:32 PST
Comment on attachment 417735 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417735&action=review

> Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp:1910
> +    if (enabled || !g_strcmp0(g_getenv("G_ENABLE_DIAGNOSTIC"), "1"))

Ok, but let's remove the G_ENABLE_DIAGNOSTIC check.
Comment 12 Michael Catanzaro 2021-02-03 14:43:05 PST
Created attachment 419187 [details]
Patch for landing
Comment 13 EWS 2021-02-03 15:17:40 PST
Committed r272342: <https://trac.webkit.org/changeset/272342>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 419187 [details].