Bug 525957 - [GTK3][HiDPI][webkit] Browser widget is not scaled
Summary: [GTK3][HiDPI][webkit] Browser widget is not scaled
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.8   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 4.8 M7   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on: 530932
Blocks: 517055
  Show dependency tree
 
Reported: 2017-10-12 15:16 EDT by Peter Severin CLA
Modified: 2018-05-29 03:00 EDT (History)
6 users (show)

See Also:


Attachments
Welcome page on HiDPI display (106.83 KB, image/png)
2017-10-12 23:44 EDT, Peter Severin CLA
no flags Details
Infocenter on HiDPI display (121.83 KB, image/png)
2017-10-12 23:45 EDT, Peter Severin CLA
no flags Details
Javadoc on HiDPI display (130.17 KB, image/png)
2017-10-12 23:45 EDT, Peter Severin CLA
no flags Details
Welcome screen on GTK2 (152.41 KB, image/png)
2018-05-16 04:40 EDT, Sravan Kumar Lakkimsetti CLA
no flags Details
Unscaled browser GTK2 (68.18 KB, image/png)
2018-05-16 05:13 EDT, Peter Severin CLA
no flags Details
Welcome screen with Eclipse 4.8 and GTK2 (139.81 KB, image/png)
2018-05-29 00:13 EDT, Peter Severin CLA
no flags Details
Unscaled javadoc on GTK2 (94.56 KB, image/png)
2018-05-29 00:20 EDT, Peter Severin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Severin CLA 2017-10-12 15:16:28 EDT
When using Eclipse on a HiDPI display the Browser widget is not scaled. For example if the display's scale factor is x2, the browser remains scaled at x1 and so its contents is twice as small than should be.

This can be reproducing by opening the Welcome page using Help > Welcome. The issue occurs both with GTK2 and GTK3.
Comment 1 Leo Ufimtsev CLA 2017-10-12 15:30:33 EDT
Thank you for the bug report.

Hmm, it's possible that HiDPI hasn't yet been implemented for Browser widget yet. But technically it seems that webkitgtk itself has hidpi support.

Would you be able to add a screenshot? It would give me a better idea of things.
Comment 2 Peter Severin CLA 2017-10-12 23:44:40 EDT
Created attachment 270965 [details]
Welcome page on HiDPI display
Comment 3 Peter Severin CLA 2017-10-12 23:45:03 EDT
Created attachment 270966 [details]
Infocenter on HiDPI display
Comment 4 Peter Severin CLA 2017-10-12 23:45:26 EDT
Created attachment 270967 [details]
Javadoc on HiDPI display
Comment 5 Peter Severin CLA 2017-10-12 23:51:39 EDT
Leo, I've attached several examples of HiDPI issues with the Browser widget.

There are other issues with HiDPI displays that can be seen in Infocenter screenshot.

Generally I am under the impression that HiDPI support is being barely tested. I don't know if you are aware of that, but HiDPI support (at least for Linux and Windows) can be easily tested under VirtualBox even if you don't have a HiDPI monitor. If you are interested, I can take some time and create a detailed step by step guide for how to do that.
Comment 6 Leo Ufimtsev CLA 2017-10-13 10:00:39 EDT
(In reply to Peter Severin from comment #5)
> Leo, I've attached several examples of HiDPI issues with the Browser widget.
> 
> There are other issues with HiDPI displays that can be seen in Infocenter
> screenshot.
> 
> Generally I am under the impression that HiDPI support is being barely
> tested. I don't know if you are aware of that, but HiDPI support (at least
> for Linux and Windows) can be easily tested under VirtualBox even if you
> don't have a HiDPI monitor. If you are interested, I can take some time and
> create a detailed step by step guide for how to do that.

Hello Peter, 

Thank you for your screen shots. Interesting. 

Do you know, does it look any better on Windows/Cocoa, or is the content strange also?

There's been a fair bit of effort to port SWT to HiDPI, it's not fully complete thou. Thank you for bug report, it is helpful. 

I'm currently working on porting SWT webkit1 to webkit2, but afterwards I may look into adding hi-dpi support to browser also. 

A detailed step-by-step setup is probably overkill, but maybe a few bullet points with general hints on how to setup such a VM would be useful.
Comment 7 Peter Severin CLA 2017-10-13 12:33:08 EDT
Leo,

