This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 24291 - The MDI window blinks once on the first time it is displayed
Summary: The MDI window blinks once on the first time it is displayed
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 3.x
Hardware: PC Windows XP
: P3 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: PERFORMANCE, UI
: 37701 39668 41576 50937 (view as bug list)
Depends on: 32233 24593
Blocks: 49990
  Show dependency tree
 
Reported: 2002-05-31 13:45 UTC by iformanek
Modified: 2008-12-22 23:13 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The beginnings of a fix - or at least demonstrates the problem is really where I thought it was (1.94 KB, patch)
2003-12-14 01:09 UTC, _ tboudreau
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description iformanek 2002-05-31 13:45:45 UTC
After the splash screen is hidden, after the MDI window is 
completely displayed, it is once more redrawn which causes 
it to blink. This redraw does not seem necessary and looks 
strange.
Comment 1 Marian Mirilovic 2002-05-31 14:09:49 UTC
It's reproducible on Win2000/ [jdk1.3.1](03) & [jdk1.4](fcs)
but not on Solaris8(CDE) / [jdk1.3.1](03) & [jdk1.4](fcs)
Comment 2 Peter Zavadsky 2002-06-03 14:44:20 UTC
Visible on Windows only. It seems there is performed twice the repaing
method also on linux, will investigate the cause of that.
Comment 3 Marian Mirilovic 2002-06-04 16:04:59 UTC
It's reproducible on Win2000 / [jdk1.4.1](13) too.
Comment 4 _ ttran 2002-06-06 10:51:54 UTC
does it happen with NB 3.3.x?
Comment 5 David Simonek 2002-06-06 11:14:35 UTC
Peter, try to search event queue for repaint requests and where they
come from.
Very hard to fix issue IMO.
Comment 6 Peter Zavadsky 2002-06-09 15:53:16 UTC
I already tried it (with the repaint requests). There are planned the repaint tasks for the compoents 
itself sooner, than the main window itself. It leads on Windows to paint component first, than main 
window background, and the rest of components are painted again. This is strange since, the same sequence 
doesn't lead to the same behaviour on unix sys (probably better written Repaint manager). This is the one 
problem, but not on our side.

From our side, the problem is how the GUI is constructed in a very complicated and not deterministic 
way at startup, the components are added on the fly, during the showing of main window 
in various event handlers (MainWindow#doShowWindow is the starting point). There is manipulated with the 
bounds etc.
Anyway I tried to supress it and still got the same behaviour, (there smells something, have no idea 
where), tried to make a testcase with desktop pane, but there was everything fine.

Next will investigate which build was fine as last one.

Comment 7 Peter Zavadsky 2002-06-09 16:01:59 UTC
The problem is also in 3.3.2

Will look further.
Comment 8 Peter Zavadsky 2002-06-10 14:13:29 UTC
Changing target milestone.

Reason: Solving this issue would require redesign the GUI creation part of startup 
sequence, and at the moment isn't known how to achieve the required one. It seems it 
could take more time to find it out.

Do you approve the change of target milestone?
Comment 9 iformanek 2002-06-10 17:01:04 UTC
Since this is highly visible bug which could make somewhat 
unprofessional impression (that's why it is P2), I would 
like to put some more effort into trying to fix this, 
before we give up and postpone till 4.0.
Comment 10 David Simonek 2002-06-10 17:25:04 UTC
To keep all sides informed: already several mandays was invested to
fix the bug, with no luck yet.

My opinion - I vote for concentrating on other bugs for now, simply
because there are too much other serious bugs.
However another fixing attempt in 3.4 timeframe sounds reasonable,
ASAP (means when bug emergency finishes).
Comment 11 Peter Zavadsky 2002-06-11 09:48:38 UTC
I spent more than two days with the issue already, and haven't found a
  straighforward easy soulution, even got no exact way how to solve it
in the case we weill redesign the sequence (bounds setting problem,
etc, also any other hacks in background like synch of maximized state
etc.). 
I guess it will require much more days to find out the proper solution
and fix the issue.

Ofcourse I could overlook something important. Maybe if somebody else
will try to look at the prob, it could help.
Comment 12 Marek Grummich 2002-07-22 08:57:09 UTC
Target milestone was changed from '3.4' to TBD.
Comment 13 Marek Grummich 2002-07-22 09:02:01 UTC
Target milestone was changed from '3.4' to TBD.
Comment 14 Marek Grummich 2002-07-22 09:03:12 UTC
Target milestone was changed from '3.4' to TBD.
Comment 15 Marek Grummich 2002-07-22 09:07:04 UTC
Target milestone was changed from '3.4' to TBD.
Comment 16 Marek Grummich 2002-07-22 09:07:33 UTC
Set terget milestone to TBD
Comment 17 Marek Grummich 2002-07-22 09:14:16 UTC
Set terget milestone to TBD
Comment 18 Peter Zavadsky 2002-07-23 16:44:08 UTC
Is purelly dependant on the #issue 24593. See there.
Comment 19 Jaroslav Tulach 2002-07-26 07:58:24 UTC
This bug is reported in version <= 3.4dev and still not fixed. Due to that it
forbids the release candidate for 3.4 to be promoted. Are you aware of that and
are you intensively working on the fix? If not, you should consider some
corrective action.
Comment 20 Peter Zavadsky 2002-07-26 08:17:27 UTC
There was already spent some time on the fix (see above comments).

I think following about that: The possible fix is in no way easy. 
It requires completely redesign the startup of GUI. The current state
is complicated due to a solution of another kind of problems
(e.g. setting bounds).


Then (at least I hope so) it was agreed that target milestone is
postponed to 4.0. Now I set it to future, because there needs to be
figured out, how the startup of GUI should look like, and can't guess
how much of work it could take.
Anyway I'm almost sure it is not fixable in short time.

So what corrective action should be taken now?
Comment 21 Jaroslav Tulach 2002-07-26 11:00:02 UTC
The process for "waivers" needs to be announced by release
coordinator. I suggested to just change the mileston to 4.0 or future.
 If accepted your bug is in "waiver" state.
Comment 22 Peter Zavadsky 2002-07-30 16:54:00 UTC
Justification explains the above comments.
Comment 23 Patrick Keegan 2002-07-30 17:33:38 UTC
I approve of the waiver.
Comment 24 iformanek 2002-07-30 17:46:59 UTC
I agree with the waiver
Comment 25 Peter Zavadsky 2002-11-13 14:52:28 UTC
Ian: Please let me know, how important is to fix this issue to 4.0.

Since the new winsys was stopped, fixing this issue would require
quite a lot of changes+time.
I'd need to know whether I should push the problem, to get the needed
time.
Comment 26 iformanek 2002-11-13 15:01:10 UTC
If it is a big amount of work, and the winsys will be rewritten
anyway, I'd say it can wait.
Are there going to be some performance-related changes in winsys that
this fix could piggyback on?
Comment 27 Peter Zavadsky 2002-11-14 09:05:55 UTC
Well, I don't know which performance changes will be taken in winsys,
I just know there is planned something.

Anyway, I don't expect performance changes would affect this, since
the problem of this issue is not in performance, but in nature of
startup of win sys.
 Currently it is undeterministic and caused by the implementation of
winsys (especially the way of showing workpaces/modes/topcomponents).

It is necessary to achieve sequence:
1) get all components going to be opened (from
workspace/modes/topcomponents)
2) create hierarchy from them
3) pack
4) show 

The current state is far away from this natural flow. It is also
connected with problems of computing bounds.


Comment 28 _ ttran 2003-03-16 09:47:15 UTC
I've reread the bug description, doesn't seem to be P2.  Lowered prio
to P3.  It has been waived without much objection two times in a row.
 Should be solved as part of winsys rewrite.

BTW, I noticed JBuilder suffers the same problem on Windows, something
deeper than a flaw in our current winsys?
Comment 29 Peter Zavadsky 2003-03-17 08:49:59 UTC
Well, it could be something deeper. But I think, when we will able to
construct the GUI in typical swing way -> add all components to
hierarchy, pack them and show them, there shouldn't occure any blinks. 
On the other hand, I'm already watching problems with toolbars, which
component is created (can be manipulated -> put into hierarchy), but
its buttons were adding just afterwards (when FolderInstance produces
them), and that design could cause similar problems (keeping it in
mind). And there could occure also pure repainting problems of
individual components.
Comment 30 Marian Mirilovic 2003-11-26 12:58:53 UTC
Because Window System v1 will not be supported from now by our team, all old
winsys issues (now "core/window system v1" issues) are going to be closed as
WONTFIX. 

Changes in API which emerged both from UI spec 
and problems with adjusting to the older API are described in the document
http://core.netbeans.org/windowsystem/changes.html.
 It shows also recommends how the client code should be adjusted to the new
window system.

If you think this issue apply also to the new winsys then change the
subcomponent (to "core/window system") and REOPEN it.
Comment 31 Jan Chalupa 2003-11-26 18:33:54 UTC
Still reproducible with the new winsys on Windows platforms and Sun
JDK 1.4.2_01. Reopening.
Comment 32 Peter Zavadsky 2003-11-27 13:26:05 UTC
Now it is almost clear it is caused by menubar/toolbar implementation,
using FolderInstance, and even after waitFinished, the GUI is not yet
created and validated..

you can see the effect more closely when you run ide with switch
-J-Dawt.nativeDoubleBuffering=true

