Skip to content

Commit 6929a02

Browse files
committed
correct config for device in the second create 3-D scene try
1 parent 225c97e commit 6929a02

File tree

1 file changed

+26
-8
lines changed

1 file changed

+26
-8
lines changed

src/plots/gl3d/scene.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ function Scene(options, fullLayout) {
9191

9292
var proto = Scene.prototype;
9393

94-
proto.tryCreatePlot = function() {
94+
proto.prepareOptions = function() {
9595
var scene = this;
96+
9697
var opts = {
9798
canvas: scene.canvas,
9899
gl: scene.gl,
@@ -132,20 +133,37 @@ proto.tryCreatePlot = function() {
132133
opts.canvas = STATIC_CANVAS;
133134
}
134135

135-
var failed = 0;
136+
return opts;
137+
};
138+
139+
proto.tryCreatePlot = function() {
140+
var scene = this;
141+
142+
var opts = scene.prepareOptions();
143+
144+
var success = true;
136145

137146
try {
138147
scene.glplot = createPlot(opts);
139148
} catch(e) {
140-
failed++;
141-
try { // try second time to fix issue with Chrome 77 https://github.com/plotly/plotly.js/issues/4233
142-
scene.glplot = createPlot(opts);
143-
} catch(e) {
144-
failed++;
149+
if(scene.staticMode) {
150+
success = false;
151+
} else { // try second time
152+
// make fresh object for options
153+
opts = scene.prepareOptions();
154+
155+
try {
156+
// invert preserveDrawingBuffer setup which could be resulted from is-mobile not detecting the right device
157+
opts.glOptions.preserveDrawingBuffer = !opts.glOptions.preserveDrawingBuffer;
158+
159+
scene.glplot = createPlot(opts);
160+
} catch(e) {
161+
success = false;
162+
}
145163
}
146164
}
147165

148-
return failed < 2;
166+
return success;
149167
};
150168

151169
proto.initializeGLCamera = function() {

0 commit comments

Comments
 (0)