Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 317102

Summary: [EditorMgmt] Recursive editor activation when using AbstractMultiEditor
Product: [Eclipse Project] Platform Reporter: Samantha Chan <chanskw>
Component: UIAssignee: Remy Suen <remy.suen>
Status: VERIFIED FIXED QA Contact: Remy Suen <remy.suen>
Severity: major    
Priority: P3 CC: bokowski, nikolaybotev.b, pwebster
Version: 3.6   
Target Milestone: 3.7 M6   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
AbstractMultiEditor recursive activation patch v1
none
AbstractMultiEditor recursive activation patch v2 none

Description Samantha Chan CLA 2010-06-16 14:49:13 EDT
Steps:

1)  Create an multi pane editor implmentation based on AbstractMultiEditor.
2)  In my implementation, the multi editor returns a sashform as the main composite
3)  Each of the sash form contains a view form.  The view form is the parent of the inner editor.
4)  Put focus on the inner editor on the left.  
5)  Put focus onto the outline view
6)  Put focus on the inner editor on the right.

Putting this as major for now, as there is no way around this and it happens on each activation.

Got the following stack trace:

java.lang.RuntimeException: WARNING: Prevented recursive attempt to activate part com.ibm.editor.multi while still in the middle of activating part com.ibm.editor.raw
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3487)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:3077)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:279)
	at org.eclipse.ui.internal.EditorPane.requestActivation(EditorPane.java:98)
	at org.eclipse.ui.internal.PartPane.handleEvent(PartPane.java:237)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1076)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1424)
	at org.eclipse.swt.widgets.Control.sendFocusEvent(Control.java:2631)
	at org.eclipse.swt.widgets.Widget.wmSetFocus(Widget.java:2401)
	at org.eclipse.swt.widgets.Control.WM_SETFOCUS(Control.java:4791)
	at org.eclipse.swt.widgets.Canvas.WM_SETFOCUS(Canvas.java:448)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4228)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4873)
	at org.eclipse.swt.internal.win32.OS.SetFocus(Native Method)
	at org.eclipse.swt.widgets.Control.forceFocus(Control.java:994)
	at org.eclipse.swt.widgets.Control.setFocus(Control.java:2999)
	at org.eclipse.swt.widgets.Composite.setFocus(Composite.java:1053)
	at org.eclipse.ui.texteditor.AbstractTextEditor.setFocus(AbstractTextEditor.java:6003)
	at org.eclipse.ui.texteditor.StatusTextEditor.setFocus(StatusTextEditor.java:102)
	at org.eclipse.ui.part.AbstractMultiEditor.setFocus(AbstractMultiEditor.java:138)
	at org.eclipse.ui.internal.PartPane.setFocus(PartPane.java:332)
	at org.eclipse.ui.internal.EditorPane.setFocus(EditorPane.java:127)
	at org.eclipse.ui.internal.WorkbenchPage$3.run(WorkbenchPage.java:629)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.runtime.Platform.run(Platform.java:888)
	at org.eclipse.ui.internal.WorkbenchPage.activatePart(WorkbenchPage.java:624)
	at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3533)
	at org.eclipse.ui.internal.WorkbenchPage.requestActivation(WorkbenchPage.java:3077)
	at org.eclipse.ui.internal.PartPane.requestActivation(PartPane.java:279)
	at org.eclipse.ui.internal.EditorPane.requestActivation(EditorPane.java:98)
	at org.eclipse.ui.internal.PartPane.handleEvent(PartPane.java:237)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1076)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)
	at org.eclipse.swt.widgets.Shell.setActiveControl(Shell.java:1424)
	at org.eclipse.swt.widgets.Shell.WM_MOUSEACTIVATE(Shell.java:2297)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4202)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1598)
	at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:2038)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2454)
	at org.eclipse.swt.widgets.Scrollable.callWindowProc(Scrollable.java:80)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4250)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:341)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4886)
	at org.eclipse.swt.internal.win32.OS.PeekMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.PeekMessage(OS.java:3024)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3652)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
	at java.lang.reflect.Method.invoke(Method.java:600)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 1 Samantha Chan CLA 2010-06-23 09:57:17 EDT
