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

[2.7] Lost responsive after destroy recreate #4737

Closed
madmoizo opened this issue Sep 11, 2017 · 13 comments
Closed

[2.7] Lost responsive after destroy recreate #4737

madmoizo opened this issue Sep 11, 2017 · 13 comments
Assignees
Milestone

Comments

@madmoizo
Copy link

If some options have changed, I destroy the chart then create a new one.

if (chart) chart.destroy()
chart = new Chart(...)

Since 2.7, the div which handle resize detection is removed but is not re-created.
No problem with the iframe in 2.6

@simonbrunel
Copy link
Member

Duplicates #4630 but haven't been able to reproduce it. @frlinw can you share your project and/or build a jsfiddle that show this issue?

@madmoizo
Copy link
Author

madmoizo commented Sep 11, 2017

@simonbrunel your jsfiddle reproduce the issue perfectly
Initial :
image
After click on recreate :
image

@simonbrunel
Copy link
Member

The fiddle works for me in Firefox 55. What browser and version are you using to get this issue? any console errors / warnings?

@madmoizo
Copy link
Author

madmoizo commented Sep 11, 2017

You are right, it's ok on firefox. I'm using Chrome lastest (60)
Nothing in the console

@simonbrunel
Copy link
Member

I can reproduce it using Chrome, not sure what workaround you can use right now. I guess that you have good reason to re-create the chart everytime instead of calling chart.update() after modifying chart.options.

@madmoizo
Copy link
Author

madmoizo commented Sep 11, 2017

I already switched to chart.update() during the night so the issue is solved for me. Take your time to fix it ;)

@etimberg
Copy link
Member

@simonbrunel @frlinw I debugged through this a bit. Here's what I've got so far:

If I add a breakpoint to line 258 of platform.dom.js then everything works fine in Chrome. If I remove it, then this bug is observed.

In the case where no breakpoint is added, the callbacks on line 261 and 269 are never called.

Interestingly if I add a breakpoint in removeResizeListener and step through it then it also works as expected. My hunch is that something gets queued up to remove the old node and then somehow either prevents the new node from being added, or removes it immediately after it is added.

@daniele-orlando
Copy link

daniele-orlando commented Sep 18, 2017

Similar issue here. 2.7 is no more responsive.

@madmoizo
Copy link
Author

@etimberg just for curiosity, what if you put these lines in a setTimeout( ... , 0) ?

@simonbrunel simonbrunel self-assigned this Sep 18, 2017
@simonbrunel
Copy link
Member

On chart destroy, the chartjs-render-monitor class is removed from the canvas node, then, in your case, added back immediately on create. Chrome might decide to optimize the node class changes and prevent the animation to re-execute, so we are not notified on animationstart.

Could be solved by:

  • forcing a reflow before adding the class on create (or after removing the class on destroy)
  • detecting that the node is visible when creating the chart (and manually call handlers)

I will investigate the second solution first.

@frlinw I think the setTimeout will work since it will re-add the class at the next animation frame

@simonbrunel
Copy link
Member

@daniele-orlando @frlinw can you guys please verify that #4774 correctly fix this issue?

@andig
Copy link
Contributor

andig commented Sep 25, 2017

I already switched to chart.update() during the night so the issue is solved for me.

Same for me.

@mwaldstein
Copy link

I had a very similar issue with chrome not being responsive while it was in firefox - I thought that I had fixed it by moving to update() but it the issue returned.

Long story short, #4774 fixes the issue for me.

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

No branches or pull requests

6 participants