Skip to content

Delayed evaluation of early-evaluated cells seems to cause ipywidgets "missing js issue" #2087

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

Closed
SylvainCorlay opened this issue Jan 30, 2017 · 6 comments

Comments

@SylvainCorlay
Copy link
Member

In PR #1002, @jasongrout implemented the delaying of the evaluation of the cells that were executed before the kernel was up.

I think that this is what introduced the random jupyter widgets warning message on missing widgetsnbextension, which occurs when such early evaluation is attempted. Indeed, code is then executed before the notebook extension is loaded.

Ping @takluyver

@jasongrout
Copy link
Member

Can you walk us through the timeline of what you think is happening?

@SylvainCorlay
Copy link
Member Author

@jasongrout @minrk @gnestor

What do you think of reverting #1002 and changing execute_cell_and_insert_below so that it first checks that the kernel is live?

@jasongrout
Copy link
Member

I'd rather fix the problem. Can you walk us through the sequence of what you think is happening?

@jasongrout
Copy link
Member

Okay, here's a possible sequence. I haven't tested this.

  1. The notebook launches
  2. The user quickly presses shift-enter to execute a cell that has widget code.
  3. The cell is queued up for execution
  4. The widget javascript is loaded. When the widget javascript is loaded, it immediately sends a comm message to the kernel with the version information, etc. This is comm message is queued behind the cell execution. (TODO: Check that the comm open message to jupyter.widget.version is queued behind the cells)
  5. The kernel starts up.
  6. The cell is executed. Since the kernel widgets has not seen the comm message from the javascript, it assumes there is no widget javascript and so prints an error message: "Widget Javascript not detected. It may not be installed or enabled properly."

Basically, it's a race condition between the widget javascript running before the user executes a cell, and an assumption from the kernel side that the ipywidgets will be able to execute a comm open before any user code runs.

Before #1002, here's what I am thinking was happening in the situations where the message seemed to randomly pop up.

  1. The notebook launches
  2. The user quickly presses shift-enter to execute a cell that has widget code.
  3. The execution is silently ignored since the kernel is not up yet.
  4. The widget javascript is loaded. When the widget javascript is loaded, it immediately sends a comm message to the kernel with the version information, etc. This is also silently ignored!
  5. The kernel starts up.
  6. Another cell is executed. Since the kernel widgets has not seen the comm message from the javascript, it assumes there is no widget javascript and so prints an error message: "Widget Javascript not detected. It may not be installed or enabled properly."

It always seemed fickle when the 'js not installed' error came up.

I think the real problem is that in ipywidgets, we are assuming that the widget javascript will have priority access to a kernel, before user execution. I think we probably need a more robust method for doing the version check.

And clearly this ipywidget check is faulty if we have multiple clients talking to the same kernel. The first client will okay its version of javascript, so the error won't show if the second client does not have the javascript installed.

@jasongrout
Copy link
Member

And clearly this ipywidget check is faulty if we have multiple clients talking to the same kernel.

I'm moving this issue to ipywidgets, since I think the real problem is with the widget javascript check.

@jasongrout
Copy link
Member

Moved to jupyter-widgets/ipywidgets#1211

@minrk minrk added this to the Reference milestone Sep 13, 2018
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants