kaikramer / keystore-explorer

KeyStore Explorer is a free GUI replacement for the Java command-line utilities keytool and jarsigner.
https://keystore-explorer.org/
GNU General Public License v3.0
1.61k stars 265 forks source link

Java d3d causes window components redraw #497

Open lordleebo opened 1 month ago

lordleebo commented 1 month ago

Describe the bug Under specific screen/hardware conditions UI redraw fails overlapping components making it difficult for user to see properly the information and/or to use software, this is a known bug with java and high dpi screens, commonly solved by passing -Dsun.java2d.d3d=false property to JVM

To Reproduce Steps to reproduce the behavior:

  1. Open Keystore Explorer
  2. Examine a certificate
  3. Open fingerprint combox, choose any value, then move cursor over other buttons
  4. See error

Expected behavior To propely show UI

Screenshots image

Environment

kaikramer commented 1 month ago

Thanks for the bug report! Unfortunately I cannot replicate this issue on my machine - despite having almost exactly the same setup (same resolution, same OS, only 4070 instead of 1060). So we will have to find out together what's causing it...

Some questions to narrow down the possible causes:

  1. Is this running in a VM (VirtualBox, VMware, Hyper-V, Parallels)?
  2. Are you using other Java-based software? If so, does it have the same issue?
  3. From what source did you get the information that this is a known bug with Java and HighDPI screens? Do you have a link?
  4. Did you actually try to set "-Dsun.java2d.d3d=false"? And did it help?

Thank you for your effort in helping improve KSE!

kaikramer commented 1 month ago

Oh, I forgot: You seem to be using the "Windows" look&feel instead of the default "FlatLaf". For High DPI screens I really recommend one of the "FlatLaf" options, it probably won't help with this issue, but in general they work much better on High DPI.

lordleebo commented 1 month ago

Hi.

Yes I'm quite aware it does not happens to everybody, but I've been having this issue since a long time with java ui and other tools like Project Libre and Soap-UI which are java based and have the same problem, although some of these in the past worked well.

Anyways, regarding to your questions:

  1. No virtualization at all.
  2. Yes, currently SoapUI have same problem. Also run a lot of Jetbrains IDEs like IntelliJ, PyCharm..., Eclipse, Netbeans but it never happens with these. Important to notice, when running Keystore Explorer or SoapUI Nvidia alert shows up, like when playing a game notifying that in-game options are enabled for use(those for record, stream, etc)
  3. It has been a long time since I crashed into this problem, cannot remember if it was officially a reported bug, but I can try to find a source...
  4. Yes, I did, and yes it does solve the problem.

I really appreciate the time taken to read my report. Best regards!

JQ

El lun, 20 de may de 2024, 1:01 p. m., Kai Kramer @.***> escribió:

Thanks for the bug report! Unfortunately I cannot replicate this issue on my machine - despite having almost exactly the same setup (same resolution, same OS, only 4070 instead of 1060). So we will have to find out together what's causing it...

Some questions to narrow down the possible causes:

  1. Is this running in a VM (VirtualBox, VMware, Hyper-V, Parallels)?
  2. Are you using other Java-based software? If so, does it have the same issue?
  3. From what source did you get the information that this is a known bug with Java and HighDPI screens? Do you have a link?
  4. Did you actually try to set "-Dsun.java2d.d3d=false"? And did it help?

Thank you for your effort in helping improve KSE!

— Reply to this email directly, view it on GitHub https://github.com/kaikramer/keystore-explorer/issues/497#issuecomment-2120936759, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQT34275QFTDLOAYTCUISTZDI26HAVCNFSM6AAAAABH7YGFD6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRQHEZTMNZVHE . You are receiving this because you authored the thread.Message ID: @.***>

lordleebo commented 1 month ago

Oh, I forgot: You seem to be using the "Windows" look&feel instead of the default "FlatLaf". For High DPI screens I really recommend one of the "FlatLaf" options, it probably won't help with this issue, but in general they work much better on High DPI.

