question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Layout engine much slower on Chrome

See original GitHub issue

When working with complex layouts the layout engine sometimes takes a considerable time to rerender because it has to measure the size of various components. For a long time I thought this was a general issue with the layout engine but it was just pointed out to me that this is much worse in Chrome.

In the contrived example below we have a reasonably complex layout of rows and columns and keep appending new rows with some text and plots.

from bokeh.layouts import Row, Column, Spacer
from bokeh.models.widgets import Div, Slider, Button
from bokeh.plotting import figure
from bokeh.io import curdoc

title = Div(text='<h1>Page title</h1>')

header = Row(children=[title, Spacer(sizing_mode='stretch_width'),
                       Div(text="Some link")],
             height=60, sizing_mode="stretch_width")

main = Column(sizing_mode='stretch_width')

def on_click(event):
    p = figure(sizing_mode='stretch_width')
    p.line([1, 2, 3], [1, 2, 3])
    row = Row(children=[Div(text="Some text") for i in range(10)]+[p],
              sizing_mode='stretch_width')
    main.children.append(row)

widgets = [Slider(start=0, end=10, title='Slider %d' % i) for i in range(10)]
button = Button(label='Click me')
button.on_click(on_click)
widgets.append(button)

nav = Column(children=widgets, width=200)

layout = Column(children=[header, Row(children=[nav, main])])

curdoc().add_root(layout)

The layout engine struggles the more items you add with the button presses in Chrome, while in Firefox it hardly slows down. Here are flame graphs generated by recording the performance in the two browsers.

Chrome

Screen Shot 2019-12-08 at 2 43 10 PM

Firefox

Screen Shot 2019-12-08 at 2 54 30 PM

You will note that it takes <2 seconds in Firefox and ~5 in Chrome. I’m not sure if this is just a Chrome performance issue but it would at least be good to investigate why it’s so much slower and if anything can be done to fix it.

Versions:

Bokeh 1.4.0 Chrome Version 78.0.3904.108 (Official Build) (64-bit) Firefox 70.0.1 (64-bit)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:27 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
xavArtleycommented, Dec 9, 2019

Hello don’t know if it helps but there it is performance on windows 10 chrome Version 78.0.3904.108 (Build officiel) (64 bits): image

Same test on firefox 60.0.1 (64-bit): image

image

Howver the difference seems mitigate when not using the debugger I made a rough test on 20 clicks an looking the scroll bar updating. It took me 27 seconds on chrome vs 23 seconds on firefox

1reaction
bryevdvcommented, Jan 30, 2020

I’m glad to hear of your successes @MarcSkovMadsen if you have some bandwidth in the next few months it would be really valuable to try and distill some small purposeful examples and documentation sections that could benefit all users.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google Chrome is Very Slow: How I Fixed it! (5+ Methods ...
Toggle “Use hardware acceleration when available” under Chrome > Settings > Advanced > System to check which mode is better, either OFF or...
Read more >
How to Fix Input Lag and Slow Performance in Google Chrome
There are several things that can cause poor Chrome performance and input lag. Regardless of your issue, a solution exists. Start with the ......
Read more >
Possible Chrome bug: Typing into input field is terribly slow if ...
Removing all the heavy CSS makes the typing much faster -- the layout are much shorter. It makes no sense that: the input...
Read more >
228948 - Rendering engine freezes after some time... - Monorail
My only current workaround is to kill the chrome process tree and then restore tabs, which seems to resolve things temporarily. I believe...
Read more >
1300848 - Much slower than Chrome in this React app
(Core :: JavaScript Engine, defect) ... In Chrome it's smooth. ... come from rendering the blur filters, but that's not the case -...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found