expo-gl 11.2.1 → 11.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +7 -0
- package/android/build.gradle +2 -2
- package/build/GLView.d.ts.map +1 -1
- package/build/GLView.js +2 -16
- package/build/GLView.js.map +1 -1
- package/build/GLWorkletContextProvider.d.ts +3 -0
- package/build/GLWorkletContextProvider.d.ts.map +1 -0
- package/build/GLWorkletContextProvider.js +25 -0
- package/build/GLWorkletContextProvider.js.map +1 -0
- package/ios/EXGL/EXGLContext.mm +31 -0
- package/ios/EXGL.xcframework/ios-arm64/EXGL.framework/EXGL +0 -0
- package/ios/EXGL.xcframework/ios-arm64/EXGL.framework/Info.plist +0 -0
- package/ios/EXGL.xcframework/ios-arm64_x86_64-simulator/EXGL.framework/EXGL +0 -0
- package/ios/EXGL.xcframework/ios-arm64_x86_64-simulator/EXGL.framework/Info.plist +0 -0
- package/package.json +4 -4
- package/src/GLView.tsx +2 -15
- package/src/GLWorkletContextProvider.ts +25 -0
- package/src/ts-declarations/lib.dom.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,25 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 11.4.0 — 2022-07-07
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Stop rendering when app is backgrounded on iOS. ([#17463](https://github.com/expo/expo/pull/17463) by [@wkozyra95](https://github.com/wkozyra95))
|
|
18
|
+
- Added support for React Native 0.69.x. ([#18006](https://github.com/expo/expo/pull/18006) by [@kudo](https://github.com/kudo))
|
|
19
|
+
|
|
20
|
+
## 11.3.0 — 2022-04-27
|
|
21
|
+
|
|
22
|
+
### 🐛 Bug fixes
|
|
23
|
+
|
|
24
|
+
- Fix crash on android 11 by packaging worklet `jsi:Runtime*` inside ArrayBuffer. ([#17194](https://github.com/expo/expo/pull/17194) by [@wkozyra95](https://github.com/wkozyra95))
|
|
25
|
+
|
|
26
|
+
## 11.2.2 — 2022-04-21
|
|
27
|
+
|
|
28
|
+
### 🐛 Bug fixes
|
|
29
|
+
|
|
30
|
+
- Fix import errors when option `inlineRequires` is enabled in `metro.config.js`. ([#17141](https://github.com/expo/expo/pull/17141) by [@wkozyra95](https://github.com/wkozyra95))
|
|
31
|
+
|
|
13
32
|
## 11.2.1 — 2022-04-20
|
|
14
33
|
|
|
15
34
|
_This version does not introduce any user-facing changes._
|
package/README.md
CHANGED
|
@@ -35,6 +35,13 @@ To use version `11.2.0` or newer of `expo-gl` you will need to use at least vers
|
|
|
35
35
|
| >=9.0.0 && <11.2.0 | >=0.63.1 && <0.65.0 |
|
|
36
36
|
| >=11.2.0 | >=0.68.0 |
|
|
37
37
|
|
|
38
|
+
To use reanimated worklets you will need compatible version of `react-native-reanimated`.
|
|
39
|
+
|
|
40
|
+
| expo-gl | react-native-reanimated |
|
|
41
|
+
| ------------------ | ----------------------- |
|
|
42
|
+
| <11.3.0 | <=2.8.0 |
|
|
43
|
+
| >=11.3.0 | >2.8.0 |
|
|
44
|
+
|
|
38
45
|
### Configure for iOS
|
|
39
46
|
|
|
40
47
|
Run `npx pod-install` after installing the npm package.
|
package/android/build.gradle
CHANGED
|
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
|
|
|
3
3
|
apply plugin: 'maven-publish'
|
|
4
4
|
|
|
5
5
|
group = 'host.exp.exponent'
|
|
6
|
-
version = '11.
|
|
6
|
+
version = '11.4.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -74,7 +74,7 @@ android {
|
|
|
74
74
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
75
75
|
targetSdkVersion safeExtGet("targetSdkVersion", 31)
|
|
76
76
|
versionCode 31
|
|
77
|
-
versionName "11.
|
|
77
|
+
versionName "11.4.0"
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
sourceSets.main {
|
package/build/GLView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.d.ts","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,eAAe,EAChB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"GLView.d.ts","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;CACZ;AAMD,oBAAY,WAAW,GAAG;IACxB;;;OAGG;IACH,eAAe,CAAC,EAAE,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAErD;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,sBAAsB,CAAC,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,OAAE;CAC7D,GAAG,eAAe,CAAC;AAIpB;;GAEG;AACH,qBAAa,MAAO,SAAQ,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC;IACtD,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IAEvB,MAAM,CAAC,YAAY;;MAEjB;WAEW,kBAAkB,IAAI,OAAO,CAAC,yBAAyB,CAAC;WAKxD,mBAAmB,CAAC,IAAI,CAAC,EAAE,yBAAyB,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAKhF,iBAAiB,CAC5B,IAAI,CAAC,EAAE,yBAAyB,GAAG,MAAM,EACzC,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,UAAU,CAAC;IAKtB,MAAM,CAAC,iBAAiB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,yBAAyB,GAAG,SAAS,CACrD;IAEjC,SAAS,EAAE,iBAAiB,CAAQ;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,MAAM;IA0BN,aAAa,cAAe,iBAAiB,KAAG,IAAI,CAKlD;IAEF,gBAAgB,mCAAoC,kBAAkB,KAAG,IAAI,CAQ3E;IAEI,mBAAmB,IAAI,OAAO,CAAC,GAAG,CAAC;IAOnC,wBAAwB,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IAmBrF,kBAAkB,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAO3D,iBAAiB,CAAC,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,UAAU,CAAC;CAO5E"}
|
package/build/GLView.js
CHANGED
|
@@ -2,6 +2,7 @@ import { NativeModulesProxy, UnavailabilityError, requireNativeViewManager, Code
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { Platform, View, findNodeHandle } from 'react-native';
|
|
4
4
|
import { configureLogging } from './GLUtils';
|
|
5
|
+
import { createWorkletContextProvider } from './GLWorkletContextProvider';
|
|
5
6
|
const { ExponentGLObjectManager, ExponentGLViewManager } = NativeModulesProxy;
|
|
6
7
|
const NativeView = requireNativeViewManager('ExponentGLView');
|
|
7
8
|
/**
|
|
@@ -24,22 +25,7 @@ export class GLView extends React.Component {
|
|
|
24
25
|
const exglCtxId = getContextId(exgl);
|
|
25
26
|
return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);
|
|
26
27
|
}
|
|
27
|
-
static getWorkletContext = (
|
|
28
|
-
try {
|
|
29
|
-
// reanimated needs to be imported before any workletized code
|
|
30
|
-
// is created, but we don't want to make it dependency on expo-gl.
|
|
31
|
-
require('react-native-reanimated');
|
|
32
|
-
return (contextId) => {
|
|
33
|
-
'worklet';
|
|
34
|
-
return global.__EXGLContexts?.[String(contextId)];
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
38
|
-
return () => {
|
|
39
|
-
throw new Error('Worklet runtime is not available');
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
})();
|
|
28
|
+
static getWorkletContext = createWorkletContextProvider();
|
|
43
29
|
nativeRef = null;
|
|
44
30
|
exglCtxId;
|
|
45
31
|
render() {
|
package/build/GLView.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GLView.js","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,GACX,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAgB7C,MAAM,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,GAAG,kBAAkB,CAAC;AAoB9E,MAAM,UAAU,GAAG,wBAAwB,CAAC,gBAAgB,CAAC,CAAC;AAE9D;;GAEG;AACH,MAAM,OAAO,MAAO,SAAQ,KAAK,CAAC,SAAsB;IACtD,MAAM,CAAC,UAAU,CAAM;IAEvB,MAAM,CAAC,YAAY,GAAG;QACpB,WAAW,EAAE,CAAC;KACf,CAAC;IAEF,MAAM,CAAC,KAAK,CAAC,kBAAkB;QAC7B,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,uBAAuB,CAAC,kBAAkB,EAAE,CAAC;QACzE,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IA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K,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import {\n NativeModulesProxy,\n UnavailabilityError,\n requireNativeViewManager,\n CodedError,\n} from 'expo-modules-core';\nimport * as React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { configureLogging } from './GLUtils';\nimport {\n ComponentOrHandle,\n SurfaceCreateEvent,\n GLSnapshot,\n ExpoWebGLRenderingContext,\n SnapshotOptions,\n BaseGLViewProps,\n} from './GLView.types';\n\nexport interface WebGLObject {\n id: number;\n}\n\ndeclare let global: any;\n\nconst { ExponentGLObjectManager, ExponentGLViewManager } = NativeModulesProxy;\n\nexport type GLViewProps = {\n /**\n * Called when the OpenGL context is created, with the context object as a parameter. The context\n * object has an API mirroring WebGL's WebGLRenderingContext.\n */\n onContextCreate(gl: ExpoWebGLRenderingContext): void;\n\n /**\n * [iOS only] Number of samples for Apple's built-in multisampling.\n */\n msaaSamples: number;\n\n /**\n * A ref callback for the native GLView\n */\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null);\n} & BaseGLViewProps;\n\nconst NativeView = requireNativeViewManager('ExponentGLView');\n\n/**\n * A component that acts as an OpenGL render target\n */\nexport class GLView extends React.Component<GLViewProps> {\n static NativeView: any;\n\n static defaultProps = {\n msaaSamples: 4,\n };\n\n static async createContextAsync(): Promise<ExpoWebGLRenderingContext> {\n const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();\n return getGl(exglCtxId);\n }\n\n static async destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.destroyContextAsync(exglCtxId);\n }\n\n static async takeSnapshotAsync(\n exgl?: ExpoWebGLRenderingContext | number,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);\n }\n\n static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =\n (function () {\n try {\n // reanimated needs to be imported before any workletized code\n // is created, but we don't want to make it dependency on expo-gl.\n require('react-native-reanimated');\n return (contextId: number): ExpoWebGLRenderingContext | undefined => {\n 'worklet';\n return global.__EXGLContexts?.[String(contextId)];\n };\n } catch {\n return () => {\n throw new Error('Worklet runtime is not available');\n };\n }\n })();\n\n nativeRef: ComponentOrHandle = null;\n exglCtxId?: number;\n\n render() {\n const {\n onContextCreate, // eslint-disable-line no-unused-vars\n msaaSamples,\n ...viewProps\n } = this.props;\n\n return (\n <View {...viewProps}>\n <NativeView\n ref={this._setNativeRef}\n style={{\n flex: 1,\n ...(Platform.OS === 'ios'\n ? {\n backgroundColor: 'transparent',\n }\n : {}),\n }}\n onSurfaceCreate={this._onSurfaceCreate}\n msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}\n />\n </View>\n );\n }\n\n _setNativeRef = (nativeRef: ComponentOrHandle): void => {\n if (this.props.nativeRef_EXPERIMENTAL) {\n this.props.nativeRef_EXPERIMENTAL(nativeRef);\n }\n this.nativeRef = nativeRef;\n };\n\n _onSurfaceCreate = ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent): void => {\n const gl = getGl(exglCtxId);\n\n this.exglCtxId = exglCtxId;\n\n if (this.props.onContextCreate) {\n this.props.onContextCreate(gl);\n }\n };\n\n async startARSessionAsync(): Promise<any> {\n if (!ExponentGLViewManager.startARSessionAsync) {\n throw new UnavailabilityError('expo-gl', 'startARSessionAsync');\n }\n return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));\n }\n\n async createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture> {\n if (!ExponentGLObjectManager.createCameraTextureAsync) {\n throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');\n }\n\n const { exglCtxId } = this;\n\n if (!exglCtxId) {\n throw new Error(\"GLView's surface is not created yet!\");\n }\n\n const cameraTag = findNodeHandle(cameraRefOrHandle);\n const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(\n exglCtxId,\n cameraTag\n );\n return { id: exglObjId } as WebGLTexture;\n }\n\n async destroyObjectAsync(glObject: WebGLObject): Promise<boolean> {\n if (!ExponentGLObjectManager.destroyObjectAsync) {\n throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');\n }\n return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);\n }\n\n async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n const { exglCtxId } = this;\n return await GLView.takeSnapshotAsync(exglCtxId, options);\n }\n}\n\nGLView.NativeView = NativeView;\n\n// Get the GL interface from an EXGLContextId\nconst getGl = (exglCtxId: number): ExpoWebGLRenderingContext => {\n if (!global.__EXGLContexts) {\n throw new CodedError(\n 'ERR_GL_NOT_AVAILABLE',\n 'GL is currently not available. (Have you enabled remote debugging? GL is not available while debugging remotely.)'\n );\n }\n const gl = global.__EXGLContexts[String(exglCtxId)];\n\n configureLogging(gl);\n\n return gl;\n};\n\nconst getContextId = (exgl?: ExpoWebGLRenderingContext | number): number => {\n const exglCtxId = exgl && typeof exgl === 'object' ? exgl.contextId : exgl;\n\n if (!exglCtxId || typeof exglCtxId !== 'number') {\n throw new Error(`Invalid EXGLContext id: ${String(exglCtxId)}`);\n }\n return exglCtxId;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"GLView.js","sourceRoot":"","sources":["../src/GLView.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,UAAU,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AAiB,EAA6B,EAAE;IAC7D,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,UAAU,CAClB,sBAAsB,EACtB,mHAAmH,CACpH,CAAC;KACH;IACD,MAAM,EAAE,GAAG,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAEpD,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAErB,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAyC,EAAU,EAAE;IACzE,MAAM,SAAS,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3E,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;QAC/C,MAAM,IAAI,KAAK,CAAC,2BAA2B,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;KACjE;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import {\n NativeModulesProxy,\n UnavailabilityError,\n requireNativeViewManager,\n CodedError,\n} from 'expo-modules-core';\nimport * as React from 'react';\nimport { Platform, View, findNodeHandle } from 'react-native';\n\nimport { configureLogging } from './GLUtils';\nimport {\n ComponentOrHandle,\n SurfaceCreateEvent,\n GLSnapshot,\n ExpoWebGLRenderingContext,\n SnapshotOptions,\n BaseGLViewProps,\n} from './GLView.types';\nimport { createWorkletContextProvider } from './GLWorkletContextProvider';\n\nexport interface WebGLObject {\n id: number;\n}\n\ndeclare let global: any;\n\nconst { ExponentGLObjectManager, ExponentGLViewManager } = NativeModulesProxy;\n\nexport type GLViewProps = {\n /**\n * Called when the OpenGL context is created, with the context object as a parameter. The context\n * object has an API mirroring WebGL's WebGLRenderingContext.\n */\n onContextCreate(gl: ExpoWebGLRenderingContext): void;\n\n /**\n * [iOS only] Number of samples for Apple's built-in multisampling.\n */\n msaaSamples: number;\n\n /**\n * A ref callback for the native GLView\n */\n nativeRef_EXPERIMENTAL?(callback: ComponentOrHandle | null);\n} & BaseGLViewProps;\n\nconst NativeView = requireNativeViewManager('ExponentGLView');\n\n/**\n * A component that acts as an OpenGL render target\n */\nexport class GLView extends React.Component<GLViewProps> {\n static NativeView: any;\n\n static defaultProps = {\n msaaSamples: 4,\n };\n\n static async createContextAsync(): Promise<ExpoWebGLRenderingContext> {\n const { exglCtxId } = await ExponentGLObjectManager.createContextAsync();\n return getGl(exglCtxId);\n }\n\n static async destroyContextAsync(exgl?: ExpoWebGLRenderingContext | number): Promise<boolean> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.destroyContextAsync(exglCtxId);\n }\n\n static async takeSnapshotAsync(\n exgl?: ExpoWebGLRenderingContext | number,\n options: SnapshotOptions = {}\n ): Promise<GLSnapshot> {\n const exglCtxId = getContextId(exgl);\n return ExponentGLObjectManager.takeSnapshotAsync(exglCtxId, options);\n }\n\n static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =\n createWorkletContextProvider();\n\n nativeRef: ComponentOrHandle = null;\n exglCtxId?: number;\n\n render() {\n const {\n onContextCreate, // eslint-disable-line no-unused-vars\n msaaSamples,\n ...viewProps\n } = this.props;\n\n return (\n <View {...viewProps}>\n <NativeView\n ref={this._setNativeRef}\n style={{\n flex: 1,\n ...(Platform.OS === 'ios'\n ? {\n backgroundColor: 'transparent',\n }\n : {}),\n }}\n onSurfaceCreate={this._onSurfaceCreate}\n msaaSamples={Platform.OS === 'ios' ? msaaSamples : undefined}\n />\n </View>\n );\n }\n\n _setNativeRef = (nativeRef: ComponentOrHandle): void => {\n if (this.props.nativeRef_EXPERIMENTAL) {\n this.props.nativeRef_EXPERIMENTAL(nativeRef);\n }\n this.nativeRef = nativeRef;\n };\n\n _onSurfaceCreate = ({ nativeEvent: { exglCtxId } }: SurfaceCreateEvent): void => {\n const gl = getGl(exglCtxId);\n\n this.exglCtxId = exglCtxId;\n\n if (this.props.onContextCreate) {\n this.props.onContextCreate(gl);\n }\n };\n\n async startARSessionAsync(): Promise<any> {\n if (!ExponentGLViewManager.startARSessionAsync) {\n throw new UnavailabilityError('expo-gl', 'startARSessionAsync');\n }\n return await ExponentGLViewManager.startARSessionAsync(findNodeHandle(this.nativeRef));\n }\n\n async createCameraTextureAsync(cameraRefOrHandle: ComponentOrHandle): Promise<WebGLTexture> {\n if (!ExponentGLObjectManager.createCameraTextureAsync) {\n throw new UnavailabilityError('expo-gl', 'createCameraTextureAsync');\n }\n\n const { exglCtxId } = this;\n\n if (!exglCtxId) {\n throw new Error(\"GLView's surface is not created yet!\");\n }\n\n const cameraTag = findNodeHandle(cameraRefOrHandle);\n const { exglObjId } = await ExponentGLObjectManager.createCameraTextureAsync(\n exglCtxId,\n cameraTag\n );\n return { id: exglObjId } as WebGLTexture;\n }\n\n async destroyObjectAsync(glObject: WebGLObject): Promise<boolean> {\n if (!ExponentGLObjectManager.destroyObjectAsync) {\n throw new UnavailabilityError('expo-gl', 'destroyObjectAsync');\n }\n return await ExponentGLObjectManager.destroyObjectAsync(glObject.id);\n }\n\n async takeSnapshotAsync(options: SnapshotOptions = {}): Promise<GLSnapshot> {\n if (!GLView.takeSnapshotAsync) {\n throw new UnavailabilityError('expo-gl', 'takeSnapshotAsync');\n }\n const { exglCtxId } = this;\n return await GLView.takeSnapshotAsync(exglCtxId, options);\n }\n}\n\nGLView.NativeView = NativeView;\n\n// Get the GL interface from an EXGLContextId\nconst getGl = (exglCtxId: number): ExpoWebGLRenderingContext => {\n if (!global.__EXGLContexts) {\n throw new CodedError(\n 'ERR_GL_NOT_AVAILABLE',\n 'GL is currently not available. (Have you enabled remote debugging? GL is not available while debugging remotely.)'\n );\n }\n const gl = global.__EXGLContexts[String(exglCtxId)];\n\n configureLogging(gl);\n\n return gl;\n};\n\nconst getContextId = (exgl?: ExpoWebGLRenderingContext | number): number => {\n const exglCtxId = exgl && typeof exgl === 'object' ? exgl.contextId : exgl;\n\n if (!exglCtxId || typeof exglCtxId !== 'number') {\n throw new Error(`Invalid EXGLContext id: ${String(exglCtxId)}`);\n }\n return exglCtxId;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GLWorkletContextProvider.d.ts","sourceRoot":"","sources":["../src/GLWorkletContextProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAU3D,wBAAgB,4BAA4B,gBAKrB,MAAM,KAAG,yBAAyB,GAAG,SAAS,CASpE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// This method needs to be in a separate file because react-native-reanimated
|
|
2
|
+
// import wrapped in try catch does not work correctly with inlineRequires option
|
|
3
|
+
// in metro.config.js
|
|
4
|
+
//
|
|
5
|
+
// It looks like in generated bundle "react-native-reanimated" is not present
|
|
6
|
+
// in _dependencyMap, but references to it count it as if it was, e.g. bundle contains
|
|
7
|
+
// a line "(0, _$$_REQUIRE(_dependencyMap[15], "./GLUtils").configureLogging)(gl);"
|
|
8
|
+
// but dependencyMap contains only 15 elements
|
|
9
|
+
export function createWorkletContextProvider() {
|
|
10
|
+
try {
|
|
11
|
+
// reanimated needs to be imported before any workletized code
|
|
12
|
+
// is created, but we don't want to make it dependency on expo-gl.
|
|
13
|
+
require('react-native-reanimated');
|
|
14
|
+
return (contextId) => {
|
|
15
|
+
'worklet';
|
|
16
|
+
return global.__EXGLContexts?.[String(contextId)];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return () => {
|
|
21
|
+
throw new Error('Worklet runtime is not available');
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=GLWorkletContextProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GLWorkletContextProvider.js","sourceRoot":"","sources":["../src/GLWorkletContextProvider.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,iFAAiF;AACjF,qBAAqB;AACrB,EAAE;AACF,6EAA6E;AAC7E,sFAAsF;AACtF,mFAAmF;AACnF,8CAA8C;AAC9C,MAAM,UAAU,4BAA4B;IAC1C,IAAI;QACF,8DAA8D;QAC9D,kEAAkE;QAClE,OAAO,CAAC,yBAAyB,CAAC,CAAC;QACnC,OAAO,CAAC,SAAiB,EAAyC,EAAE;YAClE,SAAS,CAAC;YACV,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC;KACH;IAAC,MAAM;QACN,OAAO,GAAG,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import { ExpoWebGLRenderingContext } from './GLView.types';\n\n// This method needs to be in a separate file because react-native-reanimated\n// import wrapped in try catch does not work correctly with inlineRequires option\n// in metro.config.js\n//\n// It looks like in generated bundle \"react-native-reanimated\" is not present\n// in _dependencyMap, but references to it count it as if it was, e.g. bundle contains\n// a line \"(0, _$$_REQUIRE(_dependencyMap[15], \"./GLUtils\").configureLogging)(gl);\"\n// but dependencyMap contains only 15 elements\nexport function createWorkletContextProvider() {\n try {\n // reanimated needs to be imported before any workletized code\n // is created, but we don't want to make it dependency on expo-gl.\n require('react-native-reanimated');\n return (contextId: number): ExpoWebGLRenderingContext | undefined => {\n 'worklet';\n return global.__EXGLContexts?.[String(contextId)];\n };\n } catch {\n return () => {\n throw new Error('Worklet runtime is not available');\n };\n }\n}\n"]}
|
package/ios/EXGL/EXGLContext.mm
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
@property (nonatomic, weak) EXGLObjectManager *objectManager;
|
|
21
21
|
@property (nonatomic, assign) BOOL isContextReady;
|
|
22
22
|
@property (nonatomic, assign) BOOL wasPrepareCalled;
|
|
23
|
+
@property (nonatomic) BOOL appIsBackgrounded;
|
|
23
24
|
|
|
24
25
|
@end
|
|
25
26
|
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
_eaglCtx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3] ?: [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
|
|
37
38
|
_isContextReady = NO;
|
|
38
39
|
_wasPrepareCalled = NO;
|
|
40
|
+
_appIsBackgrounded = NO;
|
|
39
41
|
}
|
|
40
42
|
return self;
|
|
41
43
|
}
|
|
@@ -71,6 +73,29 @@
|
|
|
71
73
|
{
|
|
72
74
|
self->_contextId = UEXGLContextCreate();
|
|
73
75
|
[self->_objectManager saveContext:self];
|
|
76
|
+
|
|
77
|
+
// listen for foreground/background transitions
|
|
78
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
79
|
+
selector:@selector(onApplicationDidBecomeActive:)
|
|
80
|
+
name:UIApplicationDidBecomeActiveNotification
|
|
81
|
+
object:nil];
|
|
82
|
+
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
83
|
+
selector:@selector(onApplicationWillResignActive:)
|
|
84
|
+
name:UIApplicationWillResignActiveNotification
|
|
85
|
+
object:nil];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
- (void)onApplicationWillResignActive:(NSNotification *)notification
|
|
89
|
+
{
|
|
90
|
+
_appIsBackgrounded = YES;
|
|
91
|
+
dispatch_sync(_glQueue, ^{
|
|
92
|
+
glFinish();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (void)onApplicationDidBecomeActive:(NSNotification *)notification {
|
|
97
|
+
_appIsBackgrounded = NO;
|
|
98
|
+
[self flush];
|
|
74
99
|
}
|
|
75
100
|
|
|
76
101
|
- (void)prepare:(void(^)(BOOL))callback
|
|
@@ -117,6 +142,9 @@
|
|
|
117
142
|
|
|
118
143
|
- (void)flush
|
|
119
144
|
{
|
|
145
|
+
if (_appIsBackgrounded) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
120
148
|
[self runAsync:^{
|
|
121
149
|
UEXGLContextFlush(self->_contextId);
|
|
122
150
|
|
|
@@ -128,6 +156,9 @@
|
|
|
128
156
|
|
|
129
157
|
- (void)destroy
|
|
130
158
|
{
|
|
159
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
|
|
160
|
+
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
|
|
161
|
+
|
|
131
162
|
[self runAsync:^{
|
|
132
163
|
if ([self.delegate respondsToSelector:@selector(glContextWillDestroy:)]) {
|
|
133
164
|
[self.delegate glContextWillDestroy:self];
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-gl",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.4.0",
|
|
4
4
|
"description": "Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"preset": "expo-module-scripts"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"expo-gl-cpp": "~11.
|
|
40
|
+
"expo-gl-cpp": "~11.4.0",
|
|
41
41
|
"invariant": "^2.2.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"@types/offscreencanvas": "2019.6.4",
|
|
46
46
|
"@types/webgl2": "^0.0.6",
|
|
47
47
|
"expo-module-scripts": "^2.0.0",
|
|
48
|
-
"react-test-renderer": "~
|
|
48
|
+
"react-test-renderer": "~18.0.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"expo": "*"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "e893ff2b01e108cf246cec02318c0df9d6bc603c"
|
|
54
54
|
}
|
package/src/GLView.tsx
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
SnapshotOptions,
|
|
17
17
|
BaseGLViewProps,
|
|
18
18
|
} from './GLView.types';
|
|
19
|
+
import { createWorkletContextProvider } from './GLWorkletContextProvider';
|
|
19
20
|
|
|
20
21
|
export interface WebGLObject {
|
|
21
22
|
id: number;
|
|
@@ -74,21 +75,7 @@ export class GLView extends React.Component<GLViewProps> {
|
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
static getWorkletContext: (contextId: number) => ExpoWebGLRenderingContext | undefined =
|
|
77
|
-
(
|
|
78
|
-
try {
|
|
79
|
-
// reanimated needs to be imported before any workletized code
|
|
80
|
-
// is created, but we don't want to make it dependency on expo-gl.
|
|
81
|
-
require('react-native-reanimated');
|
|
82
|
-
return (contextId: number): ExpoWebGLRenderingContext | undefined => {
|
|
83
|
-
'worklet';
|
|
84
|
-
return global.__EXGLContexts?.[String(contextId)];
|
|
85
|
-
};
|
|
86
|
-
} catch {
|
|
87
|
-
return () => {
|
|
88
|
-
throw new Error('Worklet runtime is not available');
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
})();
|
|
78
|
+
createWorkletContextProvider();
|
|
92
79
|
|
|
93
80
|
nativeRef: ComponentOrHandle = null;
|
|
94
81
|
exglCtxId?: number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExpoWebGLRenderingContext } from './GLView.types';
|
|
2
|
+
|
|
3
|
+
// This method needs to be in a separate file because react-native-reanimated
|
|
4
|
+
// import wrapped in try catch does not work correctly with inlineRequires option
|
|
5
|
+
// in metro.config.js
|
|
6
|
+
//
|
|
7
|
+
// It looks like in generated bundle "react-native-reanimated" is not present
|
|
8
|
+
// in _dependencyMap, but references to it count it as if it was, e.g. bundle contains
|
|
9
|
+
// a line "(0, _$$_REQUIRE(_dependencyMap[15], "./GLUtils").configureLogging)(gl);"
|
|
10
|
+
// but dependencyMap contains only 15 elements
|
|
11
|
+
export function createWorkletContextProvider() {
|
|
12
|
+
try {
|
|
13
|
+
// reanimated needs to be imported before any workletized code
|
|
14
|
+
// is created, but we don't want to make it dependency on expo-gl.
|
|
15
|
+
require('react-native-reanimated');
|
|
16
|
+
return (contextId: number): ExpoWebGLRenderingContext | undefined => {
|
|
17
|
+
'worklet';
|
|
18
|
+
return global.__EXGLContexts?.[String(contextId)];
|
|
19
|
+
};
|
|
20
|
+
} catch {
|
|
21
|
+
return () => {
|
|
22
|
+
throw new Error('Worklet runtime is not available');
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|