Found something interesting, it seems the problem only happens when using windows look&feel, for other themes cannot reproduce it.

For sure we can survive without windows theme... :)

lordleebo commented 1 month ago

I got some news... after a while testing with FlatLaf look&feel got the problem again... :(

image

kaikramer commented 1 month ago

I got some news... after a while testing with FlatLaf look&feel got the problem again... :(

That's very unfortunate...

I am a bit reluctant to set "-Dsun.java2d.d3d=false" for all users, because it seems to have negative side effects - at least for some users.

I could make it an preference option and set it programmatically, but I am not sure if I can do this early enough during application start to have an effect.

Of course there is always the option to start KSE with "java -Dsun.java2d.d3d=false -jar kse.jar", but this is obviously not very user friendly...

I wonder what the actual cause is. I am not getting this Nvidia alert that you've mentioned, maybe I should investigate in this direction.

I assumed that you are using the Java runtime that is included in kse553-setup.exe, is that correct?

lordleebo commented 1 month ago

This is the nvida alert, it popup as soon as I close the tip of the day

image

By other hand, yes i'm using the jre included with the setup file. Maybe, instead of putting sun.java2d.d3d into nim executable, you can set the options into an external file, like most java apps do (vm.options file...) and load then into the nim executable and then launch jvm with those flags, this will allow end users to provide additional flags if needed...

DevCharly commented 4 weeks ago

Version of Java: 17.0.9.0

@lordleebo have you tried newer Java versions (21 or 22)? Maybe this issue is already fixed in newer Java versions...

Yes, currently SoapUI have same problem.

Which Java version does SoapUI run in?

Also run a lot of Jetbrains IDEs like IntelliJ, PyCharm..., Eclipse, Netbeans but it never happens with these.

JetBrains IDEs ship with there own JREs. Eclipse does not use Swing. NetBeans is Swing, but maybe you use a newer Java version to run NetBeans?

kaikramer commented 3 weeks ago

Maybe, instead of putting sun.java2d.d3d into nim executable, you can set the options into an external file, like most java apps do (vm.options file...) and load then into the nim executable and then launch jvm with those flags, this will allow end users to provide additional flags if needed...

Yes, that would also be an option. But then you could just set the environment variable "JDK_JAVA_OPTIONS" instead. In both cases you have to know that you can fix the issue like that. If I add it to the preferences, there could be a description stating that it fixes possible UI issues that can happen in combination with Nvidia graphics.

Another option would be to add a FAQ section to the KSE website and suggest setting the env variable JDK_JAVA_OPTIONS to "-Dsun.java2d.d3d=false" as a workaround.

Also a good question what @DevCharly asked, maybe a newer Java release has already fixed the issue.

lordleebo commented 3 weeks ago

Version of Java: 17.0.9.0

@lordleebo have you tried newer Java versions (21 or 22)? Maybe this issue is already fixed in newer Java versions...

I did try (21) and the problem still there, especially with windows look and feel it happens 100% of the time, with other themes it does happen but not that often

image

Yes, currently SoapUI have same problem.

Which Java version does SoapUI run in?

OpenJDK 16.0.2.0

Also run a lot of Jetbrains IDEs like IntelliJ, PyCharm..., Eclipse, Netbeans but it never happens with these.

JetBrains IDEs ship with there own JREs. Eclipse does not use Swing. NetBeans is Swing, but maybe you use a newer Java version to run NetBeans?

Currently running netbeans with Java 21(Temurin), and I did find in netbeans java options this parameter -Dsun.java2d.noddraw=true, according to old docs (java 8 ) this is the same like -Dsun.java2d.d3d=false. By other hand also tried -Dsun.java2d.opengl=true which turn off Direct3D and the problem went away. It seems that the problem is related to Direct3D, according to this that's the existence reason of the -Dsun.java2d.d3d=false, I'm currently with DirectX 12, not sure about those faulty drivers they mention 20 years ago...

I tried this with Netbeans, went to config, removed -Dsun.java2d.noddraw=true and there is the same problem.

image