Bug 2037269

Summary: WebKit browser scrollbars not always correctly displayed if overlay scrollbars are disabled
Product: Red Hat Enterprise Linux 9 Reporter: Simeon Andreev <simeon.andreev>
Component: webkit2gtk3Assignee: Michael Catanzaro <mcatanza>
Status: CLOSED ERRATA QA Contact: Michal Odehnal <modehnal>
Severity: medium Docs Contact:
Priority: medium    
Version: 9.0CC: sbarcomb, tpelka, tpopela, vrajput
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: webkit2gtk3-2.34.6-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-17 12:34:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Deadline: 2022-02-28   
Attachments:
Description Flags
Recording of using the reproducer from the description, showcasing the scrollbar bug. none

Description Simeon Andreev 2022-01-05 10:52:05 UTC
Created attachment 1849011 [details]
Recording of using the reproducer from the description, showcasing the scrollbar bug.

Description of problem:

See WebKit bugzilla ticket: https://bugs.webkit.org/show_bug.cgi?id=234874

We observe broken scrollbars with disabled overlay scrollbars in Eclipse, see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=546870

* https://bugs.eclipse.org/bugs/attachment.cgi?id=278446 (screenshot)
* https://bugs.eclipse.org/bugs/attachment.cgi?id=278447 (recording)

Screenshot and recording from the Eclipse bugs are from RHEL 7.4, where the behavior was slightly different. On RHEL 7.9+, the scrollbars are "represented" by black bars; on RHEL 7.4 (and RHEL 7.2 I believe), the area of the scrollbars has painting artifacts.


Version-Release number of selected component (if applicable):

Red Hat Enterprise Linux release 9.0 Beta (Plow)
gtk3-3.24.30-3.el9.x86_64
webkit2gtk3-2.32.3-2.el9.x86_64

How reproducible:

Run snippet provided below.

Steps to Reproduce:

1. Create an .html file "javadoc.html" to display, with contents:

<html>
<head>
<style CHARSET="ISO-8859-1" TYPE="text/css">
html         { font-size: 10pt; }
</style>
</head>
<body style="overflow:scroll;" text="#1a1a1a" bgcolor="#ffffff">
<h5>
<div style='word-wrap: break-word; position: relative; margin-left: 20px; padding-top: 2px; '>
<a href='invalid_link'>
<img alt='Open Declaration' style='border:none; position: absolute; width: 16px; height: 16px; left: -21px; ' src='file:invalid_path.png'/>
</a>void <a class='header' href='invalid_link'>java</a>.<a class='header' href='invalid_link'>io</a>.<a class='header' href='invalid_link'>PrintStream</a>.println(<span style='font-weight:normal;'></span>int x)
</div>
</h5>
<br><p>Prints an integer and then terminate the line.  This method behaves as
 though it invokes <code><a href='invalid_link'>print(int)</a></code> and then
 <code><a href='invalid_link'>println()</a></code>.<dl><dt>Parameters:</dt><dd><b>x</b>   The <code>int</code> to be printed.</dd></dl>
</body>
</html>

2. Create the GTK3 snippet "browser.cpp" with contents:

#include <gtk/gtk.h>
#include <webkit2/webkit2.h>


static void destroyWindowCb(GtkWidget* widget, GtkWidget* window);
static gboolean closeWebViewCb(WebKitWebView* webView, GtkWidget* window);

// gcc -g browser.cpp  `pkg-config --cflags --libs  webkit2gtk-4.0 gtk+-3.0` -o BrowserExample && ./BrowserExample

int main(int argc, char* argv[])
{
    // Initialize GTK+
    gtk_init(&argc, &argv);

    // Create a window that will contain the browser instance
    GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_default_size(GTK_WINDOW(main_window), 400, 300);

    // Create a browser instance
    WebKitWebView *webView = WEBKIT_WEB_VIEW(webkit_web_view_new());

    // Put the browser area into the main window
    gtk_container_add(GTK_CONTAINER(main_window), GTK_WIDGET(webView));

    // Set up callbacks so that if either the main window or the browser instance is
    // closed, the program will exit
    g_signal_connect(main_window, "destroy", G_CALLBACK(destroyWindowCb), NULL);
    g_signal_connect(webView, "close", G_CALLBACK(closeWebViewCb), main_window);

    // Load a web page into the browser instance
    webkit_web_view_load_uri(webView, "file:///home/sandreev/javadoc.html");

    // Make sure that when the browser area becomes visible, it will get mouse
    // and keyboard events
    gtk_widget_grab_focus(GTK_WIDGET(webView));

    // Make sure the main window and all its contents are visible
    gtk_widget_show_all(main_window);

    // Run the main GTK+ event loop
    gtk_main();

    return 0;
}


static void destroyWindowCb(GtkWidget* widget, GtkWidget* window)
{
    gtk_main_quit();
}

static gboolean closeWebViewCb(WebKitWebView* webView, GtkWidget* window)
{
    gtk_widget_destroy(window);
    return TRUE;
}


3. Run the snippet with command line, disable overlay scrollbars:

export GTK_OVERLAY_SCROLLING=0 &&  gcc -g browser.cpp  `pkg-config --cflags --libs  webkit2gtk-4.0 gtk+-3.0` -o BrowserExample && ./BrowserExample 


Actual results:

The scrollbars are not displayed correctly. There are black bars instead of scrollbars, for most window sizes. If the window is small enough to actually require scrollbars (if overlay scrollbars were enabled) scrollbars seem to be fine.

Expected results:

The scrollbars are displayed correctly.

Additional info:

The broken scrollbars are not always seen (e.g. with .html from bug 234871, scrollbars are fine if steppers are disabled). Something in the .html snippet above seems to cause the bug; for variations of the .html (e.g. remove font size styling) I see normal scrollbars (with Adwaita theme). Maybe its the amount of text and its formatting, I'm not sure.

On the Eclipse bug, one of the previous SWT maintainers from RHEL bisected GTK3 to find the first commit which showed the problem: https://bugs.eclipse.org/bugs/show_bug.cgi?id=546870#c8

> (In reply to Eric Williams from comment #7)
> > The issue only happens on GTK3.22 or greater -- I'm currently bisecting to
> > see what broke it.
> 
> I bisected GTK and found that this patch broke it:
> https://gitlab.gnome.org/GNOME/gtk/commit/
> 9d719b99893297bdd1675217ba9a7c8575cc0d80
> 
> Specifically lines 193/194 in gdk/gdkdisplay.h. Why this is causing the
> breakage I do not know -- more investigation is needed.

I'm not sure how the changes relate to WebKit.

Comment 4 errata-xmlrpc 2022-05-17 12:34:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: webkit2gtk3), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2349

Comment 5 Simeon Andreev 2022-06-10 06:20:42 UTC
I validated the fix on RHEL 9, works as expected. Thanks!