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

Improve debug self hosting experience #100368

Closed
isidorn opened this issue Jun 17, 2020 · 60 comments
Closed

Improve debug self hosting experience #100368

isidorn opened this issue Jun 17, 2020 · 60 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues

Comments

@isidorn
Copy link
Contributor

isidorn commented Jun 17, 2020

Most notable with regards to debugging vscode.

@isidorn isidorn added this to the June 2020 milestone Jun 17, 2020
@isidorn isidorn added the debug Debug viewlet, configurations, breakpoints, adapter issues label Jun 17, 2020
@isidorn
Copy link
Contributor Author

isidorn commented Jun 17, 2020

Also assinging to @weinand since the large self hosting compound debugs everything inlcuding EH debugging

@isidorn
Copy link
Contributor Author

isidorn commented Jun 17, 2020

Related issue filled by @joaomoreno #83994
fyi @deepak1556 and @roblourens since they are assigned to that issue
@jrieken says it is very flaky and issues are not reproducable in general

I will self host on it more in the following days and hopefully can idenity issues that are paper cuts.

@jrieken
Copy link
Member

jrieken commented Jun 17, 2020

Yes, using the "VS Code" launch config is very frustrating. There are many UX paper cuts like notification spam, questionable debug console selection, disconnect vs stop button etc pp. However, there is also severe trouble where things freeze or crash and that seems to happen 2 out of 3 times and only when a breakpoint is set here but not there or when a console message appears at a bad time or what not. This seems soo random that I cannot file a bug that would meet my personal bug min bar and that's read sad part of this. I have no clue how to help to improve this.

@isidorn
Copy link
Contributor Author

isidorn commented Jun 17, 2020

Following down the issue links, this seems to be the issue on the Electron side for the random crashes electron/electron#21288
As for other papercuts we can look into fixing them on the vscode side.

@jrieken
Copy link
Member

jrieken commented Jun 17, 2020

Following down the issue links, this seems to be the issue on the Electron side for the random crashes electron/electron#21288

No. I know about the break-on-async-problem but this is a head to head comparison with devtools and vscode and while I can happily work with the former I cannot with the latter.

@roblourens
Copy link
Member

One issue that I repro often is that if the renderer process console.logs a lot while vscode is attached, it will hang. Doesn't happen when only attached with devtools.

@connor4312
Copy link
Member

connor4312 commented Jun 17, 2020

@jrieken please file issues for me when you run into a papercut or problem, even if you run into a issue you can't consistently reproduce. You can also add trace: true to your launch configuration locally so that you have a log available whenever you run into a problem. (The location of the log file for each run will be printed to the debug console.) My bug queue for js-debug is almost empty right now, I need to know about issues in order to fix them! 🙂

disconnect vs stop button etc

This should be better with #99736

notification spam, questionable debug console selection

Can you expand on these? Either here or a new issue is good.

things freeze or crash

I think Eric has also seen these. I can only assume this is some problem in Electron. I have not observed the extension host/node/chrome freezing in that way. I'll try to play around and reproduce it locally, a trace: true log would also help if you're able to capture it easily.

One issue that I repro often is that if the renderer process console.logs a lot while vscode is attached, it will hang

I think we fixed this yesterday with: microsoft/vscode-js-debug@154a62d I'll make a console spam extension to try to verify

@jrieken
Copy link
Member

jrieken commented Jun 17, 2020

Can you expand on these? Either here or a new issue is good.

Whenever something doesn't work, e.g because there is still a dangling process or so, things go wild. Simulate the worst of it like so:

  • in the terminal run script/code.sh
  • from debug launch "VS Code"
  • a monster 🌊 of model dialogs and notifications heading to you

Screenshot 2020-06-17 at 18 35 46

I know this is a tricky one and my sample is the worst case but when something fails it's enough to say that once.

@connor4312
Copy link
Member

That'll be fixed in the next nightly microsoft/vscode-js-debug@c462b53

@joaomoreno
Copy link
Member

I often get into this rut: reloading the window stays like this forever. Further reloadings behave the same. I am forced to close the window.

image

Once I close the window, I wait for all debug sessions to terminate, which they do. But then when I F5 again I get:

image

At this point I look for running processes:

➜  vscode git:(joao/scm-view) ✗ ps ax | grep code-oss
27213 ?        Sl     0:00 /home/joao/Work/vscode/.build/electron/code-oss --nolazy --inspect=6044 /home/joao/Work/vscode/extensions/json-language-features/server/out/node/jsonServerMain --node-ipc --clientProcessId=27013

