Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 168524 - [WorkbenchParts] On restart partActivated (and partVisible) called before widgets are visible
Summary: [WorkbenchParts] On restart partActivated (and partVisible) called before wid...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 170877 177057 178741 (view as bug list)
Depends on:
Blocks: 44295 124615 170877
  Show dependency tree
 
Reported: 2006-12-19 05:59 EST by Dani Megert CLA
Modified: 2008-04-29 12:15 EDT (History)
7 users (show)

See Also:


Attachments
Investigation patch v01 (3.49 KB, patch)
2007-04-22 16:11 EDT, Paul Webster CLA
no flags Details | Diff
Investigation patch v02 (4.09 KB, patch)
2007-04-23 07:46 EDT, Paul Webster CLA
no flags Details | Diff
Part Service approach v01 (13.97 KB, patch)
2008-04-04 15:59 EDT, Paul Webster CLA
no flags Details | Diff
Part Service approach v02 (17.13 KB, patch)
2008-04-10 10:46 EDT, Paul Webster CLA
no flags Details | Diff
Part Service v03 (10.03 KB, patch)
2008-04-10 14:24 EDT, Paul Webster CLA
no flags Details | Diff
Part Service v04 (7.77 KB, patch)
2008-04-11 15:33 EDT, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2006-12-19 05:59:56 EST
Use I20061219-0800 or newer to reproduce but problem also in earlier builds.

I added code to restore the editor selection upon restart (see bug 124615). This works for all (also if >1 window) but the first restored editor: the selection is not correctly revealed and the the scroll bar thumbs aren't correct.

There are two reasons that cause this: one is SWT bug 168429 and the other one is this one: When the very first editor is restored partActived(...) and if using IPartListener2 also partVisible(...) are called before the part's widgets are actually visible i.e. editor's StyledText.isVisble() returns false. This is not expected. Clicking on other editor tabs afterwards shows the correct behavior.

See also bug 154112 which might be related but not that this bug only appears for the very first visible editor and works when activating other not yet realized editors.
Comment 1 Dani Megert CLA 2007-02-08 05:00:27 EST
Another problem that this bug causes is described in bug 170877. We need to find a fix for this for 3.3.
Comment 2 Paul Webster CLA 2007-02-08 13:19:39 EST
This code hasn't changed (which means this problem has always been there).  The partVisible() on startup I've tracked down to: LayoutPart#getVisible() - "This returns whatever was last passed into setVisible, but does not necessarily indicate that the part can be seen"  The activation is a "model" activation event, so it also won't gaurantee the controls are really visible and have been layed out during the startup case.

Dani, is this a problem that's been highlighted in new code that you've added, or is this in existing code?

I'm wondering if this behaviour has now been highlighted since we're spinning the event loop during workbench/workbench window initial startup and restore.

asyncExec(*) might allow the events to be deferred until after startup ... but our new splash story might not allow that.

We'll need some investigation (changing any of the workbench event ordering is risky :-)

PW
Comment 3 Dani Megert CLA 2007-02-08 13:34:37 EST
>Dani, is this a problem that's been highlighted in new code that you've added,
>or is this in existing code?
Yes, this is the new code that restores the caret location.
Comment 4 Dani Megert CLA 2007-02-08 13:35:11 EST
>We'll need some investigation (changing any of the workbench event ordering is
>risky :-)
Not, if you have enough test cases.
Comment 5 Paul Webster CLA 2007-02-08 14:14:49 EST
This looks like legacy behaviour (so I don't think we need to delay M5).  I run the XMLEditor example from 3.2.2 and added an IPartListener2 in the init(*) method.

On a restart we've always had a part active and part visible event before the control has been layed out:
partActivated: false
partActivated: Point {0, 0}
partVisible: false
partActivated: Point {0, 0}

As opposed to a normal activation:
partVisible: true
partActivated: Point {528, 431}
partActivated: true
partActivated: Point {528, 431}

PW
Comment 6 Dani Megert CLA 2007-02-08 14:30:23 EST
>This looks like legacy behaviour 
That's well possible.

>(so I don't think we need to delay M5). 
No, of course not. I thought I was clear about that in my note. Even if we'd find a fix, comment 2 already mentioned that it is fragile to touch the event story.
Comment 7 Paul Webster CLA 2007-02-08 14:38:16 EST
(In reply to comment #6)
> No, of course not. I thought I was clear about that in my note. 

Yes, we were on the same page :-)

Platform UI was investigating the possiblity because we were worried that if we broke text (admittedly new code) that we might break some of the other projects that hope to demo behaviour on M5.  But we are less worried now.

PW

Comment 8 Dani Megert CLA 2007-02-08 16:17:40 EST
*** Bug 170877 has been marked as a duplicate of this bug. ***
Comment 9 Dani Megert CLA 2007-03-13 04:49:58 EDT
*** Bug 177057 has been marked as a duplicate of this bug. ***
Comment 10 John Arthorne CLA 2007-03-15 10:19:08 EDT
An interesting side-effect of this bug:

http://inside-swt.blogspot.com/2007/03/useless-dialog-of-day.html
Comment 11 Maxime Daniel CLA 2007-03-22 04:49:46 EDT
*** Bug 178741 has been marked as a duplicate of this bug. ***
Comment 12 Paul Webster CLA 2007-04-22 16:11:03 EDT
Created attachment 64551 [details]
Investigation patch v01

Can partActivated/partVisible be delayed if the control is not visible?  It looks like an asyncExec(*) will delay the firing until later.
PW
Comment 13 Paul Webster CLA 2007-04-23 07:46:43 EDT
Created attachment 64598 [details]
Investigation patch v02

Slightly cleaner version of the patch.

PW
Comment 14 Paul Webster CLA 2007-04-23 08:06:29 EDT
Delaying the activate/visible events approach changes the event ordering during startup.  Parts events are interleaved (which may or may not be a bad thing) and sometimes a partHidden can come before a partVisible (which is not good).

A better approach would be to enhance the deferUpdates(*) protocol to fire the events at the end of startup.  This would have to be threaded through the part lists, activation lists, and perspectives.

Deferring until 3.4.
PW
Comment 15 Paul Webster CLA 2008-04-04 15:59:53 EDT
Created attachment 94906 [details]
Part Service approach v01

This is an investigation patch.  When a page or window is created, start up in defer updates mode ... queue up all part events.

When the window is opened or the page is realized, then fire the events.

UC-1 open a session and restore the window
UC-2 open a second window
UC-3 open a page after closing all perspectives.

This investigation only includes UC1 so far.

PW
Comment 16 Paul Webster CLA 2008-04-10 10:46:27 EDT
Created attachment 95536 [details]
Part Service approach v02

A slightly better approach for maintaining event order within the window and page, the window has one deferred event queue that the pages use as well.

UC-4 Instantiate the Javadoc view after the window is up. partVisible(*) is fired before it has been layed out.


PW
Comment 17 Paul Webster CLA 2008-04-10 14:24:54 EDT
Created attachment 95571 [details]
Part Service v03

Different take on the part service approach.  Wait to fire the events for visible, active, and brought to top until the part pane control is visible and has been laid out at least once.

Far and away the most accurate (but also the scariest).

PW
Comment 18 Paul Webster CLA 2008-04-11 15:33:50 EDT
Created attachment 95743 [details]
Part Service v04

Use SWT events to determine when it's applicable to fire partVisible, partActivated, and partBroughtToTop.

PW
Comment 19 Paul Webster CLA 2008-04-11 15:36:14 EDT
Released to HEAD >20080411
PW
Comment 20 Paul Webster CLA 2008-04-29 12:15:12 EDT
In I20080429-0100
PW