File tree Expand file tree Collapse file tree 1 file changed +30
-8
lines changed Expand file tree Collapse file tree 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) {
9191
9292var 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,41 @@ 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+ 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+ }
145167 }
146168 }
147169
148- return failed < 2 ;
170+ return success ;
149171} ;
150172
151173proto . initializeGLCamera = function ( ) {
You can’t perform that action at this time.
0 commit comments