BabylonReactNative
BabylonReactNative copied to clipboard
App crashes during reload (not hot reload) if in AR mode
If a hot reload is triggered while in AR mode the app crashes. If you exit AR mode first hot reload works as expected. With the below traces (probably because the JS Engine is getting torn down).
We should gracefully handle this failure and exit AR mode.
2020-06-01 10:24:25.209 907-959/com.playground A/libc: E:/BabylonReactNative/Apps/Playground/node_modules/react-native-babylon/submodules/BabylonNative/Dependencies/napi/source/js_native_api_JavaScriptCore.cc:114: JSObjectRef (anonymous namespace)::ToJSObject(napi_env, const napi_value): assertion "value == nullptr || JSValueIsObject(env->context, reinterpret_cast<JSValueRef>(value))" failed 2020-06-01 10:24:25.209 907-959/com.playground A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 959 (mqt_js), pid 907 (com.playground)
I think this was for a full JS engine reload (e.g. press R in the console window) and not actual hot reload/fast refresh. This is probably blocked by #84 now.
Blocked by #84
#84 has been fixed, so this is no longer blocked. I took a quick look and one problem I saw right away is that the XR session is not synchronously disposed when the engine is disposed (which is not the behavior I was expecting). This is because NativeXR.cpp does the following:
m_xr.Dispatch([this]() {
m_xr.EndSession();
...
Basically makes a fire-and-forget async call to EndSession. This means the session remains alive even after the engine has been disposed. I tried just removing the Dispatch, but then we get a crash in bgfx. We need to dig in a bit deeper to understand the order of operations with ending the XR session, queued frame rendering, etc.