Toolbar tools difficult to toggle when HoverTool is active

Hello,

When I have my HoverTool enabled, I’m having a hard time activating/deactivating tools in the toolbar as they keep flickering when moving the cursor, and sometimes when clicking on them, causing the activation/deactivation of the tool to fail.

Here is a screen recording of the issue:
(note: this recording is not 60fps; on my screen the flickering is much worse)
https://gfycat.com/barrenunrealisticcockroach

This problem does not occur when the ‘renderers’ list of the HoverTool is empty. The only objects that are in my ‘renderers’ are GlyphRenderers of Circle glyphs.

Is there something I am doing wrong or is this a bug?

@sralok

The behavior you show is interesting, and not something I have personally encountered before.

The following minimal example does not show the problem for me; I tested with bokeh versions 1.4.0 and 2…0.2 in standalone mode with Chrome as the browser. I also varied the hover-mode (mouse versus hline), which made no difference.

I think to have help track down the problem, you’ll be asked to provide a minimally reproducible example and any relevant information about your environment (versions, standalone or server, etc.)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
"""
import numpy as np

from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, HoverTool

x = np.random.randn(100)
y = np.random.randn(100)

data = dict(x=x, y=y)
source = ColumnDataSource(data=data)

p = figure(width=300, height=300)

r = p.circle(x='x', y='y', size=10, source=source)

h = HoverTool(renderers=[r], mode='mouse')
p.add_tools(h)

show(p)

Huh that’s strange. My other plots don’t seem to be having this issue either. I’ll try to figure out what it’s caused by.

@_jm

I have managed to replicate the flickering issue with a small adjustment of your code.

I should have indeed provided some information; I tested this on Bokeh versions 2.0.2 and 2.1.0 in standalone mode on Chrome.

However, it looks like the issue I mentioned regarding the toggling of tools sometimes failing, caused by this bug, does not seem to be present in this simple standalone test. The screen recording in the OP was made on a Django server.

import numpy as np

from bokeh.plotting import figure, show
from bokeh.models import ColumnDataSource, HoverTool, Circle

x = np.random.randn(100)
y = np.random.randn(100)

data = dict(x=x, y=y)
source = ColumnDataSource(data=data)

p = figure(width=300, height=300)

glyph_default = Circle(x='x', y='y', size=10)
glyph_hover = Circle(x='x', y='y', fill_color='red')
r = p.add_glyph(source, glyph_default, hover_glyph=glyph_hover)

h = HoverTool(renderers=[r])
p.add_tools(h)

show(p)

@sralok

Interesting. I ran the modified example, and can see the flickering when the mouse is over the toolbar tools.

I did not experience the state of any tools toggling, which I think is consistent with your latest report of the behavior. However, it does seems like I occasionally experienced events where an attempt activate a particular tool, e.g. Box Zoom, Reset, Help, did not always register and had to click a second time whilst it was flickering.

@_jm

However, it does seems like I occasionally experienced events where an attempt activate a particular tool, e.g. Box Zoom, Reset, Help, did not always register and had to click a second time whilst it was flickering.

Maybe the way I worded it was a bit off, but this is indeed what I meant; clicks on the toolbar not always registering.

Perhaps I should open an issue about this bug on GitHub?

@sralok

I think that is a reasonable next step. You have a fairly tight, easy to understand example to illustrate the behavior.