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

Slow startup with launch4j until FlatLaf v1.1 #319

Closed
Ph4ntom01 opened this issue May 3, 2021 · 8 comments
Closed

Slow startup with launch4j until FlatLaf v1.1 #319

Ph4ntom01 opened this issue May 3, 2021 · 8 comments
Labels
custom window decorations Related to using FlatLaf custom window decorations
Milestone

Comments

@Ph4ntom01
Copy link

From version 1.1 to 1.1.2, the execution of my newly exe program (converted with launch4j) is very slow.

Here is the code is use to set FlatLaf :

public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(new FlatDarculaLaf());
    } catch (UnsupportedLookAndFeelException e) {
        e.printstacktrace();
    }
    SwingUtilities.invokeLater(Swappy::createAndShowGUI);
}

But everything is fine with version < 1.1
The thing is, I can't use embedded menu bar because I am obliged to use version 1.0

PS : this issue appears to only show when I convert my jar file to an exe file with launch4j.

@Ph4ntom01 Ph4ntom01 changed the title Slow startup with launch4j until FlatLaf 1.1 Slow startup with launch4j until FlatLaf v1.1 May 3, 2021
@DevCharly
Copy link
Collaborator

Tried to reproduce this with launch4j 3.14 and FlatLaf Demos 1.0 and 1.1.2, but can't notice any difference.

Could you share your launch4j configuration file?

You could also try to build an exe from flatlaf-demo-1.1.2.jar and test whether startup is slow.

@tanrikut
Copy link

I experience something similar, in most of my program launchs from Eclipse IDE, my program waits for FlatLaf to load a native DLL from temp directory. The weird thing is sometimes it does not wait.

@Ph4ntom01
Copy link
Author

Here is my launch4j configuration file

<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
  <dontWrapJar>false</dontWrapJar>
  <headerType>gui</headerType>
  <jar>E:\Ph4ntom\Documents\Swappy\Swappy.jar</jar>
  <outfile>E:\Ph4ntom\Documents\Swappy\Swappy.exe</outfile>
  <errTitle></errTitle>
  <cmdLine></cmdLine>
  <chdir>.</chdir>
  <priority>normal</priority>
  <downloadUrl>http://java.com/download</downloadUrl>
  <supportUrl></supportUrl>
  <stayAlive>false</stayAlive>
  <restartOnCrash>false</restartOnCrash>
  <manifest></manifest>
  <icon>E:\Ph4ntom\Documents\Swappy\img\icon128.ico</icon>
  <singleInstance>
    <mutexName>Swappy</mutexName>
    <windowTitle>Swappy</windowTitle>
  </singleInstance>
  <jre>
    <path>./jre</path>
    <bundledJre64Bit>false</bundledJre64Bit>
    <bundledJreAsFallback>false</bundledJreAsFallback>
    <minVersion>11</minVersion>
    <maxVersion></maxVersion>
    <jdkPreference>jdkOnly</jdkPreference>
    <runtimeBits>64/32</runtimeBits>
  </jre>
</launch4jConfig>

But I tried to reproduce this with FlatLaf Demo 1.1.2 and same thing, slow startup. I am using private JDK 11.0.11.

@DevCharly
Copy link
Collaborator

@tanrikut that's interesting.

Could you please start your program with the Eclipse debugger
and hit the "Suspend" button (in toolbar, or "Run > Suspend" in menu) while the program waits
and post the stack of the AWT-EventQueue-0 thread here?
(in Eclipse Debug view, expand node Thread [AWT-EventQueue-0],
right-click on this node and select "Copy Stack" from popup menu)

@DevCharly
Copy link
Collaborator

@Ph4ntom01 I can now reproduce the slow startup, but only with your private JDK 11.0.11,
which I downloaded from here: https://github.com/Ph4ntom01/Swappy/releases/tag/v1.0

With other JDKs on my machine, it starts fast.

Your private JDK seems to be incomplete.
It contains only jre/bin and jre/lib folders.

If I copy jre/conf from another JDK 11 to your JDK, then it starts fast.

@DevCharly
Copy link
Collaborator

Seems that the initialization of the random number generator (SecureRandom) becomes very slow if jre/conf/ folder is missing. SecureRandom is used in Files.createTempFile():

"AWT-EventQueue-0" #17 prio=6 os_prio=0 cpu=203.13ms elapsed=7.43s tid=0x00000284d76e2800 nid=0x1d98 in Object.wait()  [0x000000e30e4fc000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(java.base@11.0.11/Native Method)
        - waiting on <0x000000061ffb7330> (a sun.security.provider.SeedGenerator$ThreadedSeedGenerator)
        at java.lang.Object.wait(java.base@11.0.11/Object.java:328)
        at sun.security.provider.SeedGenerator$ThreadedSeedGenerator.getSeedByte(java.base@11.0.11/SeedGenerator.java:404)
        - waiting to re-lock in wait() <0x000000061ffb7330> (a sun.security.provider.SeedGenerator$ThreadedSeedGenerator)
        at sun.security.provider.SeedGenerator$ThreadedSeedGenerator.getSeedBytes(java.base@11.0.11/SeedGenerator.java:393)
        at sun.security.provider.SeedGenerator.generateSeed(java.base@11.0.11/SeedGenerator.java:144)
        at sun.security.provider.AbstractDrbg.lambda$static$0(java.base@11.0.11/AbstractDrbg.java:524)
        at sun.security.provider.AbstractDrbg$$Lambda$84/0x0000000800165440.getEntropy(java.base@11.0.11/Unknown Source)
        at sun.security.provider.AbstractDrbg.getEntropyInput(java.base@11.0.11/AbstractDrbg.java:507)
        at sun.security.provider.AbstractDrbg.getEntropyInput(java.base@11.0.11/AbstractDrbg.java:494)
        at sun.security.provider.AbstractDrbg.instantiateIfNecessary(java.base@11.0.11/AbstractDrbg.java:696)
        - locked <0x000000061ffb7008> (a sun.security.provider.HashDrbg)
        at sun.security.provider.AbstractDrbg.engineNextBytes(java.base@11.0.11/AbstractDrbg.java:378)
        at sun.security.provider.AbstractDrbg.engineNextBytes(java.base@11.0.11/AbstractDrbg.java:334)
        at sun.security.provider.AbstractDrbg$SeederHolder.lambda$static$0(java.base@11.0.11/AbstractDrbg.java:558)
        at sun.security.provider.AbstractDrbg$SeederHolder$$Lambda$85/0x0000000800164040.getEntropy(java.base@11.0.11/Unknown Source)
        at sun.security.provider.AbstractDrbg.getEntropyInput(java.base@11.0.11/AbstractDrbg.java:507)
        at sun.security.provider.AbstractDrbg.getEntropyInput(java.base@11.0.11/AbstractDrbg.java:494)
        at sun.security.provider.AbstractDrbg.instantiateIfNecessary(java.base@11.0.11/AbstractDrbg.java:696)
        - locked <0x000000061ffb6cd8> (a sun.security.provider.HashDrbg)
        at sun.security.provider.AbstractDrbg.engineNextBytes(java.base@11.0.11/AbstractDrbg.java:378)
        at sun.security.provider.AbstractDrbg.engineNextBytes(java.base@11.0.11/AbstractDrbg.java:334)
        at sun.security.provider.DRBG.engineNextBytes(java.base@11.0.11/DRBG.java:233)
        at java.security.SecureRandom.nextBytes(java.base@11.0.11/SecureRandom.java:751)
        at java.security.SecureRandom.next(java.base@11.0.11/SecureRandom.java:808)
        at java.util.Random.nextLong(java.base@11.0.11/Random.java:424)
        at java.nio.file.TempFileHelper.generatePath(java.base@11.0.11/TempFileHelper.java:57)
        at java.nio.file.TempFileHelper.create(java.base@11.0.11/TempFileHelper.java:126)
        at java.nio.file.TempFileHelper.createTempFile(java.base@11.0.11/TempFileHelper.java:160)
        at java.nio.file.Files.createTempFile(java.base@11.0.11/Files.java:868)
        at com.formdev.flatlaf.util.NativeLibrary.createTempFile(NativeLibrary.java:150)
        at com.formdev.flatlaf.util.NativeLibrary.loadLibraryFromJar(NativeLibrary.java:98)
        at com.formdev.flatlaf.util.NativeLibrary.<init>(NativeLibrary.java:58)
        at com.formdev.flatlaf.ui.FlatWindowsNativeWindowBorder.getInstance(FlatWindowsNativeWindowBorder.java:106)
        at com.formdev.flatlaf.ui.FlatNativeWindowBorder.initialize(FlatNativeWindowBorder.java:262)
        at com.formdev.flatlaf.ui.FlatNativeWindowBorder.isSupported(FlatNativeWindowBorder.java:68)
        at com.formdev.flatlaf.ui.FlatNativeWindowBorder.install(FlatNativeWindowBorder.java:76)
        at com.formdev.flatlaf.ui.FlatRootPaneUI.installNativeWindowBorder(FlatRootPaneUI.java:143)
        at com.formdev.flatlaf.ui.FlatRootPaneUI.installUI(FlatRootPaneUI.java:98)
        at javax.swing.JComponent.setUI(java.desktop@11.0.11/JComponent.java:685)
        at javax.swing.JRootPane.setUI(java.desktop@11.0.11/JRootPane.java:449)
        at javax.swing.JRootPane.updateUI(java.desktop@11.0.11/JRootPane.java:459)
        at javax.swing.JRootPane.<init>(java.desktop@11.0.11/JRootPane.java:353)
        at javax.swing.JFrame.createRootPane(java.desktop@11.0.11/JFrame.java:279)
        at javax.swing.JFrame.frameInit(java.desktop@11.0.11/JFrame.java:258)
        at javax.swing.JFrame.<init>(java.desktop@11.0.11/JFrame.java:181)
        at com.formdev.flatlaf.demo.DemoFrame.<init>(DemoFrame.java:53)
        at com.formdev.flatlaf.demo.FlatLafDemo.lambda$main$0(FlatLafDemo.java:58)

Resources:

To avoid slow startup, I'll replace Files.createTempFile() with something else...

DevCharly added a commit that referenced this issue May 12, 2021
@DevCharly
Copy link
Collaborator

Should be fixed in main branch. Please try the latest snapshot:
https://github.com/JFormDesigner/FlatLaf#snapshots

@DevCharly DevCharly added this to the 1.2 milestone May 12, 2021
@DevCharly DevCharly added the custom window decorations Related to using FlatLaf custom window decorations label May 13, 2021
@Ph4ntom01
Copy link
Author

Thanks for the information about conf folder and yes, It works now with your latest snapshot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom window decorations Related to using FlatLaf custom window decorations
Projects
None yet
Development

No branches or pull requests

3 participants