-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change includes a bunch of fixes for React Native dev mode reload (which reloads the JS engine). - Update to the latest BabylonNative submodule which includes a fix to actually delete the napi instance on Napi::Detach. - Set the current NativeEngine instance on the _native object so we can get it on the native side and manually dispose it (since during a reload the EngineHook's cleanup function will not be called, but we still need to release these resources). - Have the native interop code grab the current NativeEngine instance off of _native during teardown and call dispose on it. - Prevent the JS dispatcher from actually doing anything if we are in the process of shutting down the JS engine. These changes are a little icky and there is a fair bit of duplication across Android and iOS. I have a bigger cleanup planned for this code that will consolidate a lot of the Android and iOS code, but that will happen later. Fixes #84
- Loading branch information
Showing
9 changed files
with
99 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
import { NativeModules } from 'react-native'; | ||
import { NativeEngine } from '@babylonjs/core'; | ||
|
||
export const BabylonModule: { | ||
// This global object is part of Babylon Native. | ||
declare const _native: { | ||
graphicsInitializationPromise: Promise<void>; | ||
engineInstance: NativeEngine; | ||
} | ||
|
||
const NativeBabylonModule: { | ||
initialize(): Promise<boolean>; | ||
whenInitialized(): Promise<boolean>; | ||
} = NativeModules.BabylonModule; | ||
} = NativeModules.BabylonModule; | ||
|
||
export const BabylonModule = { | ||
initialize: async () => { | ||
const initialized = await NativeBabylonModule.initialize(); | ||
if (initialized) { | ||
await _native.graphicsInitializationPromise; | ||
} | ||
return initialized; | ||
}, | ||
|
||
whenInitialized: NativeBabylonModule.whenInitialized, | ||
|
||
createEngine: () => { | ||
const engine = new NativeEngine(); | ||
_native.engineInstance = engine; | ||
return engine; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters