microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.59k stars 29.03k forks source link

Color theme resets to default while editing #101648

Closed Dotrar closed 3 years ago

Dotrar commented 4 years ago

(Disclaimer: this is difficult to track down or describe, so I'm asking for a way I could debug this further)


Hi all.

I have found an annoying bug in VSCode that causes the color theme of VSCode to reset to the default while I'm in the middle of writing/editing.

ie: I will go from this: successcolour to this: failcolour almost painlessly.

It almost seems like I am pushing a hotkey button to "redraw window with default theme" but I am not.

I have tried to track it with the developer console log, but that has shown nothing of value ( errors were reported well before the reset takes place, sometimes no errors at all )

Here's some info that I have:

It is probable that the solution can be fixed by disabling the VSVim or prettier extensions, but I am under the impression that if they are crashing or causing some sort of issue, the user preferences (colour theme) shouldn't change. Unless it is the theme itself that is crashing?

Is there some way I can debug this further? maybe more in-depth console, or a way to stress test the semantic highlighter?

gjsjohnmurray commented 4 years ago

Do you get the same color changes if you explicitly disable semantic highlighting? If so, it sounds like one of your extensions occasionally causes the extension host (EH) to crash or become unresponsive.

aeschli commented 4 years ago

HTML has no semantic highlighting except in the script parts.

Do you have any extension installed that change the theme, e.g. based on daylight? Do you have window.autoDetectColorScheme enabled?

Dotrar commented 4 years ago

Do you have window.autoDetectColorScheme enabled?

Nope, but:

Do you have any extension installed that change the theme, e.g. based on daylight?

I have found out to be true, through a bit of trial and error. REPO to the theme is here: https://github.com/Binaryify/OneDark-Pro

As it turns out, this colour theme is not just a colour theme, but instead an extension that installs a few colour themes and allows you to switch between multiple ones.

I would imagine that it is perhaps choking up, which resets to the default theme. I'll get to debugging and put an issue over there.

Dotrar commented 4 years ago

OK, now I'm getting somewhere.

I was giving up on the colortheme above, and decided to rip out the colours to just to make a "bog-standard" theme ( here: https://github.com/Dotrar/one-dark-proless/blob/master/README.md )

so this is meant to be just a theme.json, specifying colours.

and now I've still triggered the resetting of the theme, but the console log actually shows up with an error now

https://pastebin.com/raw/tsWqrQsD

What seems to happen is the extension host sends a deprecation warning, and also fixSpellingWithRenameProvider gets enabled, and then a TreeError as per the other issues ( #86201, #94181) etc.

I'm using https://github.com/streetsidesoftware/vscode-spell-checker. I'll disable it and see if I get similar issues.

I think it's safe to say it's not the theme that's doing it.

aeschli commented 4 years ago

Did you find out if disabling all other extensions makes the issue go away?

Dotrar commented 4 years ago

It's very sporadic and hard to trace, so I haven't disabled every extension; just most of the ones that I think it's the issue with. My colour scheme loads up as an extension anyway, which means that I can't uninstall that if we wanted to dial into that issue.

Anyway, I've just found it triggered again, and I managed to catch the log without much on it other than errors, which is very promising. log attached at the bottom.

To me it seems like it's just the extension host dying, which then resets, which would then kill my theme, as my theme is loaded as an extension. I can't find a way to install the theme as a non-extension.

Steps to reproduce

So from what I can gather, in a small, possible to reproduce way:

  1. Have theme installed as extension
  2. Forcefully crash the extension host, the theme of vscode will go back to default
  3. Extension host comes back up, extensions reload, but theme will remain default until there's another refresh of the window where it can grab the colours from the loaded extension.

I think this is probably the most concise I can make the issue. I think this particular crash at the moment is just from ms-python not handling a 407 error. but other crashes are possible from other extensions.

Possible solutions.

I think the ideal scenario is to either:

or

errata

NB: it took me probably 15mins to get the words right and vscode is still on default colours.

Log File from crash

console.ts:137 [Extension Host] (node:11024) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
t.log @ console.ts:137
console.ts:137 [Extension Host] (node:11024) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
t.log @ console.ts:137
console.ts:137 [Extension Host] rejected promise not handled within 1 second: Error: Request failed with status code 407
t.log @ console.ts:137
console.ts:137 [Extension Host] stack trace: Error: Request failed with status code 407 at e.exports (c:\Users\dw06\.vscode\extensions\ms-python.python-2020.8.101144\out\client\extension.js:9:52398)  at e.exports (c:\Users\dw06\.vscode\extensions\ms-python.python-2020.8.101144\out\client\extension.js:24:272299)    at IncomingMessage.<anonymous> (c:\Users\dw06\.vscode\extensions\ms-python.python-2020.8.101144\out\client\extension.js:46:706651)  at IncomingMessage.emit (events.js:208:15)  at endReadableNT (_stream_readable.js:1168:12)  at processTicksAndRejections (internal/process/task_queues.js:77:11)
t.log @ console.ts:137
mainThreadExtensionService.ts:65 [[object Object]]Request failed with status code 407
$onExtensionRuntimeError @ mainThreadExtensionService.ts:65
mainThreadExtensionService.ts:66 Error: Request failed with status code 407
    at e.exports (c:\Users\dw06\.vscode\extensions\ms-python.python-2020.8.101144\out\client\extension.js:9:52398)
    at e.exports (c:\Users\dw06\.vscode\extensions\ms-python.python-2020.8.101144\out\client\extension.js:24:272299)
    at IncomingMessage.<anonymous> (c:\Users\dw06\.vscode\extensions\ms-python.python-2020.8.101144\out\client\extension.js:46:706651)
    at IncomingMessage.emit (events.js:208:15)
    at endReadableNT (_stream_readable.js:1168:12)
    at processTicksAndRejections (internal/process/task_queues.js:77:11)
$onExtensionRuntimeError @ mainThreadExtensionService.ts:66
aeschli commented 3 years ago

Thanks a lot for all your investigations. Still I'm puzzled as I'm not able reproduce. I wrote an extension that crashes the EH and did not see any theme changes. The color theme would try reload on a settings change or an extension installation/uninstall. So maybe it's a combination of that with a crash?

The EH crash will prevent the theme from loaded, there's no alternative to that. So I think the only fix will be to find the crashing extensions and fix them. If you can file your reproducible steps against the extension that crashes that would be great.