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

Threads window is not updated after each call to threadsRequest() #19858

Closed
adelphes opened this issue Feb 3, 2017 · 9 comments
Closed

Threads window is not updated after each call to threadsRequest() #19858

adelphes opened this issue Feb 3, 2017 · 9 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues info-needed Issue requires more information from poster
Milestone

Comments

@adelphes
Copy link

adelphes commented Feb 3, 2017

  • VSCode Version: 1.9
  • OS Version: Linux x64

The threads display is not being correctly updated after a call to threadsRequest().

I'm working on adding multi-threading support to the Android debugging extension and after the initial call, I'm finding that the threads shown in the UI rarely correspond to the return values from the call to threadsRequest(). In particular, newly created threads are not displayed and deleted threads remain even though they are no longer in the ThreadsResponse body.

This may be related to the ongoing thread-handling discussion in #40 but this does appear to be a distinct problem in the current build.

@weinand weinand removed their assignment Feb 3, 2017
@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Feb 3, 2017
@adelphes
Copy link
Author

adelphes commented Feb 4, 2017

Digging into this issue, it seems that the threads display is updated correctly if the response to threadsRequest() is completely synchronous. Delaying the response appears to confuse it.

@isidorn
Copy link
Contributor

isidorn commented Feb 8, 2017

@adelphes so you are saying that VSCode is sending a threads request to your debug adapter, your debug adapter only responds after some time(what time?) and then vscode ignores your response since the call stack view does not update?

Does call stack view nicely update if you send 'ThreadEvent' instead? Since you can send this event any time you want.

Just to be on the safe side please read how vscode is expecting that the debug adapter is handling threads here

How hard would it be to setup a reproducable sample so we can try this out on our side?

@isidorn isidorn added the info-needed Issue requires more information from poster label Feb 8, 2017
@adelphes
Copy link
Author

adelphes commented Feb 8, 2017

I've now fixed this issue in my adaptor, so I think it can probably be closed.

I was (asynchronously) retrieving thread information from the Android device on each call to threadsRequest - each request takes a few milliseconds, but it was probably overkill to do it every time. I was getting weird results on breakpoint hits because some threads were still showing in the UI - long after I knew they had exited and tracing threadsRequest() showed they weren't being reported back to VSCode. I assumed the UI would be doing some sort of diff from the results of calls to threadsRequest(), but that was probably a bad assumption.

In any case, I've updated my adaptor to actively monitor thread creation/exit and send the appropriate ThreadEvents (I wasn't doing this before). I also cache the information so I can send the result back immediately from threadsRequest(). I had an additional problem that thread IDs were being reused in the the Java runtime (which I now know VSCode doesn't like).
In the end, it was probably a combination of issues in my adaptor.

@adelphes adelphes closed this as completed Feb 8, 2017
@isidorn
Copy link
Contributor

isidorn commented Feb 9, 2017

@adelphes got it. Thanks for providing an explanation.

@vadimcn
Copy link
Contributor

vadimcn commented Aug 23, 2017

@isidorn, so is ThreadEvent mandatory?

I understand that without it, VSCode won't know about newly spawned threads while the program is running. But one has received a stop event, and queried thread list via the threads request, it has the full list, so ThreadEvent shouldn't be necessary?

This used to work (without sending ThreadEvents) for a while, but I've noticed that this is no longer the case (as of v1.15.1). If I don't send a "thread created" event for each new thread, they don't show up in the callstack pane.

@isidorn
Copy link
Contributor

isidorn commented Aug 28, 2017

@vadimcn sorry for the slow response I was on vacation.
On every stop event vscode will ask the frontend for all threads here

So you are saying that on a stop event if there was no thread created event that thread will not de displayed? Correct?

@vadimcn
Copy link
Contributor

vadimcn commented Aug 28, 2017

So you are saying that on a stop event if there was no thread created event that thread will not de displayed? Correct?

Yes, only the threads whose tids were ever mentioned in StoppedEvent are shown in the UI.

This used to be the case a while back, then VSCode was changed to display all threads returned by ThreadsRequest, so I stopped sending ThreadEvents to reduce chatter. But now it seems to be back to old ways again. I can put sending ThreadEvents back, if that's what the spec says.

@isidorn
Copy link
Contributor

isidorn commented Aug 29, 2017

"Thread events are optional but a debug adapter can send them to force VS Code to update the threads UI dynamically even when not in a stopped state"
From https://code.visualstudio.com/docs/extensionAPI/api-debugging

So, yes they are optional.

@vadimcn please file a new issue regarding the problem you outlined in the comments above. And mention me on it.
@weinand fyi

@vadimcn
Copy link
Contributor

vadimcn commented Aug 30, 2017

#33472

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants