Skip to content

Commit b6838d0

Browse files
authored
Don't bgfx::shutdown for debug builds since it doesn't work with fast refresh (#126)
* Don't bgfx::shutdown for debug builds since it doesn't work with fast refresh * Update docs to include a test step for fast refresh
1 parent 0572e64 commit b6838d0

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Modules/@babylonjs/react-native/EngineHook.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,12 @@ export function useEngine(): Engine | undefined {
8383
if (engine) {
8484
DisposeEngine(engine);
8585
}
86-
BabylonModule.reset();
86+
// Ideally we would always do a reset here as we don't want different behavior between debug and release. Unfortunately, fast refresh has some strange behavior that
87+
// makes it quite difficult to get this to work correctly (e.g. it re-runs previous useEffect instances, which means it can try to use Babylon Native in a de-initialized state).
88+
// TODO: https://github.com/BabylonJS/BabylonReactNative/issues/125
89+
if (!__DEV__) {
90+
BabylonModule.reset();
91+
}
8792
setEngine(undefined);
8893
};
8994
}, []);

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ When making local changes, the following manual test steps should be performed w
152152
1. **View replacement** - tap the *Toggle EngineView* button twice to replace the render target view.
153153
1. **Engine dispose** - tap the *Toggle EngineScreen* button twice to dispose and re-instantiate the Babylon engine.
154154
1. **Suspend/resume** - switch to a different app and then back to the Playground and make sure it is still rendering correctly.
155-
1. **Dev mode reload** - in the Metro server console window, press the `R` key on the keyboard to reload the JS engine and make sure rendering restarts successfully.
155+
1. **Fast refresh** (debug only) - save the App.tsx file to trigger a fast refresh.
156+
1. **Dev mode reload** (debug only) - in the Metro server console window, press the `R` key on the keyboard to reload the JS engine and make sure rendering restarts successfully.
156157
1. **XR mode** - tap the *Start XR* button and make sure XR mode is working.
157158
1. **XR display rotation** - rotate the device 90 degrees and make sure the view rotates and renders correctly.
158159
1. **XR view replacement** - tap the *Toggle EngineView* button twice to replace the render target view.

0 commit comments

Comments
 (0)