So I kill 'em: killall code-oss. Then it works. 🤷

@joaomoreno
Copy link
Member

The blank window also happens when running ./scripts/code.sh: #100740

@jrieken
Copy link
Member

jrieken commented Jun 22, 2020

Since today, my guess is that's electron 8, debugging is totally broken. Run the "VS Code" launch config and be depressed.

@jrieken
Copy link
Member

jrieken commented Jun 22, 2020

Tho, I still see this: Dangling attach to extension host which on detach shows the timeout error

Jun-22-2020 15-56-54

@connor4312
Copy link
Member

I am seeing the reload issue as well after updating Insiders with ordinary extension host debugging on both the old and new adapters. Definitely seems Electron-related.

I tried to reproduce depression but "Launch VS Code" actually works for me fine on master right now. I wonder if @deepak1556 fixed something today?

I've seen the dangling attach issue a couple times before, will try to repro and fix.

@deepak1556
Copy link
Collaborator

Nope I haven't addressed anything wrt "Launch VS Code" issue.

@connor4312
Copy link
Member

Yea, nevermind, I didn't realize the insiders was frozen -- I checked that I was on the latest but didn't see that it was a pre-Electron 8 build.

@jrieken
Copy link
Member

jrieken commented Jun 24, 2020

paper-cuts: disconnect or stop?

Screenshot 2020-06-24 at 09 43 14

@isidorn
Copy link
Contributor Author

isidorn commented Jun 24, 2020

That one we can fix on the vs code side.
I might have broken this with my compression of sessions work. The current approach: when multiple sessions are merged we show the Stop / Disconnect based on the parent session.
However the Toolbar Stop / Disconnect does not honor this "heuristic" and shows it for the bottom session.
Whatever we choose to do, at least it should be consistent.
I will look into fixing this.

@jrieken
Copy link
Member

jrieken commented Jun 24, 2020

