Bug 546011 - Eclipse RCP HighDPI Scaling on Linux broken with embedded JavaFX
Summary: Eclipse RCP HighDPI Scaling on Linux broken with embedded JavaFX
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.17   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Sravan Kumar Lakkimsetti CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2019-04-01 10:56 EDT by Marcel Austenfeld CLA
Modified: 2023-08-13 13:17 EDT (History)
6 users (show)

See Also:


Attachments
Screenshot Ubuntu 18.10 scale factor 2 (3000*2000 display) (840.21 KB, image/png)
2019-04-03 04:19 EDT, Marcel Austenfeld CLA
no flags Details
Running Eclipse Interface error after scale switch (332.24 KB, image/jpeg)
2019-11-19 10:33 EST, Marcel Austenfeld CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel Austenfeld CLA 2019-04-01 10:56:39 EDT
I've just release a Rich Client Platform (e3, compatibility layer, based on Eclipse 4.11 (03.2019) bundled with OpenJDK 12 and OpenJFX 12). 

The app works fine on a non high dpi display. 

However if I start the application on a high dpi Linux display with a scale factor of 2 (default on high dpi) the whole application starts unscaled and the Gui is broken.
 
In additon it seems that it is not started correctly.

I tested this on several Linux distribution and two different high dpi displays with the same effect (Ubuntu 18.10, latest Debian, Arch). 

If I set the scale factor to 1 on Gnome or KDE everything works correctly (but of course the display is tiny).

A former application release of my RCP application with GTK 2 enabled based on Eclipse 4.8 and Java 1.8.71 works correctly with the scale factor 2 on high dpi.

I tried to fix the UI behaviour with several *.ini tweaks to no avail.

If I start a downloaded Eclipse 4.11 release with OpenJDK 12 everything is scaled correctly which is strange because the RCP uses the same plugins!

So I wonder what would cause this erronous behaviour of an exported RCP application based on Eclipse 4.11.

To reproduce download and start the Bio7 Linux distribution as an example on a high dpi display here:

https://sourceforge.net/projects/bio7/

Bio7 ini content:

-startup
plugins/org.eclipse.equinox.launcher_1.5.300.v20190213-1655.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.1000.v20190125-2016
-clearPersistedState
-vm
jdk/bin/java
--launcher.appendVmargs
-vmargs
-Xms1024m
-Xmx4096m
-Dprism.lcdtext=false
-Dpython.console.encoding=UTF-8
-Dswt.enable.themedScrollBar=true
--add-modules=ALL-SYSTEM
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--module-path=jdk/javafx/lib
--add-modules=javafx.controls,javafx.base,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web
--add-opens=javafx.fxml/javafx.fxml=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.desktop/sun.awt=ALL-UNNAMED
--add-opens=java.desktop/sun.java2d.opengl=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED
--add-opens=java.desktop/java.awt.font=ALL-UNNAMED

I should mention here that also on Windows the RCP scaling shows a weird behaviour when scaling the Windows UI e.g. to 300% (200% however works fine).

Once more Eclipse itself doesn't show this behaviour.
Comment 1 Marcel Austenfeld CLA 2019-04-02 10:50:40 EDT
I could narrow this bug a little bit down. 

It seems to be related with the integrated JavaFX views which I use, e.g., for the integrated SceneBuilder (in a SceneBuilder perspective).

By chance I deleted the *.ini argument -clearPersistedState and did a shutdown with an selected pure SWT perspective.

As I started my app again it was scaled correctly as long as I stayed in perspectives with SWT views only. 

When I switched to a perspective with an integrated JavaFX view the
application scales down, paints incorrectly and shows erronous behaviour without any given information or exception. 

A very strange behaviour which maybe might be related to the embedded JavaFX.

However this only occurs with a scale factor of 2.
Comment 2 Marcel Austenfeld CLA 2019-04-03 04:19:04 EDT
Created attachment 278128 [details]
Screenshot Ubuntu 18.10 scale factor 2 (3000*2000 display)

