BabylonReactNative icon indicating copy to clipboard operation
BabylonReactNative copied to clipboard

App crashes during reload (not hot reload) if in AR mode

Open Alex-MSFT opened this issue 5 years ago • 3 comments

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)

Alex-MSFT avatar Jun 01 '20 17:06 Alex-MSFT

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.

ryantrem avatar Oct 01 '20 22:10 ryantrem

Blocked by #84

bghgary avatar Oct 02 '20 17:10 bghgary

#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.

ryantrem avatar Dec 22 '20 18:12 ryantrem