@@ -158,6 +158,9 @@ function registerWebGLBackend() {
158158 tf . registerBackend ( 'rn-webgl' , async ( ) => {
159159 const glContext = await GLView . createContextAsync ( ) ;
160160
161+ // ExpoGl getBufferSubData is not implemented yet (throws an exception).
162+ tf . ENV . set ( 'WEBGL_BUFFER_SUPPORTED' , false ) ;
163+
161164 //
162165 // Mock extension support for EXT_color_buffer_float and
163166 // EXT_color_buffer_half_float on the expo-gl context object.
@@ -175,8 +178,7 @@ function registerWebGLBackend() {
175178 //
176179 //@ts -ignore
177180 const getExt = glContext . getExtension . bind ( glContext ) ;
178- // tslint:disable-next-line:only-arrow-functions
179- const shimGetExt = function ( name : string ) {
181+ const shimGetExt = ( name : string ) => {
180182 if ( name === 'EXT_color_buffer_float' ) {
181183 if ( RNPlatform . OS === 'ios' ) {
182184 // iOS does not support EXT_color_buffer_float
@@ -191,20 +193,29 @@ function registerWebGLBackend() {
191193 }
192194 return getExt ( name ) ;
193195 } ;
194- //@ts -ignore
196+
197+ //
198+ // Manually make 'read' synchronous. glContext has a defined gl.fenceSync
199+ // function that throws a "Not implemented yet" exception so core
200+ // cannot properly detect that it is not supported. We mock
201+ // implementations of gl.fenceSync and gl.clientWaitSync
202+ // TODO remove once fenceSync and clientWaitSync is implemented upstream.
203+ //
204+ const shimFenceSync = ( ) => {
205+ return { } ;
206+ } ;
207+ const shimClientWaitSync = ( ) => glContext . CONDITION_SATISFIED ;
208+
209+ // @ts -ignore
195210 glContext . getExtension = shimGetExt . bind ( glContext ) ;
211+ glContext . fenceSync = shimFenceSync . bind ( glContext ) ;
212+ glContext . clientWaitSync = shimClientWaitSync . bind ( glContext ) ;
196213
197214 // Set the WebGLContext before flag evaluation
198215 tf . webgl . setWebGLContext ( 2 , glContext ) ;
199216 const context = new tf . webgl . GPGPUContext ( ) ;
200217 const backend = new tf . webgl . MathBackendWebGL ( context ) ;
201- // Manually make 'read' synchronous. glContext has a defined gl.fenceSync
202- // function that throws a "Not implemented yet" exception so core
203- // cannot properly detect that it is not supported.
204- // TODO remove once fenceSync is implemented upstream.
205- backend . read = async ( dataId ) => {
206- return backend . readSync ( dataId ) ;
207- } ;
218+
208219 return backend ;
209220 } , PRIORITY ) ;
210221 } catch ( e ) {
0 commit comments