Thus making this issue dependant.
Comment 33 _ rkubacki 2003-11-27 13:51:24 UTC
it happens on Linux too (visible with native double buffering turned on)

affects startup performance
Comment 34 Peter Zavadsky 2003-11-28 13:00:16 UTC
It doesn't blink on linux, you can just watch what is happening using
that flag.
Comment 35 _ tboudreau 2003-12-14 00:25:03 UTC
Possibly related:  jdk bug 439857 - unnecessary painting of Frames 
when first shown.  Looks like it will be fixed in 1.5; for 1.4, we 
might be able to work around it with a custom root pane;  I've 
already patched winsys to make the root panes opaque.

Quoting from the issue:

There are a couple of problems contributing to this.
1. The child of the JFrame (JRootPane) is not opaque.
This is problematic because JComponent.paintImmediately will loop 
until it finds a !opaque JComponent. If it gets to a Component that 
isn't a JComponent it'll invoke repaint on it.  This lead to 
excessive repaints on the Frame. This is fixed by invoke setOpaque
(true) on the JRootPane created for the top levels 
(JFrame/JWindow/JDialog/JApplet).

2. When a top level's size changes the JRootPane gets resized too, 
leading to a pending repaint (from the AWT side) for the top level, 
and a pending Swing repaint for the JRootPane.
This can be fixed by making the RepaintManager know that it is about 
to paint a RootPane and if necessary cancel any pending AWT paint 
events that would generate the same thing.
Comment 36 _ tboudreau 2003-12-14 01:08:09 UTC
FYI, I've confirmed it - bug 439857 is the source of the problem.

I'll attach a patch - I did some experimenting with a custom 
RootPane subclass which fires no events on resize.

The good news:  It fixes the flashing.
The bad news: The main window is completely unresponsive (not 
surprising).

I'll attach it as a start - probably the thing to do is simply to 
fire no events on the first call to reshape().

A couple things that don't work:
 - It's not a ComponentListener that triggers it (probably hierarchy 
event or something) - just overriding addComponentListener as a no-
op doesn't work
 - Turning off root pane checking and adding directly to the JFrame 
instead of to its content pane doesn't make any difference - the 
root pane is there whether we use it or not.

Possible alternate solution, but might have its own problems:  Use 
java.awt.Frame instead of JFrame.
Comment 37 _ tboudreau 2003-12-14 01:09:10 UTC
Created attachment 12564 [details]
The beginnings of a fix - or at least demonstrates the problem is really where I thought it was
Comment 38 Peter Zavadsky 2003-12-17 16:31:17 UTC
*** Issue 37701 has been marked as a duplicate of this issue. ***
Comment 39 _ tboudreau 2004-01-22 03:01:29 UTC
I have what may be a fix for this - I developed it on my mac, so it
needs to be tested on Windows - swing on the mac has hardware double
buffering, which can hide some ugliness.

What it does:
 - In a static block in MainWindow.java, so it runs when the class is
loaded, an alternate RepaintManager is installed
 - This RepaintManager makes almost all repaint operations no-ops (in
reality it should special-case the splash screen)
 - Override MainWindow.validate() to be a no-op until a flag is set
 - In MainWindow.initializeBounds, reset the validate flag and
uninstall the custom repaint manager so painting works normally

