JS error in the filmstrip comparison

I noticed a parse error in some filmstrip comparison :
http://www.webpagetest.org/video/compare.php?tests=130426_26_0f6021dac87bc23dcd6d7eb3316b253a,130425_J5_63907774df282d4cc00be84ddfd195d7,130425_QY_3c04f76987498019f23ace34088ffdeb,130425_1H_68eecafadfbf266789c28112a1f12425,130425_W0_27e970ed1866bbf70da07abe8eb358d9

In this page, one of the test seems to have an empty value, so the JS generating the graphs is failing.

dataTimes.setValue(0, 0, 'Visually Complete'); dataTimes.setValue(0, 1, 7400); dataTimes.setValue(0, 2, 11000); dataTimes.setValue(0, 3, 13000); dataTimes.setValue(0, 4, 6600); dataTimes.setValue(0, 5, );

Here is a simple fix, in video/compare.php :

[php] foreach($timeMetrics as $metric => $label) {
echo “dataTimes.setValue($row, 0, ‘$label’);\n”;
$column = 1;
foreach($tests as &$test) {
$val = $test[‘pageData’][$test[‘run’]][$test[‘cached’]][$metric];
if(!empty($val))
echo ‘dataTimes.setValue(’.$row.’, ‘.$column.’, ‘. $val .’);’.PHP_EOL;
$column++;
}
$row++;
}
echo “dataRequests.setValue(0, 0, ‘Total’);\n”;
echo “dataBytes.setValue(0, 0, ‘Total’);\n”;
$column = 1;
foreach($tests as &$test) {
$val = $test[‘pageData’][$test[‘run’]][$test[‘cached’]][‘requests’];
if(!empty($val))
echo "dataRequests.setValue(0, $column, ".$val.’);’.PHP_EOL;
$val = $test[‘pageData’][$test[‘run’]][$test[‘cached’]][‘bytesIn’];
if(!empty($val))
echo "dataBytes.setValue(0, $column, ".$val.’);’.PHP_EOL;
$column++;
}
$row = 1;
foreach($mimeTypes as $mimeType) {
echo “dataRequests.setValue($row, 0, ‘$mimeType’);\n”;
echo “dataBytes.setValue($row, 0, ‘$mimeType’);\n”;
$column = 1;
foreach($tests as &$test) {
$val = $test[‘breakdown’][$mimeType][‘requests’];
if(!empty($val))
echo "dataRequests.setValue($row, $column, ".$val.’);’.PHP_EOL;
$val = $test[‘breakdown’][$mimeType][‘bytes’];
if(!empty($val))
echo "dataBytes.setValue($row, $column, ".$val.’);’.PHP_EOL;
$column++;
}
$row++;
}[/php]

A better fix would be to know why for some tests data is missing :slight_smile:

Excellent find, thank you. The sometimes-missing graphs has been on my list to look at for a while. Should be fixed now (well, patched - haven’t looked into the root cause yet).