danvk/dygraphs — pull request #276 by hulkholden (2013-09-27 07:57:44+00:00)
Title: Fix flaky testCustomBarsWithNegativeValuesInLogScale. 

CustomBars.testCustomBarsWithNegativeValuesInLogScale works fine the first time I start the jstd server, but subsequent runs give errors like this:

$ java -jar ./auto_tests/lib/JsTestDriver-1.3.3c.jar --tests all
......................................................................
......F...............................................................
......................................................................
....................................................
Total 262 tests (Passed: 261; Fails: 1; Errors: 0) (3730.00 ms)
Chrome 29.0.1547.76 Mac OS: Run 262 tests (Passed: 261; Fails: 1; Errors 0) (3730.00 ms)
custom-bars.testCustomBarsWithNegativeValuesInLogScale failed (28.00 ms): AssertError: expected 2 but was 3
Error: expected 2 but was 3
at CustomBarsTestCase.testCustomBarsWithNegativeValuesInLogScale (http://localhost:9876/test/auto_tests/tests/custom_bars.js:182:3)

It took a long time to track this down as the error seems to stem from a jit issue, and the problem stopped happening when stepping through the code in the debugger. Argh.

The problem is that after _calcYNormal has been run a number of times, calls with value=NaN start producing Infinity rather than NaN. For the custom bars tests, this means that _drawSeries then ends up including an extra point that's normally not rendered.

This is probably a bug in V8 but it's possible to work around the bug and make the code a bit more robust. I opted to check for Infinity in _calcYNormal but a slightly more targeted fix would be to update _drawSeries to check for finite point.canvasy and not just NaN. I'm not sure which approach you'd prefer.