Is it possible to consider this for 3.6.1?
Comment 2 Remy Suen CLA 2010-08-12 07:22:12 EDT
(In reply to comment #0)
> 1)  Create an multi pane editor implmentation based on AbstractMultiEditor.

If you subclass MultiEditor instead, does the problem go away?
Comment 3 Samantha Chan CLA 2010-12-09 11:24:52 EST
(In reply to comment #2)
> (In reply to comment #0)
> > 1)  Create an multi pane editor implmentation based on AbstractMultiEditor.
> 
> If you subclass MultiEditor instead, does the problem go away?

Sorry, I am not able to subclass to MultiEditor as my editor won't work based on other problems I have encounted with the MultiEditor.  That's why I went with subclassing from AbstractMultiEditor.

Can you please let me know what this exception really means, and what is the effect of this exception?  Can this exception be omitted?

If this exception indicates a major problem, any chance of fixing this in 3.6.2?
Comment 4 Remy Suen CLA 2010-12-09 13:49:27 EST
Created attachment 184885 [details]
AbstractMultiEditor recursive activation patch v1

(In reply to comment #3)
> Can you please let me know what this exception really means, and what is the
> effect of this exception?  Can this exception be omitted?

The gist of it is that while trying to activate inner editor B that has been selected, we try to grant focus to the part's pane. The pane that is returned is the outer editor's pane. So the code flows into an activation request again (whilst granting focus to the part's pane), since the other inner editor hasn't been activated yet, we still think the inner editor A is the active editor so we try to make it the active part. At this point, we detect an activation request on inner editor A whilst attempting to activate inner editor B and print a warning message into the logs.

> If this exception indicates a major problem, any chance of fixing this in
> 3.6.2?

Since Eclipse stays up, it is not really a huge problem although constantly printing stuff in the logs does make us look pretty bad. We will first have to assess the impact of this (or any other potential) fix before we can make a call here.
Comment 5 Remy Suen CLA 2010-12-09 13:50:26 EST
Boris, this is the recursive activation bug I talked to you about.
Comment 6 Paul Webster CLA 2010-12-13 10:10:21 EST
(In reply to comment #4)
> Created an attachment (id=184885) [details]
> AbstractMultiEditor recursive activation patch v1


Just a comment, this fix is way to risky for a maintenance release.  It would have to be tested in 3.7 for at least one full milestone first (and that will miss the 3.6.2 window).

PW
Comment 7 Samantha Chan CLA 2010-12-13 19:24:35 EST
(In reply to comment #6)
> (In reply to comment #4)
> > Created an attachment (id=184885) [details] [details]
> > AbstractMultiEditor recursive activation patch v1
> 
> 
> Just a comment, this fix is way to risky for a maintenance release.  It would
> have to be tested in 3.7 for at least one full milestone first (and that will
> miss the 3.6.2 window).
> 
> PW

Thanks so much... what problems would I encounter if this is not fixed?  Other than having lots of errors logged?
Comment 8 Remy Suen CLA 2010-12-13 19:29:35 EST
(In reply to comment #7)
> Thanks so much... what problems would I encounter if this is not fixed?  Other
> than having lots of errors logged?

From a cursory glance I don't have any reason to believe that there are any adverse side effects to this recursive activation request.
Comment 9 Samantha Chan CLA 2010-12-14 21:34:19 EST
Thanks!
Comment 10 Remy Suen CLA 2011-02-01 10:28:07 EST
*** Bug 241624 has been marked as a duplicate of this bug. ***
Comment 11 Remy Suen CLA 2011-02-01 10:28:45 EST
Created attachment 188052 [details]
AbstractMultiEditor recursive activation patch v2

Attachment 184885 [details] with a unit test for validation.
Comment 12 Remy Suen CLA 2011-02-01 10:31:22 EST
(In reply to comment #11)
> Created attachment 188052 [details]
> AbstractMultiEditor recursive activation patch v2

Patch released to CVS HEAD.

Thanks for the bug report, Samantha!
Comment 13 Remy Suen CLA 2011-03-08 09:34:29 EST
Verified by testing an inner with an editor that extends AbstractMultiEditor on Windows XP with I20110307-2110.