[BUG] Incorrect initialization when loading out of focus
See original GitHub issueALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)
bokeh.version = 1.2.0 python: 3.6.8 OS: Windows 10 browser: all
Description of expected behavior and the observed behavior
When loading a bokeh document (served using the directory format) the jinja2 template is not filled as expected if page is not in focus within 30 seconds of loading. Root elements are added successfully in the positions indicated in the template, but figures and ui elements are appended to the bottom of the body instead of in their bk-root elements.
Complete, minimal, self-contained example code that reproduces the issue
The code below places a single checkbox inside a jinja2 template. The console will print a counter going up to 25.000 as a simulated loading process and to give you an opportunity to click away to a different tab or minimize the window. When the counter stops running in your console wait another 30 seconds or more. After the waiting period you can click on the loaded tab and the bokeh document will reload (the counter runs again in your console). After it completes the checkbox will appear. Inspecting the element will show an empty bk-root inside the intended-div, and the checkbox appended to the bottom of the html body instead.
main.py
from bokeh.plotting import curdoc
from bokeh.models import CheckboxGroup
CHECKBOX = CheckboxGroup(labels=['test checkbox'],
name="test")
for x in range(25000):
print("delaying add_root by " + str(x))
curdoc().add_root(CHECKBOX)
templates/index.html
{% from macros import embed %}
{% extends base %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Test</title>
<link
href="https://cdn.pydata.org/bokeh/release/bokeh-1.2.0.min.css"
rel="stylesheet" type="text/css">
<link
href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.2.0.min.css"
rel="stylesheet" type="text/css">
<link
href="https://cdn.pydata.org/bokeh/release/bokeh-tables-1.2.0.min.css"
rel="stylesheet" type="text/css">
<script src="https://cdn.pydata.org/bokeh/release/bokeh-1.2.0.min.js"></script>
<script src="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.2.0.min.js"></script>
<script src="https://cdn.pydata.org/bokeh/release/bokeh-tables-1.2.0.min.js"></script>
<script type="text/javascript"> Bokeh.set_log_level("debug"); </script>
</head>
<body>
{% block contents %}
<div id="intended-div">
{{ embed(roots.test) }}
</div>
<div>Checkbox should be above this element</div>
{% endblock %}
</body>
</html>
Stack traceback and/or browser JavaScript console output
No errors thrown
Screenshots or screencasts of the bug in action
Empty intended div, checkbox appended to bottom of body
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Top GitHub Comments
At this point the next release will be bokeh 2.0 and we’ve already worked out a potential solution to fix the issue by that time so we likely won’t be adding the warning.
You are all working so fast @philippjfr . Take care.