Tk Source Code

View Ticket
Login
Ticket UUID: 77527326e587883bda19e5d02c3580021e53d722
Title: Ttk artifacts on Ubuntu
Type: Bug Version:
Submitter: nemethi Created on: 2017-03-01 13:54:29
Subsystem: 88. Themed Tk Assigned To: fvogel
Priority: 6 Severity: Critical
Status: Closed Last Modified: 2017-03-11 14:57:55
Resolution: Fixed Closed By: fvogel
    Closed on: 2017-03-11 14:57:55
Description:
Consider the following simple script, which creates a ttk::combobox, a ttk::spinbox and a ttk::scrollbar widget:

    ttk::combobox .combo
    ttk::spinbox .spin
    ttk::scrollbar .scrl
    grid .combo -row 0 -column 0 -padx 10 -pady 10 -sticky e
    grid .spin  -row 1 -column 0 -padx 10 -pady 10 -sticky e
    grid .scrl  -row 0 -column 1 -padx 10 -pady 10 -sticky ns -rowspan 2

Run the script on Ubuntu Linux, on real hardware (i.e., not in a virtual machine).  I have tested it both on Ubuntu with the Unity desktop and on Ubuntu MATE, on two different laptops: one with AMD graphics and one with an Nvidia graphics card.  If the OS version is 16.04 or earlier, the widgets are rendered as expected.  However, with OS version 16.10 and the daily build of version 17.04, the result exhibits serious rendering problems.  To see what I mean, please visit the page

    http://www.nemethi.de/ttk_ubuntu/artifacts.html

I have used xmag to zoom in the relevant part of the window.  One can immediately see that on Ubuntu 16.10 and later, the arrow components of the three ttk widgets are cropped, making them totally ugly and unusable.

The problem is only present on recent Ubuntu versions.  X.org was upgraded in Ubuntu 16.10 from version 1.18.3 to 1.18.4.  Being that Ubuntu is one of the most popular Linux distributions, problems of this kind are for me serious show-stoppers.

The Ttk implementation draws the arrows with the aid of the Xlib functions XFillPolygon and XDrawLines.  These are known to have problems when used to draw (filled) triangles, and this Xlib bug seems to be present on Ubuntu 16.10 and later (in X.org 1.18.4) but not on Ubuntu 16.04 and earlier.

I have found a simple patch for the file ttkDefaultTheme.c that eliminates the problem:  Add the line

    XDrawPoint(display, d, gc, points[2].x, points[2].y);

at the end of the functions TtkFillArrow() and TtkDrawArrow().  This draws the missing point of the arrow on Ubuntu 16.10 and later, and does no harm on earlier OS versions where that point is already present.
User Comments: fvogel added on 2017-03-11 14:57:55:
OK thanks for your answer.

I have merged your patch to core-8-6-branch and trunk. Closing this now, thanks again for your very clear bug report and even more for the patch!

nemethi added on 2017-03-11 13:20:40:
Yes, I have checked that the original Tk scrollbars and spinboxes don't exhibit this rendering artifact.

On X11, the scrollbars are drawn with the aid of the function TkpDisplayScrollbar (see tkUnixScrlbr.c), which calls Tk_Fill3DPolygon, which in turn calls the rather complicated function Tk_Fill3DPolygon (both being implemented in tk3d.c).

Drawing the spinbox arrows in the function DisplayEntryin tkEntry.c) is somewhat easier to understand and reveals that the choice of the points passed to XFillPolygon (and XDrawLines) can be of crucial importance.

fvogel added on 2017-03-11 09:00:42:

I know what you already mentioned, I have read your report very carefully. It's just that I cannot check on my hardware/OS that the workaround you propose indeed fixes the problem. But I trust you in this.

What puzzled me is that I could not find any bug report on this problem for Xlib when I googled for it. From the comment in tkEntry.c, I understand now what you are referring to. It's a bit strange that hobbs noticed this back in May 2000 [73da332473] and that 17 years later it would be still present in Xlib. I would rather buy a problem caused by an issue in Ubuntu's driver for the Intel integrated graphics chipset, as you mentioned, than believing such a problem would have stayed unnoticed since 2000 in the xlib and unfixed since then.

Anyway, your workaround at worse is redrawing an already existing pixel, so your solution is fine with me.

One thing I'm wondering however is whether there is the same issue elsewhere in Tk, and the same workaround could need to be applied, e.g. in Tk scrollbars or spinboxes. Did you check this already perhaps? If you didn't, could you please try?


nemethi added on 2017-03-10 22:54:06:
As already mentioned, I have only seen the reported problem on Ubuntu 16.10 and 17.04, on real hardware with hybrid graphics (Intel + AMD and Intel + Nvidia).

At least XFillPolygon seems to have caused some problems many years ago in the implementation of the spin button controls, too.  The file tkEntry.c contains the comment "... we need to account for a bug in the way XFillPolygon draws triangles, ...".  I have found that XDrawLines has a similar bogus behaviour.

Thanks for committing the proposed patch!

fvogel added on 2017-03-10 22:14:48:

I have attached your snapshots directly to the present ticket for future reference.

I do not see the issue, neither on Windows Vista nor on Linux Debian 8 (where xdpyinfo | grep version spits 1.16.4 as X.Org version), both real hardware.

Do you have a pointer to what you are referring to by "Xlib functions XFillPolygon and XDrawLines. These are known to have problems when used to draw (filled) triangles"?

I have committed your proposed patch in branch bug-77527326e5. I can't check the result but at least it does not seem to harm, that's true.


nemethi added on 2017-03-09 16:57:01:
A few more observations:

1. Just like Ubuntu, the latest Solus Linux release has upgraded X.org from version 1.18.3 to 1.18.4, but it doesn't exhibit the artifact described above.  The problem seems to be Ubuntu-specific.

2. Both laptops on which I have seen the reported artifact have hybrid graphics (Intel + AMD and Intel + Nvidia, respectively).  On a classical PC (with an AMD Radeon graphics card) everything is fine (I have just tested it with the daily build of Ubuntu MATE 17.04).  From this I conclude that the problem is probably specific to Ubuntu 16.10 and later, with Intel graphics.

3. Although the reported problem seems to be caused by an issue in Ubuntu's driver for the Intel integrated graphics chipset, fact is that it is a show-stopper, which, however, can easily be eliminated with the aid of the proposed simple workaround.

Attachments: