Closed parente closed 8 years ago
See this comment (and others in that issue) from Sylvain about potential timing issues around Label
.
Looks to be another ipywidgets timing bug. Can't be related to requirejs because we're now webpacking all of ipywidgets into our build to avoid https://github.com/ipython/ipywidgets/issues/561. But the consequence sure looks like the issue we reported before against ipywidgets.
/cc @SylvainCorlay @Carreau because I get the feeling the bug mentioned on standup yesterday and the timing issues we've seen are intertwined.
Findings so far
Thought: We're webpacking all of ipywidgets, but loading declarative widgets asynchronously. Decl widgets also loads all of its modules async. Is the use of async require for decl widgets somehow tripping up ipywidgets thereafter?
/cc @lbustelo
I have experienced the same timing issue in an example corresponding to
web3 example
+ custom widgets (asynchronously loaded model)
web3 example + custom widgets (asynchronously loaded model)
Yep. Root cause here is the same as in https://github.com/ipython/ipywidgets/issues/561: when loading any modules asynchronously, classes from jupyter-js-widgets also start getting resolved asynchronously because of the logic in the utils.js loadClass
and stop working properly. So it's not the async load that's the problem per se. It's some code in ipywidgets that is depending on the load promise getting resolved immediately.
More details about what's happening here in dashboard server with decl widgets vs not ...
As soon as window.requirejs.defined('jupyter-js-widgets')
becomes true, loadClass
function in ipywidgets starts taking the branch that uses window.require
instead of immediately resolving with the webpacked version of jupyter-js-widgets
. When we have a notebook that only uses ipywidgets, defined('jupyter-js-widgets')
remains false because nothing requires it explicitly. This is why a notebook with only ipywidgets works fine. When we have a notebook that uses declarative widgets, defined('jupyter-js-widgets')
becomes true because the declarative widgets require jupyter-js-widgets
explicitly. Once defined is true, everything takes the window.require
path in loadClass
, including all requests for jupyter-js-widgets
. This should not be a problem since the require call ultimately returns the same webpacked widgets module. But it is a problem because somehow the async require causes labels, default values, or sometimes entire widgets not to appear on the page.
@jhpedemonte is going to add more detail to https://github.com/ipython/ipywidgets/issues/561. We should continue the convo there. (This defect is just a symptom.)
The remaining work here is to update to jupyter-js-services 0.10.2 and whatever version of ipywidgets ends up containing the other half of the fix (5.1.5?).
Yeah I will continue making minor releases of ipywidgets.
Tasks:
Original Description:
Using:
OR:
And deploying this notebook:
https://gist.github.com/parente/bcdaab0b004d22dadd60c811240ea048
Sometimes the labels on the ipywidgets widgets go missing. Sometimes the entire widgets go missing. It varies from refresh to refresh.
Expected (seen in notebook):
Result (seen in dashboard server):
Worth noting