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

perf: reanimated 3 upgrade #11567

Merged
merged 19 commits into from
Oct 25, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
import java.util.List;
import com.facebook.react.modules.i18nmanager.I18nUtil;

import com.facebook.react.bridge.JSIModulePackage;
import com.swmansion.reanimated.ReanimatedJSIModulePackage;

public class MainApplication extends MultiDexApplication implements ReactApplication {

private final ReactNativeHost mReactNativeHost =
Expand All @@ -49,11 +46,6 @@ protected List<ReactPackage> getPackages() {
protected String getJSMainModuleName() {
return "index";
}

@Override
protected JSIModulePackage getJSIModulePackage() {
return new ReanimatedJSIModulePackage();
}
};

// TODO: Use this to enable new architecture.
Expand Down
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ PODS:
- React-Core
- RNReactNativeHapticFeedback (1.14.0):
- React-Core
- RNReanimated (2.10.0):
- RNReanimated (3.0.0-rc.3):
- DoubleConversion
- FBLazyVector
- FBReactNativeSpec
Expand Down Expand Up @@ -1013,7 +1013,7 @@ SPEC CHECKSUMS:
RNGestureHandler: 920eb17f5b1e15dae6e5ed1904045f8f90e0b11e
RNPermissions: dcdb7b99796bbeda6975a6e79ad519c41b251b1c
RNReactNativeHapticFeedback: 1e3efeca9628ff9876ee7cdd9edec1b336913f8c
RNReanimated: 60e291d42c77752a0f6d6f358387bdf225a87c6e
RNReanimated: 6c980139eb3b043569a08b8cb3d92cdf46bd54fa
RNScreens: 0df01424e9e0ed7827200d6ed1087ddd06c493f9
RNSVG: ecd661f380a07ba690c9c5929c475a44f432d674
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
Expand Down
2 changes: 1 addition & 1 deletion jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import 'react-native-gesture-handler/jestSetup';
import _ from 'underscore';

require('react-native-reanimated/lib/reanimated2/jestUtils').setUpTests();
require('react-native-reanimated/src/reanimated2/jestUtils').setUpTests();

jest.mock('react-native-blob-util', () => ({}));

Expand Down
26 changes: 13 additions & 13 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"license": "MIT",
"private": true,
"scripts": {
"postinstall": "cd desktop && npm install",
"postinstall": "npx patch-package && cd desktop && npm install",
"clean": "npx react-native clean-project-auto",
"android": "scripts/set-pusher-suffix.sh && npx react-native run-android --port=8083",
"ios": "scripts/set-pusher-suffix.sh && npx react-native run-ios --port=8082",
Expand Down Expand Up @@ -58,7 +58,7 @@
"@react-native-firebase/crashlytics": "^12.3.0",
"@react-native-firebase/perf": "^12.3.0",
"@react-native-picker/picker": "^2.4.3",
"@react-navigation/drawer": "git@github.com:Expensify/react-navigation.git#react-navigation-drawer-v6.5.0-gitpkg",
"@react-navigation/drawer": "github:Expensify/react-navigation#react-navigation-drawer-v6.5.0-alpha1-gitpkg",
"@react-navigation/native": "6.0.13",
"@react-navigation/stack": "6.3.1",
"babel-plugin-transform-remove-console": "^6.9.4",
Expand Down Expand Up @@ -102,7 +102,7 @@
"react-native-permissions": "^3.0.1",
"react-native-picker-select": "git+https://github.com/Expensify/react-native-picker-select.git#7f09b2c15ffae320d769788f75bdf8948714bb10",
"react-native-plaid-link-sdk": "^7.2.0",
"react-native-reanimated": "2.10.0",
"react-native-reanimated": "3.0.0-rc.3",
"react-native-render-html": "6.3.1",
"react-native-safe-area-context": "4.4.1",
"react-native-screens": "3.17.0",
Expand Down
64 changes: 64 additions & 0 deletions patches/react-native-reanimated+3.0.0-rc.3.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/node_modules/react-native-reanimated/RNReanimated.podspec b/node_modules/react-native-reanimated/RNReanimated.podspec
index 3205c93..c7f2821 100644
--- a/node_modules/react-native-reanimated/RNReanimated.podspec
+++ b/node_modules/react-native-reanimated/RNReanimated.podspec
@@ -49,7 +49,12 @@ rescue
end
end

-reactCommonDir = File.join(nodeModulesDir, "react-native", "ReactCommon")
+
+# From: https://github.com/software-mansion/react-native-reanimated/pull/3701/files
+pods_root = Pod::Config.instance.project_pods_root
+react_native_common_dir_absolute = File.join(nodeModulesDir, 'react-native', 'ReactCommon')
+react_native_common_dir_relative = Pathname.new(react_native_common_dir_absolute).relative_path_from(pods_root).to_s
+reactCommonDir = react_native_common_dir_relative

if isUserApp
libInstances = %x[find ../../ -name "package.json" | grep "/react-native-reanimated/package.json" | grep -v "/.yarn/"]
@@ -111,9 +116,10 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
}
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags + ' -DHERMES_ENABLE_DEBUGGER'
- s.xcconfig = {
- "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"#{reactCommonDir}\"",
- "OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags }
+ s.xcconfig = {
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/#{folly_prefix}Folly\" \"$(PODS_ROOT)/Headers/Public/React-hermes\" \"$(PODS_ROOT)/Headers/Public/hermes-engine\" \"$(PODS_ROOT)/#{reactCommonDir}\"",
+ "OTHER_CFLAGS" => "$(inherited)" + " " + folly_flags + " " + fabric_flags
+ }

s.requires_arc = true

diff --git a/node_modules/react-native-reanimated/ios/REAModule.mm b/node_modules/react-native-reanimated/ios/REAModule.mm
index e1cd2f4..8ba248d 100644
--- a/node_modules/react-native-reanimated/ios/REAModule.mm
+++ b/node_modules/react-native-reanimated/ios/REAModule.mm
@@ -52,6 +52,7 @@ @implementation REAModule {
#ifdef DEBUG
SingleInstanceChecker<REAModule> singleInstanceChecker_;
#endif
+ bool hasListeners;
}

RCT_EXPORT_MODULE(ReanimatedModule);
@@ -291,4 +292,19 @@ - (void)eventDispatcherWillDispatchEvent:(id<RCTEvent>)event
[_nodesManager dispatchEvent:event];
}

+- (void)startObserving {
+ hasListeners = YES;
+}
+
+- (void)stopObserving {
+ hasListeners = NO;
+}
+
+- (void)sendEventWithName:(NSString *)eventName body:(id)body
+{
+ if (hasListeners) {
+ [super sendEventWithName:eventName body:body];
+ }
+}
+
@end