Move Splash initialization to EDT and make it no longer modal#9303
Move Splash initialization to EDT and make it no longer modal#9303mbien wants to merge 2 commits intoapache:masterfrom
Conversation
|
+1 to moving the Swing initialization into the right place. From what I recall, the JVM Since that PR we really should have some code in I assume by "no longer modal" you mean the window type? What changes does that introduce across OS? Curious why it was felt necessary originally? |
|
if the modal change is controversial I can revert it. This is the first of a series of startup optimization PRs - I started with the simple changes. The modality issue was just a drive by change since I had to test it anyway but not the goal. edit: one aspect where this is useful though is while debugging. If you have a breakpoint somewhere in the initialization phase the modal splash is often in the way when wanting to see the debugger. |
|
No issue with the modal revert in my opinion, even if it does bring that old issue back in fixing another one. I'd still like @eirikbakke opinion as he made the changes in #1246 I'm also curious looking at the docs for SplashScreen to revisit why using that support was not enough for hi-dpi. Once that's resolved I'll see if I can fix that WM_CLASS issue in here too, as the workaround in the installers is a little fragile. |
|
Thanks for this! Reading over the Splash class, it does not seem to be very thread-safe, nor does it document which thread may access each method. My impression is that the Splash class is externally accessed from the "main" thread, i.e. thread on which main(String args[]) was originally called. Is that right? For example, SplashComponent (comp) is constructed on the main thread, though it really should be constructed on the EDT. After this PR, it is added to the Frame (frame) on the EDT. In another example, SplashPainter.barLength is updated on the main thread and read on the EDT, without synchronization or "volatile" anywhere. Perhaps we'd need to clean up the rest of the threading issues in this class, before we can safely move any of the code between threads? It's possible that some of this worked only by accident before. On the modality thing: Sure, sounds good to make it non-modal. I tested it on MacOS and didn't see any problems with it. On the USE_LAUNCHER_SPLASH = false thing: I could not get this working with HiDPI on Windows in the past. It's also quite a lot of complexity spent on getting the splash screen to show just a tiny bit earlier in the startup cycle. I don't think it's worth trying to reintroduce it. (On the contrary, it might be a good cleanup to just get rid of the related code, e.g. the part that stores the png of the splash screen to make it available for the splash parameter on next startup etc.) On WM_CLASS: It's good to have this set properly, yes! Is your concern that it is not being set on the splash screen frame, only on the eventual main window? |
overlooked that one. will try to move that somewhere else too after I entangled the spaghetti code I just realized that |
|
this is a mess. The test only worked because it completed before the EDT ran. netbeans/platform/core.startup/src/org/netbeans/core/startup/Splash.java Lines 448 to 450 in 26a05a6 |
- about 100ms faster startup (main method duration measured) and technically more correct anyway - use JFrame to get double buffering (no progress bar flicker during repaint) - other change: splash window is no longer modal - code renovations
|
Tried to make this work without rewriting everything. Also switched to JFrame too so that the progress bar doesn't flicker on update. |
Well, it also has the benefit of not having
The problem is not that it isn't set, but that it's set to the default. If you start up the toolkit in the main thread, you'll get the name of the main class, but off another thread like we are, the splash gets This started being a problem when we stopped using the JDK splash. And why we get duplicate icons in Linux docks if relying solely on matching against |
Oh, interesting. So the JVM splash becomes a possible workaround. There seems to be two options:
Might be good for a separate PR after this one is merged, since I suspect the threading and cleanup stuff will make this one complex enough already. (EDIT Also, is it so that not having WM_CLASS set on the splash screen also solved the duplicate-taskbar-icon problem on Linux? Then a third option would be to un-set WM_SCALE in Splash.java....) |
|
Yes, let's get @mbien changes in first, and then consider this problem. Let's keep |
|
yep lets try to get the discussion back to this PR. This is primarily about EDT offloading (which is also technically a concurrency bug fix). Secondary is the modality change which can be reverted if there are concerns. Everything else would be followups - which would be appreciated since the code would benefit from more refactoring/cleanups (or a green field rewrite of the splash functionality). |
platform/core.startup/src/org/netbeans/core/startup/Splash.java
Outdated
Show resolved
Hide resolved
platform/core.startup/src/org/netbeans/core/startup/Splash.java
Outdated
Show resolved
Hide resolved
|
I looked through the latest version. Splash.java still has various threading issues. For example:
Threading issues have also clearly been an issue in the past, see e.g. the comment "run in AWT, there were problems with accessing font metrics". So if we touch threading at all we might need to do it properly... Some things that might help:
|
this is a different category of threading problems. One tried to initialize awt and swing code on the main thread which is highly problematic. The other might miss out on an update of an integer increment, which is harmless. Worst case is that the progress is wrong by a few pixels. I can give this another pass but won't rewrite the whole thing. Esp not while the requirements are unclear given the launchers and the |
|
I suppose, the alternative to fixing everything "properly" is to just test it for a while. I'd be fine with that, too. |
|
this is now no longer a small change since I extracted the model from the UI code. |
Main#startmethod execution time measured) and technically more correct anywayJFrameto get double buffering (no progress bar flicker during repaint)have to test the dev build on other systems, esp how it interacts with the Java 6
--splashJVM feature (doesn't seem to be used from the linux launcher). I suppose that one would be still modal before its replaced but its hopefully not noticeable.more startup optimizations to come later
closes #8557