-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
JFileChooser occasionally slow to instantiate #849
Comments
Sounds actually like a Java issue, which should be fixed in Java for all L&Fs...
What does "slow" mean? One second? Two seconds? Five seconds? Or more? Could you measure the time that
Does this mean that, without that warmup code, opening file chooser is slow when opened the first time
Unfortunately, that is not possible without rewriting the whole file chooser UI... Files for chooser combo box are filled in Private method So even if we implement a subclass of Re-implementing |
Unfortunately, I can't replicate the problem when I want to. On one occasion it took 3 to 5 seconds to open the JFileChooser dialogue box each time I tried. I've since upgraded to Windows 11. Now it only takes almost 1 second to open JFileChooser the first time and a few hundred milliseconds the second time. Obviously there are some caches at play somewhere ... |
Indeed. The MetalFileChooserUI is a bit odd to override. What I've found so far:
|
Here is a proof-of-concept to play with : |
JFileChooser is occasionally slow to instantiate.
This problem is difficult to replicate since it seems to appear on Windows when shortcuts target unavailable network drives.
There are also multiple layers of cache that interfere.
After some digging, I think that the source of the problem is the class
javax.swing.filechooser.FileSystemView
. Expecially:FileSystemView#getChooserComboBoxFiles()
-> its result may contains network drives on WindowsFileSystemView#getChooserShortcutPanelFiles()
FileSystemView#getSystemIcon(File)
FileSystemView#getSystemIcon(File, int, int)
FileSystemView#getSystemDisplayName(File)
My current solution is to call these methods in a background thread at startup in order to warmup Windows internal caches.
See https://github.com/jdemetra/jdplus-main/blob/ddf9ce62f5f89bdd957cac10f03017e01db141f8/jdplus-main-desktop/jdplus-toolkit-desktop-plugin/src/main/java/jdplus/toolkit/desktop/plugin/util/Installer.java#L284
A better solution would be to handle each call to
FileSystemView
in FlatLaf asynchronously but that might be difficult to program.What do you think ?
The text was updated successfully, but these errors were encountered: