From 83f1a36546784a14b3ae651ca766d7b8b806fa01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Tue, 24 Sep 2019 17:57:05 -0400 Subject: [PATCH] Add (large) upper bound on the number of redraw calls ... that Plots.doAutoMargin can trigger. (cherry picked from commit 631014a1688c4a495125c9774d8e8b438d995555) --- src/plots/plots.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plots/plots.js b/src/plots/plots.js index 24df7e286e2..b09fe8a55ea 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -1963,7 +1963,19 @@ plots.doAutoMargin = function(gd) { } else { fullLayout._redrawFromAutoMarginCount = 1; } - return Registry.call('plot', gd); + + // Always allow at least one redraw and give each margin-push + // call 3 loops to converge. Of course, for most cases this way too many, + // but let's keep things on the safe side until we fix our + // auto-margin pipeline problems: + // https://github.com/plotly/plotly.js/issues/2704 + var maxNumberOfRedraws = 3 * (1 + Object.keys(pushMarginIds).length); + + if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) { + return Registry.call('plot', gd); + } else { + Lib.warn('Too many auto-margin redraws.'); + } } };