Bokeh plots disappear randomly in a Jupyter lab notebook

When showing several bokeh plots in the most recent version of Jupyter lab, and scrolling between them it happens almost always that the plots disappear completely, except for all or part of the tools bar.
Versions used:

  • bokeh 3.7.3
  • jupyterlab 4.4.4
  • IPython 9.2.0
  • jupyter_bokeh 4.0.5
  • bokehJS is 3.73 as well

I wish I could upload a video here to show that behaviour but there is one here:

There are no errors on the JS console.

My feeling is that this is a problem with how bokeh plots get repainted when the page gets scrolled in a way to make them move into the visible area again: sometimes the appear after some delay, sometimes they do not appear at all.

I have no idea if this is bug in bokeh or jubyterlab or both but it is extremely annoying. This does not happen with plotly dynamic plots so I lean towards thinking it may be a bokeh bug.

Does anyone else experience this?

Here is the code for reproducing this:

import bokeh
print("bokeh", bokeh.__version__)
import bokeh.io
import bokeh.plotting
import numpy as np
import notebook, IPython, jupyter, jupyter_bokeh, jupyterlab

print("notebook", notebook.__version__, "IPython", IPython.__version__, 
      "jupyter_bokeh", jupyter_bokeh.__version__, "jupyterlab", jupyterlab.__version__)
bokeh.io.output_notebook()

x=np.arange(1000)
y1=np.random.randn(1000)
y2=np.random.randn(1000)
y3=np.random.randn(1000)
def make_plot():
    source = bokeh.models.ColumnDataSource(data=dict(x=x,y1=y1,y2=y2,y3=y3))
    xdr = bokeh.models.Range1d(start=0, end=99)
    p1 = bokeh.plotting.figure(height=200, width=1000,tools="xpan,box_zoom,wheel_zoom,xbox_select,reset,undo", toolbar_location="above",x_axis_location="above", x_range=xdr)
    p1.line('x', "y1", source=source)
    p2 = bokeh.plotting.figure(height=200, width=1000,tools="", toolbar_location=None,x_axis_location="below", x_range=xdr)
    p2.line('x', "y2", source=source)
    p3 = bokeh.plotting.figure(height=200, width=1000,tools="", toolbar_location=None,x_axis_location="below", x_range=xdr)
    p3.line('x', "y3", source=source)
    fig=bokeh.layouts.gridplot([p1,p2,p3], ncols=1)
    return fig
fig=make_plot()
bokeh.plotting.show(fig)

Then a bunch of empty lines to enable scrolling then once the first plot as scrolled of the page

bokeh.plotting.show(fig)

maybe repeat two or three times.

Then scroll up and down und you will notice that some plots complety disappear and never come back while others first are gone but get re-drawn after a few seconds.

As I just found out, this is probably a Jupyterlab bug. Changing the Jupyterlab configuration option Window mode from the default “full” to either “defer” or “none” seems to fix this.

@johann-petrak apologies this dropped off my radar due to some personal issues. Can you point to any documentation (or GH issues) about the configuration option you changed? Is this something we need to add to the docs for other users to know about?

1 Like

No – I did not know about this documentation option myself, but someone mentioned it in the Jupyterlab issue I linked above, I tried it and realized that it helps.
See Cells sometimes do not render when scrolling down in presence of large outputs · Issue #17023 · jupyterlab/jupyterlab · GitHub

IMO this should get fixed by Jupyterlab, ideally by changing the default to a value that does not show that problem which would be an easy fix.
Giving a heads-up in the Bokeh docs about this for users who use Jupyterlab versions where this happens (I think all 4.x up to at least 4.4.4, but I did not test all version, saw it myself with at least 4.3.x and several 4.4.x versions) would perhaps help avoiding users reporting this again and again.

1 Like

Seems reasonable @johann-petrak can you make a GitHub Issue that links to this dicussion thread?