Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FlatLaf 1.1.1 VM crash #290

Closed
Chrriis opened this issue Mar 29, 2021 · 6 comments
Closed

FlatLaf 1.1.1 VM crash #290

Chrriis opened this issue Mar 29, 2021 · 6 comments
Milestone

Comments

@Chrriis
Copy link
Contributor

Chrriis commented Mar 29, 2021

Hi!

I had an experimental project using WebSwing and I upgraded FlatLaf to give WebSwing another try. For some reasons, the VM now crashes. I am using Windows 10.

This crash could well be unrelated to FlatLaf but the crash dump makes me think FlatLaf is the culprit. I think it is because of the native code which might access handles of windows, but these do not really exist (rendering is in memory and it sends graphics directive to a client).

Is there a way to deactivate native accesses (all of them?) so that I can see if this really is the cause?

The relevant part of the crash dump:
A fatal error has been detected by the Java Runtime Environment:
EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffad7cc4e50, pid=11324, tid=15124
JRE version: OpenJDK Runtime Environment (13.0.2+8) (build 13.0.2+8)
Java VM: OpenJDK 64-Bit Server VM (13.0.2+8, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
Problematic frame:
V [jvm.dll+0x104e50]

(snip)

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j com.formdev.flatlaf.ui.FlatWindowsNativeWindowBorder$WndProc.installImpl(Ljava/awt/Window;)J+0
j com.formdev.flatlaf.ui.FlatWindowsNativeWindowBorder$WndProc.(Lcom/formdev/flatlaf/ui/FlatWindowsNativeWindowBorder;Ljava/awt/Window;)V+17
j com.formdev.flatlaf.ui.FlatWindowsNativeWindowBorder.install(Ljava/awt/Window;)V+77
j com.formdev.flatlaf.ui.FlatWindowsNativeWindowBorder.setHasCustomDecoration(Ljava/awt/Window;Z)V+6
j com.formdev.flatlaf.ui.FlatNativeWindowBorder.setHasCustomDecoration(Ljava/awt/Window;Z)V+24
j com.formdev.flatlaf.ui.FlatNativeWindowBorder.install(Ljava/awt/Window;Ljava/lang/String;)V+77
j com.formdev.flatlaf.ui.FlatNativeWindowBorder.lambda$install$0(Ljava/beans/PropertyChangeEvent;)V+18
j com.formdev.flatlaf.ui.FlatNativeWindowBorder$$Lambda$278.propertyChange(Ljava/beans/PropertyChangeEvent;)V+1
J 3453 c1 java.beans.PropertyChangeSupport.fire([Ljava/beans/PropertyChangeListener;Ljava/beans/PropertyChangeEvent;)V java.desktop@13.0.2 (39 bytes) @ 0x000001f44d28d80c [0x000001f44d28d6c0+0x000000000000014c]
j java.beans.PropertyChangeSupport.firePropertyChange(Ljava/beans/PropertyChangeEvent;)V+77 java.desktop@13.0.2
J 3427 c1 java.awt.Component.firePropertyChange(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V java.desktop@13.0.2 (59 bytes) @ 0x000001f44ce338f4 [0x000001f44ce33040+0x00000000000008b4]
j javax.swing.JComponent.addNotify()V+13 java.desktop@13.0.2
j javax.swing.JRootPane.addNotify()V+1 java.desktop@13.0.2
j java.awt.Container.addNotify()V+61 java.desktop@13.0.2
j java.awt.Window.addNotify()V+75 java.desktop@13.0.2
j java.awt.Frame.addNotify()V+72 java.desktop@13.0.2
j java.awt.Window.pack()V+28 java.desktop@13.0.2

@DevCharly
Copy link
Collaborator

Is there a way to deactivate native accesses (all of them?) so that I can see if this really is the cause?

Yes, disable at command line:

-Dflatlaf.useWindowDecorations=false

Or in Java code:

UIManager.put( "TitlePane.useWindowDecorations", false );

@Chrriis
Copy link
Contributor Author

Chrriis commented Mar 29, 2021

Setting the property seems to solve the crash. Thanks!

I wonder how hard it can be to detect that native access does not work to avoid a crash 😉

I am not sure I can provide a testing environment, but I can easily test by replacing the JAR file on my setup. Do not hesitate!

@DevCharly
Copy link
Collaborator

Have tried Webswing and could reproduce the crash.
Don't know the reason, but will have a look at it later...

Anyway, trying to use FlatLaf native window decorations in Webswing does not make any sense.
So I've disabled it for Webswing in commit 7a2d0e7

@DevCharly DevCharly added this to the 1.1.2 milestone Mar 30, 2021
@Chrriis
Copy link
Contributor Author

Chrriis commented Mar 30, 2021

I agree that using native window decoration in WebSwing does not make sense.

Just one comment on the fix, I think relying on WebSwing system property is dangerous: if a product is made to be launched both in WebSwing and regular, it might have some WebSwing related properties set.

One possible detection I used (but there may exist better!) is: Toolkit.getDefaultToolkit().getClass().getName().startsWith("org.webswing.")

Thanks a lot for the good work! 👍

@DevCharly
Copy link
Collaborator

Just one comment on the fix, I think relying on WebSwing system property is dangerous: if a product is made to be launched both in WebSwing and regular, it might have some WebSwing related properties set.

Hmm, I actually assumed that webswing.rootDir system property is only set when running on server
because it is listed in the chapter "Webswing Server and Webswing Cluster Server" here:
https://www.webswing.org/docs/20.2/configure/sysprop.html

Do you know that it is also set when not running on Webswing server?

Searched for webswing.rootDir (and ROOT_DIR_PATH) in Webswing source code.
Seems to only set/used in webswing-server subproject.
So at the moment I think it is OK.

@alexvaz83
Copy link

alexvaz83 commented Aug 18, 2023

Hi,

I'm trying flatlaf in my application, which can run on windows 10/11 and webswing.
I am having a very annoying behavior regarding dialog title decorations, and I think the cause is the commit made for this issue. In windows, my main frame and dialogs have the same decoration style on the title panel, but on webswing the main frame is just like in windows but the dialogs have the system theme decoration…
I think the problem is in the change made in this line:

public boolean getSupportsWindowDecorations() {

- if( SystemInfo.isProjector || SystemInfo.isWinPE )
+ if( SystemInfo.isProjector || SystemInfo.isWebswing || SystemInfo.isWinPE )
return false;

This method is called in JDialog class:

if (JDialog.isDefaultLookAndFeelDecorated()) {
boolean supportsWindowDecorations =
UIManager.getLookAndFeel().getSupportsWindowDecorations();
if (supportsWindowDecorations) {
setUndecorated(true);
getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
}
}

Can you change this (I even think the original crash was not on this lines) or have any ideia on how can I get the same style on JDialogs both in windows and webswing?

I tried to run, during debug, the lines inside the if ( setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG); ) and it works like a charm...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants