Skip to content

Commit 85a646f

Browse files
committed
avoid potential infinite loop when replotting due to wrong gl dims
1 parent e3d947e commit 85a646f

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/plot_api/plot_api.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -243,21 +243,22 @@ exports.plot = function(gd, data, layout, config) {
243243
.attr('width', fullLayout.width)
244244
.attr('height', fullLayout.height);
245245

246-
247246
var regl = fullLayout._glcanvas.data()[0].regl;
248247
if(regl) {
249-
if(
250-
fullLayout.width !== regl._gl.drawingBufferWidth ||
248+
// Unfortunately, this can happen when relayouting to large
249+
// width/height on some browsers.
250+
if(fullLayout.width !== regl._gl.drawingBufferWidth ||
251251
fullLayout.height !== regl._gl.drawingBufferHeight
252252
) {
253-
// Unfortunately, this can happen when relayouting to large
254-
// width/height on some browsers.
255-
Lib.log([
256-
'WebGL context buffer and canvas dimensions do not match,',
257-
'due to browser/WebGL bug.',
258-
'Clearing graph and plotting again.'
259-
].join(' '));
260-
exports.newPlot(gd, gd.data, gd.layout);
253+
var msg = 'WebGL context buffer and canvas dimensions do not match due to browser/WebGL bug.';
254+
if(fullLayout._redrawFromWrongGlDimensions) {
255+
Lib.error(msg);
256+
} else {
257+
Lib.log(msg + ' Clearing graph and plotting again.');
258+
fullLayout._redrawFromWrongGlDimensions = 1;
259+
Plots.cleanPlot([], {}, gd._fullData, fullLayout, gd.calcdata);
260+
exports.plot(gd, gd.data, gd.layout);
261+
}
261262
}
262263
}
263264
}

test/jasmine/tests/splom_test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -697,20 +697,22 @@ describe('Test splom interactions:', function() {
697697
expect(gl.drawingBufferHeight).toBe(h, msg);
698698
}
699699

700-
spyOn(plotApi, 'newPlot').and.callThrough();
700+
spyOn(plotApi, 'plot').and.callThrough();
701701
spyOn(Lib, 'log');
702702

703703
Plotly.plot(gd, fig).then(function() {
704-
expect(plotApi.newPlot).toHaveBeenCalledTimes(0);
704+
expect(plotApi.plot).toHaveBeenCalledTimes(0);
705705
expect(Lib.log).toHaveBeenCalledTimes(0);
706+
expect(gd._fullLayout._redrawFromWrongGlDimensions).toBeUndefined();
706707
assertDims('base', 600, 500);
707708

708709
return Plotly.relayout(gd, {width: 4810, height: 3656});
709710
})
710711
.then(function() {
711-
expect(plotApi.newPlot).toHaveBeenCalledTimes(1);
712+
expect(plotApi.plot).toHaveBeenCalledTimes(1);
712713
expect(Lib.log)
713-
.toHaveBeenCalledWith('WebGL context buffer and canvas dimensions do not match, due to browser/WebGL bug. Clearing graph and plotting again.');
714+
.toHaveBeenCalledWith('WebGL context buffer and canvas dimensions do not match due to browser/WebGL bug. Clearing graph and plotting again.');
715+
expect(gd._fullLayout._redrawFromWrongGlDimensions).toBe(1);
714716
assertDims('base', 4810, 3656);
715717
})
716718
.catch(failTest)

0 commit comments

Comments
 (0)