Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Apps/PackageTest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Apps/PackageTest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@babylonjs/core": "^4.2.0-beta.6",
"@babylonjs/core": "^4.2.0-beta.10",
"@babylonjs/react-native": "file:../../Package/Assembled/babylonjs-react-native-0.0.1.tgz",
"react": "16.13.1",
"react-native": "0.63.1",
Expand Down
22 changes: 11 additions & 11 deletions Apps/Playground/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Apps/Playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"lint": "eslint . --ext .js,.jsx,.ts,.tsx"
},
"dependencies": {
"@babylonjs/core": "^4.2.0-beta.6",
"@babylonjs/loaders": "^4.2.0-beta.6",
"@babylonjs/core": "^4.2.0-beta.10",
"@babylonjs/loaders": "^4.2.0-beta.10",
"@babylonjs/react-native": "file:../../Modules/@babylonjs/react-native",
"@react-native-community/slider": "^2.0.9",
"logkitty": "^0.7.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ namespace Babylon
Polyfills::Window::Initialize(m_env);

m_nativeInput = &Babylon::Plugins::NativeInput::CreateForJavaScript(m_env);

// TODO: This shouldn't be necessary, but for some reason results in a significant increase in frame rate. Need to figure this out.
m_graphics->ReinitializeFromWindow<void*>(windowPtr, width, height);
}

~Native()
Expand Down
10 changes: 5 additions & 5 deletions Modules/@babylonjs/react-native/ios/BabylonNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,22 @@ namespace Babylon
struct DispatchData
{
arcana::run_loop_scheduler scheduler;
Napi::FunctionReference flushedQueue;
std::shared_ptr<facebook::jsi::Function> setTimeout;

DispatchData(Napi::Env env)
DispatchData(facebook::jsi::Runtime& rt)
: scheduler{ arcana::run_loop_scheduler::get_for_current_thread() }
, flushedQueue{ GetFlushedQueue(env) }
, setTimeout{ GetSetTimeout(rt) }
{
}
};

JsRuntime::DispatchFunctionT dispatchFunction =
[env = m_impl->env, data = std::make_shared<DispatchData>(m_impl->env)](std::function<void(Napi::Env)> func)
[env = m_impl->env, data = std::make_shared<DispatchData>(*jsiRuntime)](std::function<void(Napi::Env)> func)
{
(data->scheduler)([env, func = std::move(func), &data]()
{
func(env);
data->flushedQueue.Call({});
data->setTimeout->call((static_cast<napi_env>(env))->rt, {});
});
};

Expand Down
2 changes: 1 addition & 1 deletion Modules/@babylonjs/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"base-64": "^0.1.0"
},
"peerDependencies": {
"@babylonjs/core": "^4.2.0-beta.6",
"@babylonjs/core": "^4.2.0-beta.10",
"react": "^16.13.1",
"react-native": "^0.63.1",
"react-native-permissions": "^2.1.4"
Expand Down
12 changes: 12 additions & 0 deletions Modules/@babylonjs/react-native/shared/Shared.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <napi/napi.h>
#include <jsi/jsi.h>

// See https://github.com/BabylonJS/BabylonReactNative/issues/60 for original issue.
// This is a work around to poke the React Native message queue to run setImmediate callbacks.
Expand All @@ -16,3 +17,14 @@ inline Napi::FunctionReference GetFlushedQueue(Napi::Env env)
auto flushedQueue{ batchedBridge.Get("flushedQueue").As<Napi::Function>() };
return Napi::Persistent(flushedQueue);
}

// On iOS, directly calling flushedQueue breaks some kind of internal UI state and we start getting errors like:
// *** Assertion failure in -[RCTNativeAnimatedNodesManager disconnectAnimatedNodes:childTag:](), node_modules/react-native/Libraries/NativeAnimation/RCTNativeAnimatedNodesManager.m:138
// [native] Exception thrown while executing UI block: 'parentNode' is a required parameter
// However, calling setTimeout eventually also calls flushedQueue, but doesn't result in the above error,
// so we'll go this route until we (hopefully) get a better resolution from the React Native team at Facebook.
inline std::shared_ptr<facebook::jsi::Function> GetSetTimeout(facebook::jsi::Runtime& rt)
{
auto code{std::make_shared<const facebook::jsi::StringBuffer>("() => setTimeout(() => {})")};
return std::make_shared<facebook::jsi::Function>(rt.evaluateJavaScript(std::move(code), "").asObject(rt).asFunction(rt));
}