Bug 381886 - Debugger keybindings frequently require pressing twice
Summary: Debugger keybindings frequently require pressing twice
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC All
: P3 major with 5 votes (vote)
Target Milestone: 4.2.2   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
: 387057 389383 391583 (view as bug list)
Depends on:
Blocks: 390869
  Show dependency tree
 
Reported: 2012-06-06 12:32 EDT by Bryan Hunt CLA
Modified: 2013-06-10 20:30 EDT (History)
20 users (show)

See Also:


Attachments
Covert launch view actions to command contributions (22.27 KB, patch)
2012-10-25 18:10 EDT, Pawel Piech CLA
no flags Details | Diff
Updated patch to convert debug action set to command contributions (41.90 KB, patch)
2012-10-31 16:20 EDT, Pawel Piech CLA
no flags Details | Diff
ActionDelegateHandlerProxy patch (741 bytes, patch)
2012-11-08 14:44 EST, Michael Rennie CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Bryan Hunt CLA 2012-06-06 12:32:38 EDT
I'm using Eclipse 4.2RC3.

When in the debug perspective, the F5 - F8 keybindings often don't work.  I often have to press the key twice to get it to work, and sometimes I have to click on the stack frame to get the key to work.

Debugging on OS X is very painful.
Comment 1 Paul Webster CLA 2012-06-06 13:02:47 EDT
I've seen this to on linux

PW
Comment 2 Ian Bull CLA 2012-06-06 13:06:13 EDT
Remy mentioned this at EclipseCon. I thought there was a fix.  I'm sure there is another bug report, but I can't find it now.
Comment 3 Marc Khouzam CLA 2012-07-17 15:28:52 EDT
I had this problem a while ago and I'm not 100% 
if it really got fixed by Bug 297899
Comment 4 Brian de Alwis CLA 2012-08-07 14:45:10 EDT
I think this is due to a race condition due to lazy loading of the step command handlers with how the step action enablements are computed.

The DebugCommandActionDelegates are first created as part of the @CanExecute check on the step-X handlers, and so their DebugCommandAction instances aren't current with the active debug context.  The DebugCommandAction enablement state is requested using an UpdateJob, which is not joined, and so doesn't complete before the DebugCommandAction/DebugCommandActionDelegate initialization is finished.  This causes the step action to be marked as disabled until the background update request is able to update the action delegate's enablement state.  This background update doesn't occur in time before the step handler's @CanExecute returns.

What's funny is that the DebugCommandService has already queried the step availabilities (after a breakpoint or exception), but it doesn't keep ahold of the current state.  This problem could be circumvented if the DebugCommandService had a way to access the last state for a particular command.



A few stack traces:

Immediately on pushing F5 for the first time; the CommandLegacyActionWrapper is the action wrapper pushed in by ActionDelegateHandlerProxy.  The action wrapper is disabled.

Daemon Thread [Thread-1] (Suspended (entry into method setEnabled in CommandLegacyActionWrapper))	
	CommandLegacyActionWrapper.setEnabled(boolean) line: 456	
	StepIntoCommandAction(DebugCommandAction).setActionProxy(IAction) line: 109	
	StepIntoCommandActionDelegate(DebugCommandActionDelegate).init(IAction) line: 51	
	ActionDelegateHandlerProxy$2.run() line: 466	
	SafeRunner.run(ISafeRunnable) line: 42	
	ActionDelegateHandlerProxy.initDelegate() line: 485	
	ActionDelegateHandlerProxy.loadDelegate() line: 603	
	ActionDelegateHandlerProxy.updateDelegate(IAction, IEvaluationContext) line: 312	
	ActionDelegateHandlerProxy.setEnabled(Object) line: 522	
	E4HandlerProxy.canExecute(IEclipseContext, IEvaluationContext) line: 56	
	GeneratedMethodAccessor1.invoke(Object, Object[]) line: not available	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	MethodRequestor.execute() line: 56	
	InjectorImpl.invokeUsingClass(Object, Class<?>, Class<Annotation>, Object, PrimaryObjectSupplier, PrimaryObjectSupplier, boolean) line: 229	
	InjectorImpl.invoke(Object, Class<Annotation>, Object, PrimaryObjectSupplier, PrimaryObjectSupplier) line: 210	
	ContextInjectionFactory.invoke(Object, Class<Annotation>, IEclipseContext, IEclipseContext, Object) line: 131	
	HandlerServiceImpl.executeHandler(ParameterizedCommand, IEclipseContext) line: 166	
	KeyBindingDispatcher.executeCommand(ParameterizedCommand, Event) line: 276	
	KeyBindingDispatcher.press(List<KeyStroke>, Event) line: 497	
	KeyBindingDispatcher.processKeyEvent(List<KeyStroke>, Event) line: 548	
	KeyBindingDispatcher.filterKeySequenceBindings(Event) line: 369	

