Hover tool takes long time to render

Upgrading from Bokeh 2.3.0 to 2.4.0, for the same data set, the hover tool is taking longer time to render.

I did many experiments and found that I could improve (fix) the long render by commenting out some arguments,

ht = HoverTool(
    tooltips=[("i", "@i{0.00} uA"), ("t", "@t{0.000} ms"), ("y", "@y uA"), ],
    #mode='vline',
    #show_arrow=True,
    #renderers=[line],
)

Turning on any of mode, show_arrow, renders, causes the hover tool render time to increase. I have proven this out in this minimum example.

from bokeh.layouts import layout
from bokeh.io import show
from bokeh.plotting import figure
from bokeh.models import ColumnDataSource, Range1d, LinearScale, LinearAxis, HoverTool

NUM_DATA_POINTS = 48000

source = ColumnDataSource(data={
    "t": [i for i in range(1, NUM_DATA_POINTS)],
    "i": [i for i in range(1, NUM_DATA_POINTS)],
    "y": [i * 2 for i in range(1, NUM_DATA_POINTS)],
})

plot = figure(toolbar_location="above",
              y_range=(0.1, NUM_DATA_POINTS*4),
              x_range=(0, NUM_DATA_POINTS),
              y_axis_type="linear")

line = plot.line(x="t", y="i", line_width=2, source=source, color="green", legend_label="i")
plot.line(x="t", y="y", line_width=4, alpha=0.4, source=source, color="red", legend_label="y")

ht = HoverTool(
    tooltips=[("i", "@i{0.00}"), ("y", "@y{0}"), ("t", "@t{0.000} ms")],
    # >>> Uncomment to make hover tool really slow
    #mode='vline',
    #show_arrow=True,
    #renderers=[line],
)
plot.tools = [ht]
doc_layout = layout()
doc_layout.children.append(plot)
show(doc_layout)

I have also taken this example, modified to run in bokeh server, and the result is the same.

Now the hard part to explain, and my question…

I use flask and bokeh components interface, and the above example is a port of what I am doing in flask. With the above example, the workaround to fix the slow hover render is to not set those hover tool options, which is acceptable to me. However, my flask implementation, the fix above does not work, the hover tool rendering is still slow. Is it possible there is a difference between the components resultant code, versus the minimal example above. As noted I checked the bokeh server, in case that would duplicate the issue I see in flask, but bokeh server is fine with the work around.

I further notice, that even with the work around, that you you slide the mouse across the green line, the hover tool renders fast, but when one deviates from the line, and then comes back to the green line, there is a noticeable lag. Not all the time, but some of the time.

1 Like

Seems like a regression, you should file a GitHub Issue with full information.

1 Like

I am also facing this issue.

Rather than flask, I’m using Panel, and I also see massively degraded performance on quadmeshes & heatmaps:

The left side shows the pre-rendered chart as standalone html file, while the right side shows the same pre-rendered chart embedded via Panel HTML pane.

This used to work fine before the update to 2.4.0.

1 Like

A fix has already been submitted, it will be in the next point release.

1 Like