Yes, as I am developing an RCP application, so I am testing HiDPI on all platforms. Both Windows and Cocoa have good support for HiDPI. On Cocoa it works best and I have no problems to report there. There are some issues on Windows, but those a relatively minor. The Browser widget works correctly on both Windows and Cocoa.

HiDPI support on Linux however is far from being acceptable. The most blatant issues are this one and Bug 494724.

Here's how to setup a Debian system in Virtual Box for HiDPI testing. I imagine the same can be done with Fedora, however I believe you need to use an xorg session instead of Wayland. Here are the steps:

You need to add a 3200x1800 resolution option first:

# Generate modeline using
gtf 3200 1800 60
# Create and add new mode using xrandr
xrandr --newmode "3200x1800_60.00"  492.00  3200 3456 3800 4400  1800 1803 1808 1865 -hsync +vsync
# Find out display name by simply running xrandr
xrandr
# Then add more to the display
xrandr --addmode "VBOX-0" 3200x1800_60.00

Now you should have a new resolution available in the Gnome display settings. Switch to it.

# Enable 2 factor scaling using:
gsettings set org.gnome.desktop.interface scaling-factor 2

At this point you can scale the guest window down using Host+C shortcut to make it fit your monitor. Hit Host+C to restore the original size. I find this useful for inspecting HiDPI issues by viewing them closely.

The same can be done for Windows guest, but with fewer steps:

VBoxManage setextradata "Windows Guest" CustomVideoMode1 "3200x1800x16"
VBoxManage setextradata global GUI/MaxGuestResolution any

Then start the Windows guest and choose the custom resolution. One issue that I've encountered with this is that you need to uninstall Guest Additions on Windows for custom video mode to work.

I hope this helps.
Comment 8 Leo Ufimtsev CLA 2017-10-13 14:03:38 EDT
(In reply to Peter Severin from comment #7)
> Leo,
> 
> Yes, as I am developing an RCP application, so I am testing HiDPI on all
> platforms. Both Windows and Cocoa have good support for HiDPI. On Cocoa it
> works best and I have no problems to report there. There are some issues on
> Windows, but those a relatively minor. The Browser widget works correctly on
> both Windows and Cocoa.
> 
> HiDPI support on Linux however is far from being acceptable. The most
> blatant issues are this one and Bug 494724.
> ....
> I hope this helps.

Hey ya, 

Thanks for outlining this. We're having a team meeting next week to look what we'd work on next year. I've added the HiDPi business to the meeting agenda. Perhaps it's a project that we can investigate for upcoming eclipse releases. I don't have a set timeline for this, but it's on the radar.

Also thanks for VM config steps. They'll come in handy during development.
Comment 9 Wim Jongman CLA 2018-01-14 10:05:08 EST
Maybe we can discuss some workarounds since the browser is unusable on gtk HiDPI monitors.

If you have access to the HTML, the following can be done to fix the Browser widget:

	private String getScaling() {
   if (Platform.getWS().startsWith("gtk")) {
			int zoom= DPIUtil.getDeviceZoom();
			return "<style>" + "body {" + "  zoom: " + zoom + "%;" 
                    + "}</style> ";
		}
	   return "";
	}
Comment 10 Leo Ufimtsev CLA 2018-01-16 11:43:22 EST
Hi, 

At the moment we are prioritizing bugs that prevent people from moving from Gtk2 to Gtk3 and Wayland. HiDpi comes after.

But I'd be happy to review patches.
Comment 11 Wim Jongman CLA 2018-01-16 13:20:39 EST
(In reply to Leo Ufimtsev from comment #10)
> But I'd be happy to review patches.

Can you point me in the right direction?
Comment 12 Leo Ufimtsev CLA 2018-01-16 13:45:55 EST
(In reply to Wim Jongman from comment #11)
> (In reply to Leo Ufimtsev from comment #10)
> > But I'd be happy to review patches.
> 
> Can you point me in the right direction?

Hmmm, I don't know much about the HiDpi movement to be honest.

But the way it works is that there is a common widget:
org.eclipse.swt.browser.Browser

Which is implemented differently on each platform. On Gtk it's here:
org.eclipse.swt.browser.WebKit  (in Webkit/Gtk folder).

Note, the javadoc hover is read from a CSS file. Maybe the font size needs to be set properly if hidpi is enabled. Look around here for hover:
https://github.com/eclipse/eclipse.jdt.ui/blob/master/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavadocHover.java

There is also JavadocView.java for the view in eclipse. They share some common ancestor I think.
Comment 13 Sravan Kumar Lakkimsetti CLA 2018-05-07 02:47:09 EDT
Fixed as part of bug 530932
Comment 14 Sravan Kumar Lakkimsetti CLA 2018-05-09 05:11:00 EDT
verified Eclipse SDK
Version: Photon (4.8)
Build id: I20180508-2000
OS: Linux, v.4.16.6-302.fc28.x86_64, x86_64 / gtk 3.22.30, WebKit 2.20.1
Comment 15 Peter Severin CLA 2018-05-16 03:39:20 EDT
I'm testing the latest I20180515-2000 build on HiDPI display with x2 scaling. I see a regression when running with GTK2 as web browser is not scaled. There is also an issue with recently fixed getDPI method in Bug 518717 which might be related to this.
Comment 16 Sravan Kumar Lakkimsetti CLA 2018-05-16 04:40:59 EDT
Created attachment 274060 [details]
Welcome screen on GTK2

Here is the screenshot I see on GTK2. I don't have webkit for GTK2 installed so this screen is expected.
Comment 17 Peter Severin CLA 2018-05-16 05:13:08 EDT
Created attachment 274062 [details]
Unscaled browser GTK2

This is what I see running Debian stable. GTK version is 2.24.31.

org.eclipse.swt.internal.deviceZoom=200
org.eclipse.swt.internal.gdk.backend=x11
org.eclipse.swt.internal.gtk.theme=Adwaita
org.eclipse.swt.internal.gtk.version=2.24.31
Comment 18 Wim Jongman CLA 2018-05-28 05:54:52 EDT
(In reply to Peter Severin from comment #17)
> Created attachment 274062 [details]
> Unscaled browser GTK2
> 
> This is what I see running Debian stable. GTK version is 2.24.31.
> 
> org.eclipse.swt.internal.deviceZoom=200
> org.eclipse.swt.internal.gdk.backend=x11
> org.eclipse.swt.internal.gtk.theme=Adwaita
> org.eclipse.swt.internal.gtk.version=2.24.31

Ping. Is this solved or not solved? Peter what Debian version are you running?
Comment 19 Peter Severin CLA 2018-05-28 13:54:55 EDT
I am reproducing this issue with Ubuntu 16.04 too, so it's not related to Debian. My understanding is that GTK2 is not maintained anymore, which is unfortunate as at this stage GTK3 still has various issues related to HiDPI, so there is no stable GTK option at this moment.
Comment 20 Wim Jongman CLA 2018-05-28 13:58:46 EDT
(In reply to Peter Severin from comment #19)
> I am reproducing this issue with Ubuntu 16.04 too, so it's not related to
> Debian. My understanding is that GTK2 is not maintained anymore, which is
> unfortunate as at this stage GTK3 still has various issues related to HiDPI,
> so there is no stable GTK option at this moment.

I do not see this bug on

Ubuntu 18.04
V4.15-0-20-generic X86-64 / gtk 3.22.30 / webkit 2.20.2
Comment 21 Peter Severin CLA 2018-05-29 00:12:53 EDT
I am not sure we are testing the same thing. For example the screenshot attached by Sravan shows SWT-based Welcome screen and not the browser-based Welcome screen. It's a fallback method used when not correct webkit package is intalled. To test webkit correctly with GTK2 you need to have libwebkitgtk-1.0-0 package installed. Then start eclipse with SWT_GTK3=0. I'm attaching the screenshot of what welcome screen looks like in this case.
Comment 22 Peter Severin CLA 2018-05-29 00:13:28 EDT
Created attachment 274233 [details]
Welcome screen with Eclipse 4.8 and GTK2
Comment 23 Peter Severin CLA 2018-05-29 00:18:24 EDT
And just to make it clear, it's not the Welcome screen that I need to work, but the embedded browser. I'm just using Welcome screen to test webkit support. In WireframeSketcher app that I develop the embedded browser is being used for other things, and for that I ensure that the correct webkit package is installed on user system.
Comment 24 Peter Severin CLA 2018-05-29 00:20:51 EDT
Created attachment 274234 [details]
Unscaled javadoc on GTK2

Here's another example, that of Javadoc view.
Comment 25 Sravan Kumar Lakkimsetti CLA 2018-05-29 03:00:09 EDT
The problem here is we don't use native scaling in GTK2. Eclipse uses its own scaling algorithm. This the reason why a lot of native widgets doesn't scale. 

GTK3 have native scaling support so we made use of native scaling here.

Till we get native scaling it is going to be difficult to achieve this on GTK2.