The action delegate initialization registers an UpdateJob to verify the step ability status:

Daemon Thread [Thread-1] (Suspended (entry into method canExecute in AbstractDebugCommand))	
	StepOverCommand(AbstractDebugCommand).canExecute(IEnabledStateRequest) line: 253	
	DebugCommandService.updateCommand(Class, Object[], IEnabledTarget[]) line: 181	
	DebugCommandService.updateCommand(Class, IEnabledTarget) line: 134	
	StepOverCommandAction(DebugCommandAction).init(IWorkbenchWindow) line: 207	
	StepOverCommandActionDelegate(DebugCommandActionDelegate).init(IWorkbenchWindow) line: 59
Comment 5 Dani Megert CLA 2012-08-08 09:27:00 EDT
This is a major productivity killer.
Comment 6 Paul Webster CLA 2012-08-15 19:14:39 EDT
One thing I noticed with this is in 4.2 we are only calling canExecute(*) once, during the execute phase, but in 3.8 we called canExecute(*) twice (once earlier than the execute).  Adding back that extra call seemed to make it harder to hit this condition, but it was still there sometimes.

Michael, when debugging this in 3.8 there were a lot more calls to the canExecute/UpdateJob, usually triggered in asyncExecs(*) by debug model changes.

Could you have a look at this tomorrow and see if there's something we did that is causing less debug model changes to be broadcast?

PW
Comment 7 Michael Rennie CLA 2012-09-12 10:20:42 EDT
*** Bug 387057 has been marked as a duplicate of this bug. ***
Comment 8 Michael Rennie CLA 2012-10-01 11:13:17 EDT
*** Bug 389383 has been marked as a duplicate of this bug. ***
Comment 9 Larsen Doe CLA 2012-10-08 05:17:38 EDT
Not sure if this helps, but when a breakpoint is hit and I first click onto the call stack (if that´s what it´s called), I only need to press F5, etc. once.

Using Eclipse 4.2.1 on Win XP SP3.
Comment 10 Dani Megert CLA 2012-10-11 04:59:31 EDT
*** Bug 391583 has been marked as a duplicate of this bug. ***
Comment 11 Brett Wooldridge CLA 2012-10-11 20:11:47 EDT
Any progress on this bug?  This is a huge productivity killer for OS X developers.  Bug#372941 references this bug, but I'm not sure which one is the "true" bug.  Any fix on the horizon?
Comment 12 Paul Webster CLA 2012-10-12 09:51:02 EDT
no, not yet.

PW
Comment 13 Michael Rennie CLA 2012-10-15 16:36:06 EDT
Looking on the debug side of things we have the DebugCommand* classes that get loaded at startup and enable correctly, but then when debugging starts, another set of delegates is created which end up disabling the handlers. After the first key press the handler re-evaluates its enabled state and correctly enables (again) then the following key presses work.

I need to poke around a bit more to see if we broke something on the debug side or not.
Comment 14 Pawel Piech CLA 2012-10-25 18:10:53 EDT
Created attachment 222852 [details]
Covert launch view actions to command contributions

Hi Mike,
This patch gets rid of the problematic actions from the launch view and contributes them through the org.eclipse.ui.menus extension.  The problem with this solution is that we have an action that lets the user show/hide the run control actions in the view toolbar.  We have a system property to test for, but I don't know of a way to force the toolbar to re-evaluate its contributions.  Instead, I put in a crude update that directly turns off/on the toolbar contributions.
Comment 15 Michael Rennie CLA 2012-10-29 16:47:00 EDT
I like the fix, and it makes debugging on the Mac usable again. I do agree though that we would need a different solution to show/hide the toolbar, because the current solution will only show/hide the platform contributed actions - I would assume if someone contributed an action to the stepOverGroup (for example) that that action would also show/hide.

Also this fix helps the work in progress from bug 390869

Paul, is it a supported scenario in Platform UI to have a contributed action (plugin.xml) and an action added via code that share a command id work when both are used at the same time? If not than this bug can be moved to platform debug, as the proposed fix is completely on the debug side.
Comment 16 Pawel Piech CLA 2012-10-31 09:56:53 EDT
Looks like my proposed fix is severely broken in 3.8 for a change.  Besides the broken switching between debug view toolbar on/off, the commands are always enabled until they are first run.
Comment 17 Pawel Piech CLA 2012-10-31 16:20:23 EDT
Created attachment 223052 [details]
Updated patch to convert debug action set to command contributions

