File tree 1 file changed +30
-8
lines changed
1 file changed +30
-8
lines changed Original file line number Diff line number Diff line change @@ -91,8 +91,9 @@ function Scene(options, fullLayout) {
91
91
92
92
var proto = Scene . prototype ;
93
93
94
- proto . tryCreatePlot = function ( ) {
94
+ proto . prepareOptions = function ( ) {
95
95
var scene = this ;
96
+
96
97
var opts = {
97
98
canvas : scene . canvas ,
98
99
gl : scene . gl ,
@@ -132,20 +133,41 @@ proto.tryCreatePlot = function() {
132
133
opts . canvas = STATIC_CANVAS ;
133
134
}
134
135
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 ;
136
145
137
146
try {
138
147
scene . glplot = createPlot ( opts ) ;
139
148
} 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
+ try {
153
+ // invert preserveDrawingBuffer setup which could be resulted from is-mobile not detecting the right device
154
+ Lib . warn ( [
155
+ 'webgl setup failed possibly due to' ,
156
+ isMobile ? 'disabling' : 'enabling' ,
157
+ 'preserveDrawingBuffer config.' ,
158
+ 'The device may not be supported by isMobile module!' ,
159
+ 'Inverting preserveDrawingBuffer option in second attempt to create webgl scene.'
160
+ ] . join ( ' ' ) ) ;
161
+ isMobile = opts . glOptions . preserveDrawingBuffer = ! opts . glOptions . preserveDrawingBuffer ;
162
+
163
+ scene . glplot = createPlot ( opts ) ;
164
+ } catch ( e ) {
165
+ success = false ;
166
+ }
145
167
}
146
168
}
147
169
148
- return failed < 2 ;
170
+ return success ;
149
171
} ;
150
172
151
173
proto . initializeGLCamera = function ( ) {
You can’t perform that action at this time.
0 commit comments