Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash in hv.Labels DynamicMap with hook adding Bokeh Label annotation #6178

Open
TheoMathurin opened this issue Apr 9, 2024 · 4 comments
Open

Comments

@TheoMathurin
Copy link
Contributor

ALL software version info

Holoviews 1.18.3
Bokeh 3.4.0
Panel 1.4.0

Description of expected behavior and the observed behavior

With previous versions of Bokeh (up to 3.3.4 with Panel 1.3.8), I could add a static annotation using a hook on a DynamicMap that itself returned a hv.Labels element. It now triggers a crash and the plot gets updated in an unexpected way.

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import holoviews as hv
import pandas as pd
from bokeh.models import Label

hv.extension('bokeh')

slider = pn.widgets.IntSlider(name='Slider', start=0, end=1)

df = pd.DataFrame({'text': ['A', 'B'], 'value': [0, 1],
                   'x': [1, 2], 'y': [1, 2]})


def get_plot(value):
    df_ = df[df['value'] == value]
    return hv.Labels(df_, ['x', 'y'], 'text')


def add_annotation(p, element):
    p.state.add_layout(
        Label(x=0, y=0, text='TEXT'))


dmap = hv.DynamicMap(pn.bind(get_plot, slider)).opts(hooks=[add_annotation])

pn.Column(slider, dmap).servable()

Stack traceback and/or browser JavaScript console output

No error in python, but the following in the browser:

Uncaught (in promise) DOMException: FontFaceSet.check: Invalid font shorthand

Screenshots or screencasts of the bug in action

labels_bug

@TheoMathurin TheoMathurin changed the title Crash in hv.Labels DynamicMap with hook adding bokeh Label annotation Crash in hv.Labels DynamicMap with hook adding Bokeh Label annotation Apr 9, 2024
@hoxbro
Copy link
Member

hoxbro commented Apr 9, 2024

Likely a regression in Bokeh, cc @mattpap

@TheoMathurin
Copy link
Contributor Author

I'd file an issue there but I'm having a hard time trying to produce a MRE in pure Bokeh.

@mattpap do you have an idea about the root cause of this?

@mattpap
Copy link

mattpap commented Apr 17, 2024

Sorry, I missed this issue. This error most likely originates from bokehjs' font metrics code, but I need to reproduce this and investigate to know more. @TheoMathurin, is this code everything that's involved or maybe there's a theme of some sort involved?

@TheoMathurin
Copy link
Contributor Author

Thanks, yes this example is all that's needed to reproduce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants