c3js / c3

:bar_chart: A D3-based reusable chart library
http://c3js.org
MIT License
9.33k stars 1.39k forks source link

[Violation] 'focus' handler took XXX ms #2742

Open viseth opened 4 years ago

viseth commented 4 years ago

Hi, Thanks for this amazing lib !

The console log of Chrome is cluttered with verbose message of this type: [Violation] 'focus' handler took 519ms c3.js:2311 Which makes the navigation on the page very bad. The clicks responsiveness is totally bad at some point.

Here's a little JSFiddle 👍 https://jsfiddle.net/Viseth7/ad19b7s6/8/

  1. open the console.log
  2. click on the icon at the top left corner
  3. move the subchart aera back and forth and navigate to another tab of your browser

=> message log verbose appear and the navigation experience goes bad.

All messages point to the same line of code " this.windowFocusHandler = function ()" :

` ChartInternal.prototype.bindWindowFocus = function () { var _this = this;

if (this.windowFocusHandler) {
  // The handler is already set
  return;
}

this.windowFocusHandler = function () {
  _this.redraw();
};

//window.addEventListener('focus', this.windowFocusHandler)
//custom
window.addEventListener('focus', this.windowFocusHandler, { capture: true, passive: true });

}; `

Please below is the console log screeshot.

image

I don't know whether this has to do with uikit-3.2.7 that I used in this project.

Does anyone else experience the same ? Any hints and idea ?

seanpoulter commented 4 years ago

We've been experiencing a very similar issue. We have about 30 charts on the page which locks up the UI quite a bit.

Maintainers, would you welcome a PR to allow the user to override the windowFocusHandler?I'd expect the workaround would be to override ChartInternal.prototype.windowFocusHandler.

jteppinette commented 3 years ago

I am currently detaching the window focus handler, because switching tabs causes the entire page to go blank for ~10 seconds.

chadnaylor commented 2 years ago

Any resolution on this?

seanpoulter commented 2 years ago

It has been a long time since I've looked at this. @jteppinette, did you have anything to share with @chadnaylor to detach the listener? I'm not optimistic we'd be able to get a PR through. 😓