Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix merge conflict #3

Merged
merged 13 commits into from
Jul 20, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:
jdk: openjdk8
env:
- NODE_VERSION=10.15.3
- ANDROID_API=28
- ANDROID_BUILD_TOOLS=28.0.3
- ANDROID_API=29
- ANDROID_BUILD_TOOLS=29.0.2
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -rf $HOME/.gradle/caches/*/plugin-resolution/
Expand Down
4 changes: 3 additions & 1 deletion Common/cpp/NativeModules/NativeReanimatedModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ NativeReanimatedModule::NativeReanimatedModule(std::shared_ptr<CallInvoker> jsIn
std::shared_ptr<Scheduler> scheduler,
std::unique_ptr<jsi::Runtime> rt,
std::function<void(std::function<void(double)>)> requestRender,
std::function<void(jsi::Runtime&, int, const jsi::Object&)> propUpdater):
std::function<void(jsi::Runtime&, int, const jsi::Object&)> propUpdater,
std::shared_ptr<ErrorHandler> errorHandler):
NativeReanimatedModuleSpec(jsInvoker),
runtime(std::move(rt)),
mapperRegistry(new MapperRegistry()),
eventHandlerRegistry(new EventHandlerRegistry()),
requestRender(requestRender),
errorHandler(errorHandler),
workletsCache(new WorkletsCache()),
scheduler(scheduler) {
RuntimeDecorator::addNativeObjects(*runtime, propUpdater, [=](FrameCallback callback) {
Expand Down
32 changes: 23 additions & 9 deletions Common/cpp/SharedItems/ShareableValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
return jsi::Value(rt, *funPtr);
}

auto clb = [=](
auto clb = [=, &module](
jsi::Runtime &rt,
const jsi::Value &thisValue,
const jsi::Value *args,
Expand All @@ -205,11 +205,18 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
rt.global().setProperty(rt, "jsThis", *jsThis); //set jsThis

jsi::Value res = jsi::Value::undefined();

if (thisValue.isObject()) {
res = funPtr->callWithThis(rt, thisValue.asObject(rt), args, count);
} else {
res = funPtr->call(rt, args, count);
try {
if (thisValue.isObject()) {
res = funPtr->callWithThis(rt, thisValue.asObject(rt), args, count);
} else {
res = funPtr->call(rt, args, count);
}
} catch(std::exception &e) {
std::string str = e.what();
module->errorHandler->setError(str.c_str());
if (!module->errorHandler->raise()) {
throw;
}
}

rt.global().setProperty(rt, "jsThis", oldJSThis); //clean jsThis
Expand All @@ -235,7 +242,7 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {
params.push_back(ShareableValue::adapt(rt, args[i], module));
}

module->scheduler->scheduleOnUI([retain_this, params] {
module->scheduler->scheduleOnUI([retain_this, params, &module] {
jsi::Runtime &rt = *retain_this->module->runtime.get();
auto jsThis = retain_this->createHost(rt, retain_this->frozenObject);
auto code = jsThis.getProperty(rt, "asString").asString(rt).utf8(rt);
Expand All @@ -250,11 +257,18 @@ jsi::Value ShareableValue::toJSValue(jsi::Runtime &rt) {

jsi::Value oldJSThis = rt.global().getProperty(rt, "jsThis");
rt.global().setProperty(rt, "jsThis", jsThis); //set jsThis

returnedValue = funPtr->call(rt,
try {
returnedValue = funPtr->call(rt,
static_cast<const jsi::Value*>(args),
(size_t)params.size());

} catch(std::exception &e) {
std::string str = e.what();
module->errorHandler->setError(str.c_str());
if (!module->errorHandler->raise()) {
throw;
}
}
rt.global().setProperty(rt, "jsThis", oldJSThis); //clean jsThis

delete [] args;
Expand Down
10 changes: 9 additions & 1 deletion Common/cpp/Tools/Mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Mapper::Mapper(NativeReanimatedModule *module,
std::vector<std::shared_ptr<MutableValue>> inputs,
std::vector<std::shared_ptr<MutableValue>> outputs):
id(id),
module(module),
mapper(std::move(mapper)),
inputs(inputs),
outputs(outputs) {
Expand All @@ -24,7 +25,14 @@ outputs(outputs) {

void Mapper::execute(jsi::Runtime &rt) {
dirty = false;
mapper.callWithThis(rt, mapper);
try {
mapper.callWithThis(rt, mapper);
}
catch(...) {
if (!module->errorHandler->raise()) {
throw;
}
}
}

}
5 changes: 3 additions & 2 deletions Common/cpp/headers/NativeModules/NativeReanimatedModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec {
std::shared_ptr<Scheduler> scheduler,
std::unique_ptr<jsi::Runtime> rt,
std::function<void(std::function<void(double)>)> requestRender,
std::function<void(jsi::Runtime&, int, const jsi::Object&)> propUpdater);
std::function<void(jsi::Runtime&, int, const jsi::Object&)> propUpdater,
std::shared_ptr<ErrorHandler> errorHandler);
virtual ~NativeReanimatedModule();

void installCoreFunctions(jsi::Runtime &rt, const jsi::Value &valueSetter) override;
Expand Down Expand Up @@ -56,11 +57,11 @@ class NativeReanimatedModule : public NativeReanimatedModuleSpec {
std::shared_ptr<MapperRegistry> mapperRegistry;
std::shared_ptr<EventHandlerRegistry> eventHandlerRegistry;
std::function<void(FrameCallback)> requestRender;
std::shared_ptr<ErrorHandler> errorHandler;
std::shared_ptr<jsi::Value> dummyEvent;
std::vector<FrameCallback> frameCallbacks;
bool renderRequested = false;
public:
std::shared_ptr<ErrorHandler> errorHandler;
std::shared_ptr<WorkletsCache> workletsCache;
std::shared_ptr<ShareableValue> valueSetter;
std::shared_ptr<Scheduler> scheduler;
Expand Down
17 changes: 10 additions & 7 deletions Common/cpp/headers/SpecTools/ErrorHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@

struct ErrorWrapper {
std::string message = "";
bool handled = false;
bool handled = true;
};

class ErrorHandler {
public:
void raise(const char *message) {
std::string str = message;
this->getScheduler()->scheduleOnUI([this, str]() mutable {
this->raiseSpec(str.c_str());
bool raise() {
if (getError()->handled) {
return false;
}
this->getScheduler()->scheduleOnUI([this]() mutable {
this->raiseSpec();
});
return true;
}
virtual std::shared_ptr<Scheduler> getScheduler() = 0;
virtual std::shared_ptr<ErrorWrapper> getError() = 0;
virtual void handleError() = 0;
virtual void setError(const char *message) = 0;
virtual ~ErrorHandler() {}
protected:
virtual void raiseSpec(const char *message) = 0;
virtual void raiseSpec() = 0;
};
1 change: 1 addition & 0 deletions Common/cpp/headers/Tools/Mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Mapper {
friend MapperRegistry;
private:
unsigned long id;
NativeReanimatedModule *module;
jsi::Function mapper;
std::vector<std::shared_ptr<MutableValue>> inputs;
std::vector<std::shared_ptr<MutableValue>> outputs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@

public class MainApplication extends Application implements ReactApplication {

static {
ReactFeatureFlags.useTurboModules = true;
}

private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
Expand Down Expand Up @@ -81,7 +77,7 @@ public ReactNativeHost getReactNativeHost() {
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
// initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
}

private static void initializeFlipper(
Expand Down
8 changes: 4 additions & 4 deletions Example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

buildscript {
ext {
buildToolsVersion = "28.0.3"
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
jcenter()
google()
}

dependencies {
classpath('com.android.tools.build:gradle:3.5.2')
classpath('com.android.tools.build:gradle:3.5.3')
classpath 'de.undercouch:gradle-download-task:4.0.0'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion Example/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
android.useAndroidX=true
android.enableJetifier=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.33.1
FLIPPER_VERSION=0.37.0
2 changes: 1 addition & 1 deletion Example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
105 changes: 11 additions & 94 deletions Example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,108 +1,25 @@
platform :ios, '9.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

# commented out because of https://github.com/facebook/react-native/issues/28824
#def add_flipper_pods!(versions = {})
#versions['Flipper'] ||= '~> 0.33.1'
#versions['DoubleConversion'] ||= '1.1.7'
#versions['Flipper-Folly'] ||= '~> 2.1'
#versions['Flipper-Glog'] ||= '0.3.6'
#versions['Flipper-PeerTalk'] ||= '~> 0.0.4'
#versions['Flipper-RSocket'] ||= '~> 1.0'
#pod 'FlipperKit', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FlipperKitUserDefaultsPlugin', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FlipperKitReactPlugin', versions['Flipper'], :configuration => 'Debug'
# List all transitive dependencies for FlipperKit pods
# to avoid them being linked in Release builds
#pod 'Flipper', versions['Flipper'], :configuration => 'Debug'
#pod 'Flipper-DoubleConversion', versions['DoubleConversion'], :configuration => 'Debug'
#pod 'Flipper-Folly', versions['Flipper-Folly'], :configuration => 'Debug'
#pod 'Flipper-Glog', versions['Flipper-Glog'], :configuration => 'Debug'
#pod 'Flipper-PeerTalk', versions['Flipper-PeerTalk'], :configuration => 'Debug'
#pod 'Flipper-RSocket', versions['Flipper-RSocket'], :configuration => 'Debug'
#pod 'FlipperKit/Core', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/CppBridge', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FBCxxFollyDynamicConvert', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FBDefines', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FKPortForwarding', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configuration => 'Debug'
#pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configuration => 'Debug'
#end
# Post Install processing for Flipper
#def flipper_post_install(installer)
#installer.pods_project.targets.each do |target|
# if target.name == 'YogaKit'
# target.build_configurations.each do |config|
# config.build_settings['SWIFT_VERSION'] = '4.1'
# end
# end
#end
#end
platform :ios, '10.0'

def pods()
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/callinvoker', :path => "../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'

pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
pod 'React-ART', :path => '../node_modules/react-native/Libraries/ART'
pod 'ReactCommon/turbomodule/samples', :path => '../node_modules/react-native/ReactCommon'

pod 'Yoga', :path => "../node_modules/react-native/ReactCommon/yoga"
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])

def pods()
pod 'RNReanimated', :path => '../../'
pod 'ReactCommon/turbomodule/samples', :path => '../node_modules/react-native/ReactCommon'


pod 'RNSVG', :path => '../node_modules/react-native-svg'
pod 'RNCMaskedView', :path => '../node_modules/@react-native-community/masked-view'

# Additional Pods which aren't included in the default Podfile
pod 'React-ART', :path => '../node_modules/react-native/Libraries/ART'
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga', :modular_headers => true
pod 'React-callinvoker', :path => "../node_modules/react-native/ReactCommon/callinvoker"
use_native_modules!
pod 'RNGestureHandler', :path => '../node_modules/react-native-gesture-handler'
end

target 'ReanimatedExample' do
project 'ReanimatedExample',
'Debug (Staging)' => :debug,
'Debug (Production)' => :debug,
'Release (Staging)' => :release,
'Release (Production)' => :release
project 'ReanimatedExample'
pods()
pod 'RNSVG', :path => '../node_modules/react-native-svg'
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# add_flipper_pods!
# post_install do |installer|
# flipper_post_install(installer)
# end
end

target 'ReanimatedExampleTests' do
Expand Down