Skip to content

"Python: Create new blank Juypter notebook" shows a blank editor #500

Closed

Description

@mjbvz

Issue Type: Bug

Repro

  1. Run the Python: Create new blank Juypter notebook command

Bug
A blank editor shows up. It never is filled in:

image

The developer tools for the webview show:

Uncaught Error: An instance of the VS Code API has already been acquired
    at <anonymous>:11:13
    at e.acquireApi (commons.initial.bundle.js:2)
    at e.addHandler (commons.initial.bundle.js:2)
    at Object.k (commons.initial.bundle.js:2)
    at Module.U4QP (nativeEditor.js:1)
    at o (nativeEditor.js:1)
    at Object.0 (nativeEditor.js:1)
    at o (nativeEditor.js:1)
    at a (nativeEditor.js:1)
    at nativeEditor.js:1

Extension version: 2020.9.114305
VS Code version: Code - Insiders 1.51.0-insider (16f4a29aa0ac05d3cba222b1f347b7404626c680, 2020-10-26T05:32:45.135Z)
OS version: Darwin x64 19.6.0

Activity

  1. mjbvz commented on Oct 27, 2020

    @mjbvz
    Author

    Same error + blank window when for opening a notebook file

    Possibly related: microsoft/vscode#109273 /cc Connor Peet (@connor4312)

  2. connor4312 commented on Oct 27, 2020

    @connor4312
    Member

    Looks like (just by searching keywords on github) one usage is coming from a minified bundle whose source I don't have access to.

    First usage: (not sure where this is in source)

    Second usage:

    From https://github.com/microsoft/vscode-python/blob/f02fce43c46eea68932ac95773d67d1cb70588dd/src/startPage-ui/react-common/postOffice.ts#L76

    Using an Insiders version from a few days ago, I only see a single call from the latter location -- so something with changing const -> globalThis (which should be generally identical as far as I know) is causing the extension to make an additional call. Or there was some other behavior change in the same time period.

    Can you toss a code pointer to the source of the former location?

  3. changed the title [-]"Python: Create new blank Juypter notebook" shows a blank window[/-] [+]"Python: Create new blank Juypter notebook" shows a blank editor[/+] on Oct 27, 2020
  4. eternalphane commented on Oct 27, 2020

    @eternalphane

    so something with changing const -> globalThis (which should be generally identical as far as I know) is causing the extension to make an additional call

    It seems that globalThis.acquireVsCode breaks the notebook ui test (#10675):

    https://github.com/DonJayamanne/pythonVSCode/blob/f38b636455a507e867a043df5d735d4e3968da23/src/datascience-ui/interactive-common/redux/store.ts#L307-L308

  5. joyceerhl commented on Oct 27, 2020

    @joyceerhl
    Contributor

    Can you toss a code pointer to the source of the former location?

    Connor Peet (@connor4312) we're attempting to access acquireVsCodeApi off the global window object below, this is the source of the duplicate acquire. It's possible the globalThis change caused this check to no longer work:

    https://github.com/microsoft/vscode-python/blob/cec827ffcb1917c3acc7494f11785408c8a18ca1/src/datascience-ui/interactive-common/redux/store.ts#L307-L309

    Would you mind clarifying what you mean by this?

    I only see a single call from the latter location

  6. connor4312 commented on Oct 27, 2020

    @connor4312
    Member

    Okay. I think a good fix would be some additional or marker for unit tests that doesn't require you to call acquireVsCodeApi, since now it's present on the window.

  7. joyceerhl commented on Oct 27, 2020

    @joyceerhl
    Contributor

    Yeah I'm not sure why this fails now when it didn't before (those three lines haven't changed in 7 months), but in any case we should be passing the vscodeApi object through as recommended in https://code.visualstudio.com/api/extension-guides/webview#passing-messages-from-a-webview-to-an-extension. I've put up a PR to address this. Thanks Connor Peet (@connor4312) and Matt Bierner (@mjbvz) 😊

  8. connor4312 commented on Oct 27, 2020

    @connor4312
    Member

    Previously acquireVscodeApi was defined in a global scope, but not on the window. The change we made caused it to be defined on the window, which made the UI-test-detecting code start calling acquireVsCodeApi()

  9. joyceerhl commented on Oct 27, 2020

    @joyceerhl
    Contributor

    Ah got it. Thanks for explaining!

  10. jejsemin commented on Oct 28, 2020

    @jejsemin

    Has anyone fixed this issue yet? I am still getting a blank screen when I open up Python files

  11. joyceerhl commented on Oct 28, 2020

    @joyceerhl
    Contributor

    Hi Justin (@jejsemin), we are releasing a fix for blank Jupyter notebooks in VSCode Insiders as part of the Python extension's October stable release, which should go out today or tomorrow. If you are experiencing a blank screen in VSCode stable, that is likely a different bug—please file a new issue describing the bug and provide logs and system information so we can assist you. Thanks for your patience!

  12. joyceerhl commented on Oct 28, 2020

    @joyceerhl
    Contributor

    Justin (@jejsemin) we just released https://github.com/microsoft/vscode-python/releases/tag/2020.10.332292344, please let me know if this fixes the problem for you!

  13. jejsemin commented on Oct 28, 2020

    @jejsemin

    Justin (@jejsemin) we just released https://github.com/microsoft/vscode-python/releases/tag/2020.10.332292344, please let me know if this fixes the problem for you!

    Seems like everything is working again ! Thank you

  14. deepan-py commented on Oct 29, 2020

    @deepan-py

    Justin (@jejsemin) we just released https://github.com/microsoft/vscode-python/releases/tag/2020.10.332292344, please let me know if this fixes the problem for you!

    Everything is back to normal thanks for letting us to know. Do you know what caused the problem?

  15. joyceerhl commented on Oct 29, 2020

    @joyceerhl
    Contributor

    Deepan Sankar (@deepan-py) Yes, our codebase contains two calls to acquireVsCodeApi, which is a special function that allows VSCode webviews to use the VSCode API and should only be called once per session. The second call was only intended to invoke a mock of the function which we set up on the window object while running UI tests. The latest Insiders build included a change which made the real acquireVsCodeApi available on the window object. This caused our extension to call it more than once and our Jupyter notebook UI and interactive window, both of which are implemented using webviews, to crash. The fix that went out in today's stable release removes that second invocation.

  16. rchiodo commented on Oct 29, 2020

    @rchiodo
    Contributor

    Fix should be in latest release

  17. jejsemin commented on Nov 3, 2020

    @jejsemin

    I'm still getting this problem after it was fixed for a few days

  18. joyceerhl commented on Nov 3, 2020

    @joyceerhl
    Contributor

    Justin (@jejsemin) I can't repro this problem on Windows 10 with Insiders 1.51.0 and our latest release of the Python extension (v2020.10.332292344). Would you mind providing details, including your OS, VSCode version, Python extension version, logs, and any relevant screenshots, please? Thanks!

  19. jejsemin commented on Nov 3, 2020

    @jejsemin

    Justin (@jejsemin) I can't repro this problem on Windows 10 with Insiders 1.51.0 and our latest release of the Python extension (v2020.10.332292344). Would you mind providing details, including your OS, VSCode version, Python extension version, logs, and any relevant screenshots, please? Thanks!

    OS. MacOS Catalina Version 10.15.7
    Python Extension: 3.9.0 64-bit
    It
    Screen Shot 2020-11-03 at 5 14 16 PM


    Screen Shot 2020-11-03 at 5 10 41 PM

  20. joyceerhl commented on Nov 3, 2020

    @joyceerhl
    Contributor

    Hm, I cannot repro this on my Macbook (admittedly running 10.14). Could you confirm that you have the latest Python extension installed and are also running VSCode Insiders 1.51? Then could you run Command+Shift+P and type in "Developer: Open Webview Developer Tools" to bring up the developer console log, and see if there are any error logs in there?

  21. LaurensvanG commented on Nov 5, 2020

    @LaurensvanG

    I am on Windows 10, using the v2020.11.311084263-dev version of the extension in VSC insiders 1.51.0-insider, experiencing the same issue.

    The following console log results from opening a notebook:
    image

    The notebook opens normally in the public release 2020.10.332292344, with the following console logs:
    image

    I hope this info helps somewhat. If you need more information, I'd be happy to provide it.


    edit: Perhaps important to note is that 'Open in preview Notebook Editor' does work as expected. But opening it in the normal Notebook Editor (either clicking on the file or in the right-click context menu) produces the empty window.

  22. flazouh commented on Nov 8, 2020

    @flazouh

    Getting the same error when trying out the new notebook feature by downloading code inside.

    Version: 1.52.0-insider
    Commit: 24b28f57be22fe3029cb17a1dd72d8d9c2d6468b
    Date: 2020-11-06T05:39:23.276Z (2 days ago)
    Electron: 9.3.3
    Chrome: 83.0.4103.122
    Node.js: 12.14.1
    V8: 8.3.110.13-electron.0
    OS: Darwin x64 19.6.0

    Screenshot 2020-11-08 at 22 13 51

  23. joyceerhl commented on Nov 8, 2020

    @joyceerhl
    Contributor

    @Maulorian, what version of the Python extension are you using? Could you try using v2020.10.332292344 (the latest stable version) and let me know if you still encounter the same behavior?

  24. flazouh commented on Nov 9, 2020

    @flazouh

    Ah yes, it works!

  25. flazouh commented on Nov 9, 2020

    @flazouh

    Joyce Er (@joyceerhl) Hey, I installed insiders to be able to have features like linting (missing imports and such) in my notebooks. but it doesn't seem to be working:

    Screenshot 2020-11-09 at 13 53 05

    great_circle is not highlighted or anything if I remove the import

  26. locked as resolved and limited conversation to collaborators on May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions