Skip to content

Commit 94e98d7

Browse files
committed
invert is-mobile once at init time and revert is-mobile with no success
1 parent dfd122b commit 94e98d7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/plots/gl3d/scene.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ proto.prepareOptions = function() {
136136
return opts;
137137
};
138138

139+
var firstInit = true;
140+
139141
proto.tryCreatePlot = function() {
140142
var scene = this;
141143

@@ -146,7 +148,7 @@ proto.tryCreatePlot = function() {
146148
try {
147149
scene.glplot = createPlot(opts);
148150
} catch(e) {
149-
if(scene.staticMode) {
151+
if(scene.staticMode || !firstInit) {
150152
success = false;
151153
} else { // try second time
152154
try {
@@ -158,15 +160,22 @@ proto.tryCreatePlot = function() {
158160
'The device may not be supported by is-mobile module!',
159161
'Inverting preserveDrawingBuffer option in second attempt to create webgl scene.'
160162
].join(' '));
163+
164+
// invert is-mobile
161165
isMobile = opts.glOptions.preserveDrawingBuffer = !opts.glOptions.preserveDrawingBuffer;
162166

163167
scene.glplot = createPlot(opts);
164168
} catch(e) {
169+
// revert changes to is-mobile
170+
isMobile = opts.glOptions.preserveDrawingBuffer = !opts.glOptions.preserveDrawingBuffer;
171+
165172
success = false;
166173
}
167174
}
168175
}
169176

177+
firstInit = false;
178+
170179
return success;
171180
};
172181

0 commit comments

Comments
 (0)