microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.27k stars 284 forks source link

Cell randomly losing focus, view jumping #12863

Open PaulTeco opened 1 year ago

PaulTeco commented 1 year ago

Applies To

What happened?

At random times when working with jupyter notebook, the current cell will unfocus and the view jump a few cells (how much may have to do with any matplotlib plots in the file that are being rerendered it seems). This is accompanied by syntax coloring being lost and coming back a second later. Aside from being annoying and breaking the workflow, this causes keystrokes to trigger e.g. deletion of cells without me realizing it, which is really serious.

In the output/jupyter console, this is accompanied by a number of "debug 14:34:22.666: Disposing request as the cell was deleted c:\Users...\correlation analysis\evaluate_random_noise.ipynb" followed by "debug 14:34:22.689: _jupyterPythonPathFunction: Giving Pylance "c:\Users...\anaconda3\python.exe" as python path for "file:///c%3A/Users/.../correlation%20analysis/evaluate_random_noise.ipynb"" as seen right at the bottom of the jupyter log I pasted below.

Not sure if this has anything to do with it, but the devtools debug console regularly shows the following three kinds of warnings (does not necessarily coincide with above problem):

Only extensions I have active are python + pylance (somehow coming with isort now) and jupyter (with its accompanying extensions cell tags, keymap, notebook renderers and slide show). I have another extension "live server" installed but deactivated.

VS Code Version

Version: 1.75.1 (user setup) Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf Date: 2023-02-08T21:32:34.589Z Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Windows_NT x64 10.0.22621 Sandboxed: Yes

Jupyter Extension Version

v2023.1.2010391206

Jupyter logs

- says comment too long, can't post the log -

Coding Language and Runtime Version

Python v3.9.16

Language Extension Version (if applicable)

Python v2023.2.0 Pylance v2023.2.30

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

None

PaulTeco commented 1 year ago

No idea on what is happening here? I attached a video showing one such occurrence. It seems that the cells are all being rerendered for whatever reason.

https://user-images.githubusercontent.com/47188581/223437130-a701adfe-c6de-4f28-b0ce-fe2f5726c23c.mp4

This is really breaking my workflow every few minutes and makes jupyter notebooks in VScode more or less unusable to me.

roblourens commented 1 year ago

Sorry for the slow response. Thanks for the video. I have no clue what's happening. Can you try disabling other extensions that you may have installed to check whether one of them is interfering?

And is this still happening in the latest 1.77 release?

PaulTeco commented 1 year ago

Yes it is still happening, I use:

Version: 1.77.3 (user setup) Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710 Date: 2023-04-12T09:16:02.548Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.22621 Sandboxed: No

I disabled all extensions except jupyter, jupyter notebook renderer and python. The weird thing is it occurred even if I did not start the kernel yet. I was cleaning up the code before starting the kernel and at some point the cursor would unfocus the cell and the view would jump. No output in the jupyter output log of course. The dev tools console just shows the rerendering of the cells at that moment, nothing else happening, no error, no warning.

While it occurs only in jupyter notebooks (not in scripts) for me, I do suspect by now that the problem lies elsewhere, like where the rendering of syntax coloring and matplotlib plots comes from. I suspect the dev tools warnings "failed to load sourcemap" or "refuse to add event listener" may have something to do with it.

roblourens commented 1 year ago

The dev tools console just shows the rerendering of the cells at that moment

Not sure what you're referring to

Can you run the command "Set Log Level > Trace", reproduce it again, and share the log from the Window output channel (or the devtools console log)

PaulTeco commented 1 year ago

I deactivated all extensions except python and jupyter. Still happening occasionally. Here are the logs with dev tools set to trace.

log_vscode-app-1682504820777.txt

log_jupyter-output.txt

PaulTeco commented 1 year ago

I was now able to reproduce the error deliberately. I opened vscode, clicked into a cell of the jupyter notebook, added a spacebar and saved the file with crtl+s. 2-3 seconds later, the notebook is rerendered, unfocusing the cell and causing the view to jump. Here is a video and the logs where triggered it repeatedly. I have no idea what is going on there. (NB: since I checked it also occurs without any extensions, I activated pylance and isort again).

https://user-images.githubusercontent.com/47188581/235662148-9feb2b4c-cc4b-49c8-a1e2-b2c35f4dc043.mp4

new_log_vscode-app-1683028963427.txt

new_log_jupyter-output.txt

roblourens commented 1 year ago

Thanks for grabbing the screen recording, that helps a lot.

image

There is nothing that stands out to me in the log though. @rebornix could this be the EH crashing? I don't see anything in the log to suggest that but it's a bit hard to navigate the devtools log since it doesn't have timestamps. @PaulTeco are you able to repro this consistently? If so, it would help to have the logs from the Window, Extension Host, and Main output channels as well.

PaulTeco commented 1 year ago

Sorry for the slow reply. Yes at the moment I can reproduce this consistently every time I save the file via crtl+s it takes a few seconds and the rerendering occurs.

I attached the Window, Extension Host and Main outputs. I also copied a part of the window and extension host logs at one such occurence into separate files. There you can see I pressed crtl+s at :37, then the rerendering happens at around :41

extension_host_log on occurence.txt window_log on occurence.txt window_log_full.txt main_log.txt extension_host_log_full.txt

roblourens commented 1 year ago

I don't see any smoking gun in the logs, but it seems like the EH is crashing to me.

@rebornix @DonJayamanne this happens without any extra extensions enabled, any known issues with python/jupyter that would cause the EH to crash somewhat regularly like this?

VSCodeTriageBot commented 7 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

thobitz commented 7 months ago

I have the same issue. VSC version is 1.81.1. Whenever the "Problems" section refreshes, the cell I am working on in Jupyter NB loses focus. The issue only seems to appear for a couple of days - I am not sure whether the behaviour is linked to a file I have edited before, but it does not seem to make a lot of sense.

amunger commented 1 month ago

For those still experiencing this issue, I have an idea of what might be causing the issue, but need to see some logs to confirm and get some clue of why

If you can still repro this could you:

  1. download and install vscode insiders
  2. run the command Developer: set log level and select trace
  3. Use vs code until the issue happens
  4. Copy the "window" logs from the output panel, as well as logs in "notebook" (doesn't have to be all the logs, just from around the time of the issue)
jxu commented 2 weeks ago

I have the same issue. Seems to be the same as #13526. In my case, turning off auto-save works around whatever is going on when saving.

jmerkow commented 1 week ago

Same issue here. Any progress on this?

amunger commented 6 days ago

not yet, but the logs would be very helpful. Stable can be used at this point to collect them

  1. run the command "Developer: set log level" and select trace
  2. Use vs code until the issue happens
  3. Copy the "window" logs from the output panel, as well as logs in "notebook" (doesn't have to be all the logs, just from around the time of the issue)