The reason that the commands don't work in 3.8 is that they seem to conflict with the actions defined in the main menu.  This patch doubles down on the command contributions with the main menu and toolbar.  It fixes the enablement issues in 3.8, but toggling debug view toolbar still doesn't work.  Also a bad side-effect is that the Customize Perspective->Command Groups->Debug doesn't show the debug actions anymore.
Comment 18 Dani Megert CLA 2012-11-01 04:31:40 EDT
I would be reluctant to change the action contributions to command contributions in a service release. Besides new bugs, this *might* also result in different ordering of the menu entries.
Comment 19 Michael Rennie CLA 2012-11-08 14:44:48 EST
Created attachment 223367 [details]
ActionDelegateHandlerProxy patch

Seems like part of the fix to bug 361562 added an extra call to loadDelegate(), which when removed, the debug actions start working as expected again. I confirmed that removing the extra loadDelegate call does not affect the fixes for bug 371130, bug 371131 or bug 361562 - Pawel can you test to confirm it does not affect CDT?

The easiest way I reproduced the multiple key press problem was:
1. start target workspace
2. debug Java application to breakpoint
3. hit one of F5-F8 after it suspends
Comment 20 Pawel Piech CLA 2012-11-08 17:31:00 EST
Thanks Mike!  I gave the patch a quick try with CDT and it fixes the keybinding problem.  I also didn't see any issues with the CDT action delegates, though my test pass was not exhaustive.
Comment 21 Paul Webster CLA 2012-11-13 10:31:45 EST
(In reply to comment #19)
> Created attachment 223367 [details]
> ActionDelegateHandlerProxy patch

I've had a look at this as well, and it removes the problem for me.  Do you want to go ahead and put it in, and we'll get some more widespread testing in the M build?

Thanx for looking into this, Mike.

PW
Comment 22 Michael Rennie CLA 2012-11-13 11:15:52 EST
(In reply to comment #21)
> (In reply to comment #19)
> > Created attachment 223367 [details]
> > ActionDelegateHandlerProxy patch
> 
> I've had a look at this as well, and it removes the problem for me.  Do you
> want to go ahead and put it in, and we'll get some more widespread testing
> in the M build?
> 
> Thanx for looking into this, Mike.
> 
> PW

Sure, if you wouldn't mind putting it in for me.
Comment 23 Dani Megert CLA 2012-11-13 11:28:53 EST
I did not test the fix, but looking at the change it *might* result in early and unwanted plug-in loading. Please test this before committing.
Comment 24 Paul Webster CLA 2012-11-13 13:37:01 EST
(In reply to comment #23)
> I did not test the fix, but looking at the change it *might* result in early
> and unwanted plug-in loading. Please test this before committing.

I agree, we should be careful.  This patch will remove the second part of the if, which can load the delegate after its plugin is already active, but earlier than it would have in regular 3.x startup.  So it just removes the "load the delegate earlier than usual" call.

Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?h=R4_2_maintenance&id=9aefcba2ae27ba3d1b36baf26009806c0b6dd28d

Thanx Mike,
PW
Comment 25 Larouche CLA 2012-12-14 02:46:43 EST
I have this issue too but my behavior is different i dont know if i should open a new bug or not.

When i go in the debug perspective. In any window the F6, F7 and F8 keys are working fine.

F5 key NEVER work in source code. I always have to go in the debug stack for it to work.

I removed the F5 hot key binding everywhere. Only step into have it now. But not working either.

I try to make a custom perspective and play with the Command Groups and Toolbars see if its affecting anything but after 15 minutes i understood never to do that again.

So yeah, that F5 key is a mistery.
Comment 26 Dani Megert CLA 2012-12-14 03:17:34 EST
(In reply to comment #25)
> I have this issue too but my behavior is different i dont know if i should
> open a new bug or not.
> 
> When i go in the debug perspective. In any window the F6, F7 and F8 keys are
> working fine.
> 
> F5 key NEVER work in source code. I always have to go in the debug stack for
> it to work.
> 
> I removed the F5 hot key binding everywhere. Only step into have it now. But
> not working either.
> 
> I try to make a custom perspective and play with the Command Groups and
> Toolbars see if its affecting anything but after 15 minutes i understood
> never to do that again.
> 
> So yeah, that F5 key is a mistery.

Please try whether the latest 4.2.2 or 4.3 M4 build fixed the issue
http://download.eclipse.org/eclipse/downloads/drops4/M20121212-1800/
http://download.eclipse.org/eclipse/downloads/drops4/I20121213-1200/
Comment 27 Larouche CLA 2012-12-14 06:38:14 EST
It is ok with 4.2.2 and 4.3 M4

But in my eclipse 4.2 SR1 is the JEE Birt version. With Android SDK and GWT plugin. Plus some utilities like findbugs, jboss tools, Git, subversive, etc.

I dont know if it can affect the debug perspective.