Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit 6e6bd19

Browse files
authored
[RN] Remove manual delegation of read to readSync
INTERNAL Remove manual delegation of read to readSync in react native platform
1 parent b727d80 commit 6e6bd19

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

karma.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const devConfig = {
3535
frameworks: ['jasmine', 'karma-typescript'],
3636
files: ['src/setup_test.ts', {pattern: 'src/**/*.ts'}],
3737
exclude: [
38+
'src/tests.ts',
3839
'src/worker_node_test.ts',
3940
'src/worker_test.ts',
4041
'src/test_node.ts',

tfjs-react-native/src/platform_react_native.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)