paper-cuts: how likely are breakpoints to be "inside" identifiers? this is surely complicated to get right but some heuristic (at least for JS where this doesn't make sense) that renders them at word boundaries wouldn't make look so bad

Screenshot 2020-06-24 at 12 08 18

@isidorn
Copy link
Contributor Author

isidorn commented Jun 24, 2020

For breakoint locations VS Code trusts extensions and does not update the location.
I agree with you that we could introduce a heuristic to only render them at word boundaries. So the question is where would this heuristic live, on the js-debug side or on vscode side?
However words have different boundaries for different languages. Not sure if I ask for words from the editor would they be language specific.

@connor4312 is there a chance we do this on the js-debug extension side? If not possible, I can also look into introducing a general heuristic for all languages based on words.

@jrieken
Copy link
Member

jrieken commented Jun 24, 2020

Not sure if I ask for words from the editor would they be language specific.

The editor model uses the correct word definition in getWordAtPosition

@isidorn
Copy link
Contributor Author

isidorn commented Jun 24, 2020

Then it feels to me like the proper thing would be to do this on the VS Code side. Especially since I am not aware of a language that would want to place inline breakpoints inside a word.
Though before I jump on this let's see what @connor4312 thinks

@connor4312
Copy link
Member

connor4312 commented Jun 24, 2020

how likely are breakpoints to be "inside" identifiers? this is surely complicated to get right but some heuristic (at least for JS where this doesn't make sense) that renders them at word boundaries wouldn't make look so bad

The screenshot you showed usually happens when the code in the runtime doesn't match whatever you have running locally. For example, if you change a file but don't reload the extension host. E.g. I can reproduce the problem by putting a blank line in "resolve", which will have the breakpoint on the column where it should normally go in the following line:

Does this sound like what might have happened for you?

I agree that it's not a good scenario, and we've an issue someone raised about it before. I don't know what the right behavior is, though; the code mismatches so all bets are off, even if we cosmetically shift the breakpoint column.

Maybe whenever a file is locally edited we unverify all breakpoints in that file. But that could also become annoying. Open to ideas.

we could introduce a heuristic to only render them at word boundaries

I don't think we should do this. js-debug should be responsible for returning the correct breakpoint columns. If it returns a breakpoint in the middle of the word, that's a problem (usually due to mismatched code, or in 🐛 cases, bad sourcemap resolution).

Also, thank you so much for continuing to raise these issues! ❤️

@jrieken
Copy link
Member

jrieken commented Jun 24, 2020

Does this sound like what might have happened for you?

Definitely something like that. In my case I did reload but I noticed that I often need to restart webpack (that sample is from an extension) for it to recover. So, not blaming debug for the bad information it retrieves but more for the way it handles those. Generally, I'd say it should be more conservative with those editing while debugging cases

@connor4312
Copy link
Member

👍 opened microsoft/vscode-js-debug#538

@connor4312
Copy link
Member

connor4312 commented Jul 31, 2020

Spinning out the collected issues thus far to make verification less confusing :)

Joh's "window has crashed" -- we're back on E7 for endgame, wondering if E9 will fix this? Will keep an eye out and to see if it happens on E7 and whether I'm able to catch the trace logs red-handed in that scenario.

@deepak1556
Copy link
Collaborator

Thanks @connor4312 thats super helpful.

@jrieken
Copy link
Member

jrieken commented Aug 12, 2020

FYI that's the only thing I see when trying to debug (VS Code)

Screenshot 2020-08-12 at 09 34 44

@Tyriar
Copy link
Member

Tyriar commented Aug 12, 2020

I've stopped trying to use the debug target because:

  • It often takes so long to launch, not just when electron/built-in extensions need to be downloaded, leading to a bunch of modals
  • It now launches 2 windows? Closing one of them closes the other
  • I sometimes get empty windows as called out here Improve debug self hosting experience #100368 (comment)
  • Closing VS Code does not stop debugging the extension host
  • nit: timeout notification when stopping debugging

@connor4312
Copy link
Member

Thanks for the update, will look at this today or tomorrow.

connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Aug 12, 2020
This is no longer necessary in the self-host case after some refactorings.
Works on microsoft/vscode#100368
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Aug 12, 2020
@connor4312
Copy link
Member

connor4312 commented Aug 12, 2020

It often takes so long to launch, not just when electron/built-in extensions need to be downloaded, leading to a bunch of modals

🏃 I pushed some changes that should improve startup time. We were doing something slow in startup that, in the VS Code case, is no longer needed. Please let me know if that improves things for you.

✔️ I also realized that I only added the "Ensure Prelaunch Dependencies" task to "Launch VS Code", so if you launched the compound task where an update was needed the attachment configs would time out. Fixed that as well...

It now launches 2 windows? Closing one of them closes the other

✔️ Internally js-debug has kind of a legacy feature where tracks the first debug target (in this case, browser page) it sees as the "main target" and stops when it is closed. I think that's what you're hitting here; VS Code might open two windows when it's restoring the state (I assume?) and you're closing the one that's designated as the main target.

Tomorrow I will see if we can remove I have now removed this, it should be good enough to say that as long as one target is alive the debug session should continue.

Closing VS Code does not stop debugging the extension host

✔️ It wasn't my intended purpose when I prompted it, but now that we have a stopDebugging API, I was able fix this correctly. Should work in the next nightly js-debug build 🙂

nit: timeout notification when stopping debugging

✔️ Isi fixed this in today's Insiders.

I sometimes get empty windows as called out here

❓ The message indicates that the Electron instance didn't start listening or didn't have good data on localhost:9222. So the debugger didn't connect, and VS Code was waiting indefinitely. Next time you hit that, please try going to http://localhost:9222/json/list; see if it loads and what's there.

Also, is seeing that specific error (cc @jrieken) recent since today/Electron 9? Wondering if there's some behavioral change or bug there.

@jrieken
Copy link
Member

jrieken commented Sep 2, 2020

Just like @Tyriar (see #100368) I have stopped trying to use the debugger for selfhost, esp. the "VS Code" launch config, I much more pain than gain. Tho, I do use attach to extension host with moderate joy.

@joaomoreno
Copy link
Member

I resumed using this today with E9 and it seems to work much better than before, actually.

@roblourens
Copy link
Member

I still get #105019 from time to time, but it's my only current pain point.

@connor4312
Copy link
Member

I have stopped trying to use the debugger for selfhost, esp. the "VS Code" launch config, I much more pain than gain

Please let me know if you try it again and run into more issues! The issue the Rob mentioned and the slippery #103707 are the only two outstanding issues I know of.

@isidorn
Copy link
Contributor Author

isidorn commented Sep 3, 2020

Moving to September since this is on-going work and nothing more is planned for this milestone as far as I know.

@isidorn isidorn modified the milestones: August 2020, September 2020 Sep 3, 2020
@weinand weinand removed their assignment Sep 25, 2020
@connor4312
Copy link
Member

There've been no more issues on here this month, thus closing it. Please give me a shout if you run into any further problems!

@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
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
Projects
None yet
Development

No branches or pull requests

8 participants