FVANCOP / ChartNew.js

MIT License
420 stars 142 forks source link

Stopped working in Safari (no code changes but data did change) but still works pefectly in Chrome with the same data #386

Closed bbhdev closed 8 years ago

bbhdev commented 8 years ago

The code for this process has not changed in months; OTOH, the data changes often. Pie charts are built on the fly. This worked perfectly for months on all the browsers that I had tested. But now Safari hangs in the middle of building pie charts, while in Chrome everything is perfect. I can only assume that the new data is at the root of the problem; but of course data should never be able to break code.

Unfortunately although I use JS, I'm not familiar enough with it to trace the code of ChartNew at this level of detail. I have attached a screenshot (labels removed for clarity) showing all pie charts stopped in the middle. Safari is frozen and the tab needs to be closed.

Anything I can do to help clarify this and/or do any specific tests, just say the word. I would really like to clear this up, I like ChartNew too much to accept replacing it by something else :-)

screenshot 2015-11-11 17 19 51 .

FVANCOP commented 8 years ago

Hi,

Unfortunately, I do not have a Mac to test it in Safari (I suppose that you test it on a Mac).

Perhaps that the problems occurs because of an upgrade of the Safari browser and perhaps it is a bug of the Safari Browser.

Can you (or someone else) perform a debugging of the problem ?

Thanks, François

bbhdev commented 8 years ago

Yes you are right, a Mac, I have been using Macs since '84 :-)

Some more info...

I have been making tests while massaging the data. I remember an early problem which was hard to analyze and was data-related : if there was a single class with non-zero value, the lib would hang; but not if the value was zero and not if there was more than one class. Once found, this was easy to work around of course. BTW I reported it at the time but honestly this was an outlier case not worth much effort. So anyway, now I have done a number of tests with modified data.

The results are surprising to me. I have found which of the five pies freezes; and then I have found data combinations which freeze, and others which don't. Maybe if I give you this info, you can point me to some specific part of the JS which I will then try to debug. I would have a hard time tracing everything, but may have a fighting chance if I can target a more limited part of the code.

Here goes. I will just use short pseudo code for data arrays, [ 'data_label' : data_value {,...} ].

(A) This works correctly: [ 'a' : 2, 'b' : 2, 'c' : 2, 'd' : 2 ]

(B) This freezes, the two first values and the second label are changed: [ 'a' : 10, 'xxxxxxxxxxxx' : 0, 'c' : 2, 'd' : 2 ]

(C) BUT this works, please note the value 2 which replaces the 10: [ 'a' : 2, 'xxxxxxxxxxxx' : 0, 'c' : 2, 'd' : 2 ]

(D) AND this works too, the value 10 is back but the second label is short: [ 'a' : 10, 'b' : 0, 'c' : 2, 'd' : 2 ]

(E) This works ! it's like (B) but the second value is 2 instead of 0 : [ 'a' : 10, 'xxxxxxxxxxxx' : 2, 'c' : 2, 'd' : 2 ]

I have wondered if some positioning calculation is behind this, which has to be dependent on element sizes, which themselves depend on the number of value digits and label chars.

Well... any ideas ?

Thanks!

bbhdev commented 8 years ago

Oh BTW, if I change the number of values in the array, that can have an effect too. I wanted to simplify so did not detail that.

FVANCOP commented 8 years ago

Two things, that you can try :

bbhdev commented 8 years ago

You got it !

I had the standard 30 steps => reduced it to 5, no more freeze. Same with anims off; it was nearly obvious but I tried anyway and yes, no freeze when no anims. Many thanks, I'm very glad.

So... it isn't some positioning calculation but the animation steps calculation. But appears only in some JS implementations, obviously. AFAIK the Safari JS engine is recent and compliant.

If you think it's worth researching (who knows how, when and where it may resurface), I am very willing to help by doing on my config any tests you devise.

FVANCOP commented 8 years ago

@bbhdev : Because I do not have a Mac to test it, I need your help to solve this problem. But talking through this issue, will generate lot of mails for poeple not interested in it. Can you take contact with me by mail (you will find my email address in the source code) ?

Thanks, François