Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacktrace view loses focus on stopped thread #34246

Closed
DatGuyJonathan opened this issue Sep 12, 2017 · 3 comments
Closed

Stacktrace view loses focus on stopped thread #34246

DatGuyJonathan opened this issue Sep 12, 2017 · 3 comments
Assignees
Labels
*caused-by-extension Issue identified to be caused by an extension debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@DatGuyJonathan
Copy link

  • VSCode Version: 1.16.0-insider
  • OS Version: OSX 10.11.6

Steps to Reproduce:

  1. Start debugger session with a debugger extension that supports multiple stopped threads.
  2. Stop at least two threads.
  3. Step over with the second thread.

Reproduces without extensions: Yes

Apologies for the watermark, but you can see the UI remains focused on the first thread after the second thread stops again. I think the UI should refocus on the thread that is most recently stopped.

stacktracefocus

I suspect the issue is in debugService.tryToAutoFocusStackFrame(). I think that if-statement should be true if there is no callstack or the current focused stack frame is in the same thread as the method parameter. So, something like this:

if (!callStack.length || (this.viewModel.focusedStackFrame && this.viewModel.focusedStackFrame.thread.threadId === thread.threadId)) {

@vscodebot vscodebot bot added the insiders label Sep 12, 2017
@vscodebot vscodebot bot added the debug Debug viewlet, configurations, breakpoints, adapter issues label Sep 12, 2017
@isidorn
Copy link
Contributor

isidorn commented Sep 13, 2017

@DatGuyJonathan thanks for the nice steps and for the pointer where you think the fix is.
However I believe this is a duplicate of dotnet/vscode-csharp#1617

Even though if you are maybe not using the C# adapter the extension you are using is suffering from the same flow I described in that issue.

And yes I was first optimistic to try your fix but that did not help. The problem is that when you click step over, the adapter actually contoniues all threads, and then when the stop even comes it comes for the wrong thread making vscode focus wrongly.

Closing as duplicate / caused by extension. Please check with the extension for more details

@isidorn isidorn closed this as completed Sep 13, 2017
@isidorn isidorn added the *caused-by-extension Issue identified to be caused by an extension label Sep 13, 2017
@DatGuyJonathan
Copy link
Author

DatGuyJonathan commented Sep 13, 2017

@isidorn I set a breakpoint in rawDebugSession.ts to see how NextResponse is handled. After receiving a response from the adapter, it calls fireFakeContinued() with allThreadsContinued = false. We can see this in the GIF because the second thread's state is 'running' and the first thread's state is still 'paused'. In debugService.ts, the continued event is handled by trying to focus on a stackframe, but it uses a null stackframe. So, focusStackFrameAndEvaluate() defaults the focus to the first thread's stack.

When the stopped event comes for the second thread, it tries to focus that thread's stackframe, but it won't because of that if-statement I mentioned earlier. There's already a focused stackframe, so it won't try to focus again.

What if we only default the stack focus for session with only one thread? It would fix the bug I'm experiencing, and also give a smoother debugging experience because the UI won't jump to the first thread before jumping back to the second thread.
https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/electron-browser/debugService.ts#L499

@isidorn
Copy link
Contributor

isidorn commented Sep 14, 2017

@DatGuyJonathan sounds like you got quite deep in the code. Would you be willing to provide a PR, since it is a bit easier for me to understand your intention by looking at proposed code.
Here is our guide on how to contribute https://github.com/Microsoft/vscode/wiki/How-to-Contribute

When running vscode out of source, you will need to add a debug extension. You can do that by simply dropping a .vsix of the extension you are using.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*caused-by-extension Issue identified to be caused by an extension debug Debug viewlet, configurations, breakpoints, adapter issues
Projects
None yet
Development

No branches or pull requests

2 participants