@@ -78,19 +78,28 @@ var Main = function () {
7878 }
7979 } ,
8080
81- check_GL_enabled : function ( ) {
82- var testCanvas = document . createElement ( 'canvas' ) ;
83- if ( ! testCanvas . getContext ( "webgl2" ) && ! testCanvas . getContext ( "webgl" ) ) {
84- var elem = document . getElementById ( 'dragdrop' ) ;
85- elem . classList . add ( "error" ) ;
81+ init_ww : function ( canvas ) {
82+ let noww = ( window . location . hash == "#noww" ) ;
83+ if ( noww || typeof OffscreenCanvas === 'undefined' || typeof Worker === 'undefined' ) {
84+ return false ;
8685 }
86+ console . log ( "ww impl" ) ;
87+ var offscreen = canvas . transferControlToOffscreen ( ) ;
88+ _ww = new Worker ( 'send-worker.js' ) ;
89+ _ww . onmessage = Report . handleWorkerMessage ;
90+ _ww . onerror = function ( err ) {
91+ console . error ( '[send] Worker error: ' , err ) ;
92+ } ;
93+ _ww . postMessage ( { fun : 'init_window' , args : [ offscreen ] } , [ offscreen ] ) ;
94+ return true ;
8795 } ,
8896
8997 on_ww_init : function ( force_local ) {
9098 console . log ( 'on ww init ' + force_local ) ;
9199
92100 if ( force_local ) {
93101 _ww = undefined ;
102+ // force refresh in main thread mode
94103 window . location . hash = "#noww" ;
95104 window . location . reload ( ) ;
96105 return ;
@@ -100,21 +109,13 @@ var Main = function () {
100109 _ww . postMessage ( { fun : 'nextFrame' , args : [ ] } ) ;
101110 } ,
102111
103- init_ww : function ( canvas ) {
104- let noww = ( window . location . hash == "#noww" ) ;
105- if ( noww || typeof OffscreenCanvas === 'undefined' || typeof Worker === 'undefined' ) {
106- return false ;
112+
113+ check_GL_enabled : function ( ) {
114+ var testCanvas = document . createElement ( 'canvas' ) ;
115+ if ( ! testCanvas . getContext ( "webgl2" ) && ! testCanvas . getContext ( "webgl" ) ) {
116+ var elem = document . getElementById ( 'dragdrop' ) ;
117+ elem . classList . add ( "error" ) ;
107118 }
108- console . log ( "ww impl" ) ;
109- // TODO: clone canvas maybe?
110- var offscreen = canvas . transferControlToOffscreen ( ) ;
111- _ww = new Worker ( 'send-worker.js' ) ;
112- _ww . onmessage = Report . handleWorkerMessage ;
113- _ww . onerror = function ( err ) {
114- console . error ( '[send] Worker error: ' , err ) ;
115- } ;
116- _ww . postMessage ( { fun : 'init_window' , args : [ offscreen ] } , [ offscreen ] ) ;
117- return true ;
118119 } ,
119120
120121 resize : function ( ) {
0 commit comments