MouseMove events queuing up after 2.3.0 update

I’ve noticed that a dashboard I’ve been building has suffered a drop in performance after updating from 2.2.3 to 2.3 (on my machine, at least).

Specifically I am using the event MouseMove on an image to update a line on an adjacent plot. With 2.2.3 the line ceases to update as soon as I stop moving the mouse, which I interpret to be ‘good’; while with 2.3.0 the line continues to update for a while after I stop (depending on how fast I was moving the mouse) [tested by switching between venvs]. It is possible that the overall update rate is lower in 2.2.3, leading to reduced ‘queuing’, but I don’t have a way to measure that.


import numpy as np
from import curdoc
from bokeh.layouts import column
from bokeh.plotting import figure
from import MouseMove
from bokeh.models import ColumnDataSource

h,w,s = (50,100,200)
np_data = np.random.uniform(size=(h,w,s))

def sample_data(x,y):
    xs, ys = np.clip(x,0,w-1).astype(int), np.clip(y,0,h-1).astype(int)
    yvals = np_data[ys,xs,:]
    return yvals

xvals = np.arange(s)
yvals = sample_data(0,0)
source = ColumnDataSource(data={'a': xvals, 'b': yvals})

def mousemove_callback(event):
    yvals = sample_data(event.x, event.y) = {'a':xvals,'b':yvals}

pimg = figure(plot_width=800, plot_height=400)
pimg.image(image=[np_data[...,0]], x=0, y=0, dw=w, dh=h)
pimg.on_event(MouseMove, mousemove_callback)
pline = figure(plot_width=800, plot_height=300)
pline.line('a', 'b', source=source)

layout = column(pimg, pline)

I appreciate this isn’t really a good type of interactivity to implement (too fast update rate, throttling etc.), but I am intrigued what is causing this change? My original implementation was in holoviews where the performance change seems even worse with the update (although again I don’t have a way to measure that well).

1 Like

CC @mateusz

This may or may not be relevant, but some poking around in the Firefox network inspector shows that the 'mousemove' message being sent from the browser is much larger in 2.3.0 (~65 kB) than 2.2.3 (215 B):



In the older version it seems the message just has the x/y coordinates of the mouse (in data and screen space), while in the new version it is sending (I believe) a full copy of the document including the base64-encoded image (2.3.0 JSON message file here: An example mousemove message in Bokeh 2.3.0 · GitHub)

Currently serialization of MessageSent document event includes all model references this event’s model field refers to, whereas it should include only previously unknown models. This is a regression since PR Please create an issue and we will get this fixed.

OK, have done that here: [BUG] Serialization of MessageSent document event includes all model references · Issue #11026 · bokeh/bokeh · GitHub