Here a screenshot from the result starting the app on a high dpi display (3000*2000) with the Ubuntu settings at scale factor 2 (window top left).
Comment 3 Sravan Kumar Lakkimsetti CLA 2019-05-26 23:53:44 EDT
Can you please attach a sample code snippet demonstrating this problem. 

Also can you please let us know the desktop environment(KDE/Gnome) both have different implementations.
Comment 4 Sravan Kumar Lakkimsetti CLA 2019-05-27 02:32:28 EDT
After going through some documentation on the inter I found this https://wiki.archlinux.org/index.php/HiDPI#Java_applications

here it says GDK_SCALE environment variable needs to be set for the hidpi to work for swing applications. 

Can you try setting GDK_SCALE to 2 and running your application?
Comment 5 Marcel Austenfeld CLA 2019-05-27 04:56:39 EDT
I can now definetely say that it works with a pure SWT environment.

For the test I disabled all embedded JavaFX panels.

Without an opened JavaFX panel the scaling works fine.
 
However when I then open a JavaFX panel (embedded in SWT) instantly the application displays this strange behaviour with SWT.

So it seems that some actions in JavaFX in combination with SWT causes this misbehaviour.

I already wrote to the JavaFX mailing list with no answer until now:

https://mail.openjdk.java.net/pipermail/openjfx-dev/2019-April/023188.html
Comment 6 Marcel Austenfeld CLA 2019-05-27 04:57:12 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #4)
> After going through some documentation on the inter I found this
> https://wiki.archlinux.org/index.php/HiDPI#Java_applications
> 
> here it says GDK_SCALE environment variable needs to be set for the hidpi to
> work for swing applications. 
> 
> Can you try setting GDK_SCALE to 2 and running your application?

Already did that to no avail.
Comment 7 Sravan Kumar Lakkimsetti CLA 2019-05-27 05:02:19 EDT
(In reply to Marcel Austenfeld from comment #6)
> (In reply to Sravan Kumar Lakkimsetti from comment #4)
> > After going through some documentation on the inter I found this
> > https://wiki.archlinux.org/index.php/HiDPI#Java_applications
> > 
> > here it says GDK_SCALE environment variable needs to be set for the hidpi to
> > work for swing applications. 
> > 
> > Can you try setting GDK_SCALE to 2 and running your application?
> 
> Already did that to no avail.

Can you share a sample application for us to test?
Comment 8 Marcel Austenfeld CLA 2019-05-27 06:01:03 EDT
I create an RCP example with an embedded JavaFX panel which hopefully reproduces this behaviour.

It might be that an SWT Shell with an embedded JavaFX panel already shows this
highdpi problem.

However I used OpenJDK 12 with OpenJFX 11.01.
Comment 9 Marcel Austenfeld CLA 2019-05-27 06:24:49 EDT
(In reply to Sravan Kumar Lakkimsetti from comment #7)
> (In reply to Marcel Austenfeld from comment #6)
> > (In reply to Sravan Kumar Lakkimsetti from comment #4)
> > > After going through some documentation on the inter I found this
> > > https://wiki.archlinux.org/index.php/HiDPI#Java_applications
> > > 
> > > here it says GDK_SCALE environment variable needs to be set for the hidpi to
> > > work for swing applications. 
> > > 
> > > Can you try setting GDK_SCALE to 2 and running your application?
> > 
> > Already did that to no avail.
> 
> Can you share a sample application for us to test?

Maybe this application already reproduces the bug with Linux HighDpi displays:

https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/fx-swt_interoperability.htm
Comment 10 Marcel Austenfeld CLA 2019-05-27 07:47:33 EDT
I can reproduce this behaviour with this simple SWT/JavaFX example (scale Ubuntu Gnome = 2):

https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/fx-swt_interoperability.htm

If you execute this simple example the buttons are not scaled at all. If you press on the JavaFX button only the SWT button gets resized.

Already in this very simple example the SWT JavaFX interop. seems to be disturbed.

The example was tested on Windows running VirtualBox with Ubuntu Linux 19.04 installed.
Comment 11 Sravan Kumar Lakkimsetti CLA 2019-05-30 07:41:35 EDT
(In reply to Marcel Austenfeld from comment #10)
> I can reproduce this behaviour with this simple SWT/JavaFX example (scale
> Ubuntu Gnome = 2):
> 
> https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/fx-
> swt_interoperability.htm
> 
> If you execute this simple example the buttons are not scaled at all. If you
> press on the JavaFX button only the SWT button gets resized.
> 
> Already in this very simple example the SWT JavaFX interop. seems to be
> disturbed.
> 
> The example was tested on Windows running VirtualBox with Ubuntu Linux 19.04
> installed.

I am not able to fugure out on how to enable hidpi for JavaFX. Since this is not related to eclipse directly I lowering the severity
Comment 12 Marcel Austenfeld CLA 2019-06-11 07:21:57 EDT
Created a JavaFX bugreport:

https://github.com/javafxports/openjdk-jfx/issues/496
Comment 13 Marcel Austenfeld CLA 2019-10-30 07:20:44 EDT
Created Java bugreport:

https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8233181
Comment 14 Marcel Austenfeld CLA 2019-10-30 07:21:16 EDT
See also:

https://github.com/javafxports/openjdk-jfx/issues/600
Comment 15 Marcel Austenfeld CLA 2019-11-19 10:33:44 EST
Created attachment 280704 [details]
Running Eclipse Interface error after scale switch
Comment 16 Marcel Austenfeld CLA 2019-11-19 10:34:39 EST
After investigating a missing gtk clause in the javafx-swt library class FXCanvas, see:
 
https://mail.openjdk.java.net/pipermail/openjfx-dev/2019-November/023993.html

I still think this bug is related to Eclipse SWT.

When I have a running Eclipse instance at scale 100% and then switch to a 200% scale the Eclipse interface also shows interface disturbances similar to the GUI when javafx is embedded (see screenshot second attachement).

So somehow in both cases a function is called which causes this weired behaviour.

When I then restart Eclipse the interface looks fine. 

But shouldn't it work without a start?

Somehow a wrong scale factor irritates the interface.

Which function is responsible for setting the scale?
Comment 17 Marcel Austenfeld CLA 2020-02-17 04:39:11 EST
(In reply to Sravan Kumar Lakkimsetti from comment #11)

Probably the same bug:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=559199
Comment 18 Marcel Austenfeld CLA 2020-11-23 08:33:12 EST
Are there any news regarding this issue. With an RCP export based on Eclipse 4.17 

I still have the same problems.

Difference now:

When the JavaFX canvas is loaded which initialize JavaFX at startup a dialog occurs "Zoom changed - Would you like to restart....." which of course doesn't work at next startup where the same dialog is opened.

Thus, the problem is that somehow the SWT FXCanvas changes the Zoom at startup.

Is there a flag to avoid the zooming switch of the FXCanvas at startup?

See also:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=559199
Comment 19 Tanvi A CLA 2022-03-24 16:01:33 EDT
Was this issue ever resolved?
Comment 20 Cam Mannett CLA 2022-06-07 05:51:46 EDT
I'm suffering from this with Eclipse v4.23.  As the reporter noted, commenting out the FXCanvas creation fixed the SWT HiDPI issues.
Comment 21 Daniel Sagenschneider CLA 2023-08-13 13:17:27 EDT
Still having this issue on Linux

I believe FxCanvas is not catering to Linux. Should just be able to use the windows solution for Linux.

https://github.com/openjdk/jfx/blob/master/modules/javafx.swt/src/main/java/javafx/embed/swt/FXCanvas.java#L173

However, seems to be JavaFx issue and being private hard to override to provide work around.

A non-optimal work around to avoid crashing was add system property -Dswt.autoScale=false  (however, makes it very small)