It eliminates the flash - the first repaint will come from an AWT
PaintEvent (no way to avoid that, so we just avoid all the other paint
events).  As a bonus, we might get a trivial startup time improvement
- RepaintManager.addDirtyRegion & addInvalidComponent were called
around 9000 times (!!) when I logged them during startup (mostly by
components that are not really onscreen, so they're nearly no-ops anyway).

There will still be a repaint when the toolbars populate themselves -
they are added empty and then populate themselves one-by-one (this
should be fixed at some point - there's no good reason for it to be
done that way).

I noticed two calls to MainWindow.validate() that don't seem to do
anything except generate useless repaints - one in initializeBounds
(if you set the bounds of a window, it will validate itself), and one
in ToolbarPool (this one may do something useful when changing toolbar
configurations, which aren't used by anything anymore).

I'll post the results when I try it on a non-Apple machine.
Comment 40 David Simonek 2004-02-24 16:09:54 UTC
*** Issue 39668 has been marked as a duplicate of this issue. ***
Comment 41 _ tboudreau 2004-02-29 21:46:55 UTC
FWIW, I added a bunch of logging to MainWindow.validate() and found
that the main window was being fully laid out 7 times during startup
due to each toolbar calling validate().  That's fixed;  I also added
an off-by-default workaround for this problem, which is to simply
ignore the first call to doLayout().  If you'd like to test it, run with

-J-Dnetbeans.winsys.flashhack=true

This simply blocks the first validation (which comes from the resizing
ComponentEvent sent when the main window is first shown).  I put the
workaround in mainly to measure the impact on startup time of this
problem - getPreferredSize() is not the cheapest call in the world for
trees and such, so eliminating gratuitous layouts will help startup time.

Note JDK 1.5 beta 2 does not automagically fix the problem - the
behavior is the same in 1.4 or 1.5.  Some numbers would help make a
case for getting it fixed.

I'll do some more research and see if there's a safer way to do this -
I wouldn't want to find that on the one platform where it works
correctly (?), the main window never gets laid out :-/
Comment 42 Lukas Hasik 2004-04-02 12:11:54 UTC
*** Issue 41576 has been marked as a duplicate of this issue. ***
Comment 43 Milos Kleint 2004-06-14 12:31:23 UTC
I think at least partly this issue was fixed by changes in the window
regarding JSplitPane.setDeviderLocation() to
JSplitPane.resetToPrefferedSized(). which simplified the startup
sequence and eliminated some of the repaints. 
Can someone validate if the issue is gone or not?
Comment 44 Jan Chalupa 2004-06-15 09:59:21 UTC
It's not gone. I can reproduce the extra repaint (blink) easily on my
Windows NT box when starting with no project open. Obviously, when
there is an open project, scanning of project's structure comes to
play which makes the UI temporarily flash and freeze even more, but
it's a different issue.
Comment 45 _ ttran 2004-07-27 12:57:47 UTC
Tim, perhaps you should take over this issue from Dafe
Comment 46 David Simonek 2004-07-27 15:43:17 UTC
Tim already did a lot of investigation (I'm delighted),so yes, Tim is
the right person. But I wouldn't expect total fix anytime soon,
toolbars and startup sequence may play role here as well.
Comment 47 _ tboudreau 2004-07-27 16:05:46 UTC
The correct java bug number is 4939857, ostensibly fixed in 1.5
Comment 48 _ ttran 2004-07-27 16:26:11 UTC
If so then we should close this bug, after verification of course
Comment 49 Jan Chalupa 2004-08-13 15:51:56 UTC
Still reproducible with 4.0 build #200408121800 on JDK 1.5 b63
(latest). The main window area is redrawn (flashes) once during the
startup sequence.
Comment 50 _ tboudreau 2004-08-13 16:07:53 UTC
FIrst, do we know that there is one *less* repaint on 1.5 than 1.4, during startup - that is, 
was the JDK issue really fixed?

After that, there is the matter of toolbars - the way it is done now, the toolbars are 
created, but then populated lazily - this code does need to be rewritten, but is unlikely to 
for 4.0.

Finally, there are assorted calls to MainWindow.validate() that may be able to be 
eliminated.  But there are a lot of variables here, toolbars being by far the worst of the 
bunch.
Comment 51 mslama 2004-08-13 16:25:17 UTC
Toolbars are now created synchronously BEFORE they are displayed. This
was fixed recently. See issue #46016.
Comment 52 _ tboudreau 2004-08-24 15:40:20 UTC
Spent some more time poking at this, but still no obvious culprits.

Note that the hack does work - if you run with
-J-Dnetbeans.winsys.flashhack=true

you won't see the flash.  This issue is  a little more severe now, 
since if the timing is just right, the classpath scanning stuff will 
hijack the AWT thread just after the main window has gone gray, so 
you can occasionally see the main window go gray for 10s or so on 
startup.

Possibly if the hack could be enabled only for <= JDK 1.5 on windows, 
it would be safe enough.
Comment 53 Jan Chalupa 2004-11-01 16:50:16 UTC
Re-assigning Tim's issues to Dafe.
Comment 54 David Simonek 2005-01-19 15:06:02 UTC
Passing to Stan to distribute bugs evenly. Thanks Stane :-)
Comment 55 Stanislav Aubrecht 2005-01-27 09:40:48 UTC
*** Issue 50937 has been marked as a duplicate of this issue. ***
Comment 56 Stanislav Aubrecht 2005-01-27 13:59:18 UTC
fixed

i integrated the patch kindly provided by ericarseneau (see issue
50937 ) and removed the repaint call from the setDesktop method and it
seems to be working fine in jdk 1.5. 
however i had to add a hack to repaint the main window when it's being
maximized for the first time (setExtendedState()).

pls reopen the issue if you think this fix is not good enough.

Checking in windows/src/org/netbeans/core/windows/view/ui/MainWindow.java;
/cvs/core/windows/src/org/netbeans/core/windows/view/ui/MainWindow.java,v
 <--  MainWindow.java
new revision: 1.40; previous revision: 1.39
done
Comment 57 Marian Mirilovic 2005-03-29 07:57:17 UTC
verified in NB4.1(200503281924)