JavaFX WebView shows different in real IDE vs development IDE

While developing a JavaFX UI in IntelliJ using https://github.com/JetBrains/gradle-intellij-plugin my UI looks perfect but when I build the plugin and then install it via file the text and images in the WebView look a lot worse. It's also bigger for some reason even though I've defined the preferred and max sizes.

 

This is how it looks during development:

 

But the same exact code produces this when the plugin is actually installed to a non-development IDE:

 

I've been playing with all the anti-aliasing techniques I've come across on the internet but none seem to help. I'm not sure if this is a JavaFX problem or a IntelliJ problem but I've noticed that to get it showing up like in the first picture I must use:

plugins {
id 'org.jetbrains.intellij' version '0.2.20'
}

This will ensure that when I run 'runIde' the plugin will look correct.

 

The moment I change that to the following I get the bad UI showing again (even on the development IDE):

plugins {
id 'org.jetbrains.intellij' version '0.3.0'
}

This has led me to believe that when the plugin is being installed to a normal IDE the version is somehow being auto-bumped.

I've created a simple plugin to re-create the issue: https://github.com/BFergerson/groovy-plugin-test. It's only one Groovy class long and I would appreciate any help on this. To make the balloon dialog show just hover your mouse over the gutter area.

Like I said, not sure if this is JavaFX or IntelliJ creating the issue. Looks perfect on the development IDE. Just need it to look and work the same when installed through .zip or the JetBrains plugin repository.

 

0
6 comments

It may depend on the Java version used to run IntelliJ IDEA, see https://intellij-support.jetbrains.com/hc/articles/206544879 .

1
Avatar
Permanently deleted user

Serge, that did the trick on the first try! The level of understanding the JetBrains developers have for their products is truly a thing of beauty. This does lead me to my next question though: Why does the JDK included with IntelliJ not work when my installed JDK does? The JDK included with IntelliJ is more up-to-date.


IntelliJ JDK:

IntelliJ IDEA 2018.1 (Ultimate Edition)
Build #IU-181.4203.550, built on March 26, 2018
JRE: 1.8.0_152-release-1136-b20 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

 

Installed JDK:

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

0

There is probably some regression in JetBrains Java builds related to DPI/scaling support, https://youtrack.jetbrains.com/issue/IDEA-193493 looks related.

0
Avatar
Permanently deleted user

Anton, I feel like I've run into this "sun.java2d.uiScale.enabled" property a few times while using IntelliJ. Is it turned off by default and is there any possible way to set this via a plugin? If not do I just include notice that this is ongoing issue JetBrains is working on and recommend the same fix? Feels great to have a solution. Thank you for that. Just want to understand the scope of the issue to know what to expect when I release my plugin since it relies solely on WebView for UI.

0
Avatar
Permanently deleted user

> is there any possible way to set this via a plugin

No, it's not possible, because the option takes effect when JDK starts and can not be changed in runtime. Yes, we indeed have some issues not yet resolved in the context of fractional scale HiDPI support. Sorry about that, we work to address them. As to JavaFX + fract hidpi, it's to be addressed in 2018.3. Until that, I can suggest that your plugin detects if it runs in fract hidpi mode and shows a warning to switch off the option. This is how to do that:

boolean isFractHiDPI = false;
if (UIUtil.isJreHiDPIEnabled()) {
  Window ancestor = SwingUtilities.getWindowAncestor(myJFXPanel);
  if (ancestor != null && ancestor.isShowing() {
    AffineTransform tx = ancestor.getGraphicsConfiguration().getDefaultTransform();
    isFractHiDPI = com.intellij.ui.paint.PaintUtil.isFractionalScale(tx);
  }
}

Please also note that you should detect the display change for JFXPanel and repeat the check.

1

Please sign in to leave a comment.