Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
5e28bd2
Preparation work
Kwasow Jul 21, 2022
3f8215b
Fixed prepareHermes
Kwasow Jul 21, 2022
51bfb8f
Building hermes-inspector from source
Kwasow Jul 21, 2022
ff3fbaa
Replaced libhermes-inspector dependency with libhermes-executor
Kwasow Jul 22, 2022
320b039
Reverted change in xcode project
Kwasow Jul 25, 2022
dd57719
Added some source maps to wokrlets
Kwasow Jul 26, 2022
2729412
Removed old hermes initialization code
Kwasow Jul 28, 2022
9e9cbbf
IT STOPPED 🛑
Kwasow Aug 11, 2022
db298ca
Cleanup on Android, some changes on iOS
Kwasow Aug 11, 2022
571b65a
Merged main
Kwasow Aug 11, 2022
fb096be
Removed hermes debugger from release builds
Kwasow Aug 11, 2022
efed1e8
M
Kwasow Aug 17, 2022
24754c8
Moved closure prepending to transform
Kwasow Aug 17, 2022
ce0b2e2
Removed useless code
Kwasow Aug 18, 2022
acf077a
Fixed off by one line mapping issues. Optimized release bundle
Kwasow Aug 18, 2022
29491b2
Removed redundant console.log
Kwasow Aug 19, 2022
e579f72
Fixed release builds on Android (cmake part only)
Kwasow Aug 19, 2022
4adca84
Added some support for hermes debugging on iOS
Kwasow Aug 22, 2022
d288c66
Fixed app reloads on iOS
Kwasow Aug 23, 2022
bcc5d84
Partially fixed release builds on Android
Kwasow Aug 23, 2022
aa0cf3c
Added error handling on iOS
Kwasow Aug 23, 2022
55306a2
Fixed header search paths on iOS
Kwasow Aug 24, 2022
c116722
Added support for older React Native versions
Kwasow Aug 24, 2022
a530416
Prevented crashes on reload on Android (but still doesn't work)
Kwasow Aug 24, 2022
403384f
Merged main
Kwasow Aug 29, 2022
6bb62ac
Updated plugin tests
Kwasow Aug 29, 2022
6c33122
Fixed reloads on Android
Kwasow Aug 29, 2022
e4b9116
Moved hermes debugger logic to Common folder
Kwasow Aug 30, 2022
bec2b88
Fixed release builds on Android
Kwasow Aug 30, 2022
b45cc81
Code cleanup
Kwasow Aug 30, 2022
1e6a9f9
Fixing iOS
Kwasow Aug 30, 2022
63ce88a
Added important comment
Kwasow Aug 31, 2022
3219a5a
Added missing code on iOS
Kwasow Aug 31, 2022
b2c0061
Minor code improvements
Kwasow Aug 31, 2022
c3588cf
Added support for Flipper in babel plugin
Kwasow Sep 1, 2022
35853fd
Fixed cpp lint
Kwasow Sep 1, 2022
1303b2e
Fixed java lint
Kwasow Sep 1, 2022
740a334
Fixed babel plugin tests
Kwasow Sep 1, 2022
70b4af5
Fixed Example app build
Kwasow Sep 1, 2022
12ed55e
Fixed example apps build
Kwasow Sep 1, 2022
bd995a4
This PoC allows for a reload, but crashes on interaction with debugge…
Kwasow Sep 2, 2022
87aed5e
Removed patch hack
Kwasow Sep 5, 2022
ca68a49
Merge main
Kwasow Sep 12, 2022
78d0a31
Improved runtime initialization on iOS
Kwasow Sep 12, 2022
94ab7d4
Fixed Android CI
Kwasow Sep 12, 2022
1957ccc
Added patch from facebook/react-native#34489
Kwasow Sep 12, 2022
69dbbeb
Simplified implementation
Kwasow Sep 13, 2022
9fc0aa7
Updated initizalization on Android
Kwasow Sep 13, 2022
db7b40f
Removed unnecessary patch
Kwasow Sep 13, 2022
88dfdc9
Added patch for metro-inspector-proxy
Kwasow Sep 13, 2022
7618832
Fixed some of the tvOS build issues
Kwasow Sep 13, 2022
e5c72ab
Fixed Android build
Kwasow Sep 13, 2022
916e786
Added patch for react-native-gesture-handler
Kwasow Sep 13, 2022
58e9e7b
Fixed reloads while debugger connected
Kwasow Sep 13, 2022
5ba13ce
Fixed tvOS build
Kwasow Sep 14, 2022
c57bf23
save
Kwasow Sep 14, 2022
4751025
Fixed Android build
Kwasow Sep 14, 2022
2e98fdd
Fixed tvOS build and improved implementation
Kwasow Sep 14, 2022
86be060
Reverted yarn.lock, which was commited by mistake
Kwasow Sep 14, 2022
f72b23a
Improvements after self-review
Kwasow Sep 14, 2022
a73a124
More improvements and explanations
Kwasow Sep 14, 2022
98af8dc
save
Kwasow Sep 15, 2022
105b7ca
Added documentation to code
Kwasow Sep 15, 2022
c890ccc
Improved comments
Kwasow Sep 15, 2022
95b10dc
Fixed JSC on iOS
Kwasow Sep 15, 2022
98840bb
Fixed incorrect enabling of hermes debugger
Kwasow Sep 15, 2022
c2d5eef
Fixed build issues
Kwasow Sep 15, 2022
8c99701
Added patches to example app
Kwasow Sep 16, 2022
bf706af
Added patch-package to example app
Kwasow Sep 16, 2022
cfd0458
Fixed patch-package warnings
Kwasow Sep 16, 2022
ccd0c38
Enabled flipper in Example app
Kwasow Sep 16, 2022
ba6438c
We want it like this
Kwasow Sep 19, 2022
176ccc0
Removed tickleJS
Kwasow Sep 20, 2022
25a740a
Updated known issues
Kwasow Sep 20, 2022
628813f
Added explainatory comments:
Kwasow Sep 20, 2022
2fcf0fd
Removed unnecessary reference
Kwasow Sep 20, 2022
9e50fa4
Improvements after review (part 1)
Kwasow Sep 20, 2022
1d68efe
Improvements after review (part 2)
Kwasow Sep 21, 2022
df8498a
Improvements after review (part 3)
Kwasow Sep 21, 2022
fa4f39d
Improvements after review (part 4)
Kwasow Sep 21, 2022
873678f
Merged main
Kwasow Sep 21, 2022
c7cc522
Final updates
Kwasow Sep 21, 2022
fb92063
Improvements after review
Kwasow Sep 21, 2022
77ead21
Final changes
Kwasow Sep 21, 2022
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
Next Next commit
Preparation work
  • Loading branch information
Kwasow committed Jul 21, 2022
commit 5e28bd2ce747c08f34d2afafe738d9d924afaeaf
4 changes: 2 additions & 2 deletions FabricExample/ios/FabricExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -634,7 +634,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = i386;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
81 changes: 78 additions & 3 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ cmake_minimum_required(VERSION 3.12.0)

set (CMAKE_VERBOSE_MAKEFILE ON)
set (CMAKE_CXX_STANDARD 17)
set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DON_ANDROID -DONANDROID -DANDROID -DRNVERSION=${RNVERSION} -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall")
set (DEFAULT_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_HAVE_CLOCK_GETTIME=1 -DFOLLY_HAVE_MEMRCHR=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_MOBILE=1 -DFOLLY_HAVE_RECVMMSG=1 -DFOLLY_HAVE_PTHREAD=1 -DON_ANDROID -DONANDROID -DANDROID -DRNVERSION=${RNVERSION} -DHERMES_ENABLE_DEBUGGER=1 -fexceptions -fno-omit-frame-pointer -frtti -Wno-sign-compare -std=c++17 -Wall")
if(${IS_NEW_ARCHITECTURE_ENABLED})
set (ALL_FLAGS "${DEFAULT_FLAGS} -DRCT_NEW_ARCH_ENABLED")
else()
set (ALL_FLAGS ${DEFAULT_FLAGS})
endif()
set (CMAKE_CXX_FLAGS ${ALL_FLAGS})

if(${NATIVE_DEBUG})
#if(${NATIVE_DEBUG})
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
endif()
#endif()

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
Expand Down Expand Up @@ -82,6 +82,37 @@ add_library(
${REANIMATED_UI_MANAGER_BINDING_CPP}
)

# build hermes-inspector
#[[
file(
GLOB_RECURSE
HERMES_INSPECTOR_SOURCES_CPP
"${NODE_MODULES_DIR}/react-native/ReactCommon/hermes/inspector/*.cpp"
)
add_library(
hermes-inspector
SHARED
${HERMES_INSPECTOR_SOURCES_CPP}
)
target_include_directories(
hermes-inspector
PUBLIC
"${NODE_MODULES_DIR}/react-native/sdks/hermes/API/"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/build/third-party-ndk/libevent/include/"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/hermes-engine/build/hermes/external/llvh/include/"
"${NODE_MODULES_DIR}/react-native/ReactAndroid/src/main/jni/first-party/fbjni/headers/"
"${NODE_MODULES_DIR}/react-native/ReactCommon/"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/sdks/hermes/public/"
"${NODE_MODULES_DIR}/react-native/sdks/hermes/external/llvh/include/"
"${NODE_MODULES_DIR}/react-native/sdks/hermes/external/llvh/utils/unittest/googletest/include/"
"${NODE_MODULES_DIR}/react-native/sdks/hermes/external/llvh/utils/unittest/googlemock/include/"
"${BUILD_DIR}/third-party-ndk/glog/exported/"
"${BUILD_DIR}/third-party-ndk/folly/"
"${BUILD_DIR}/third-party-ndk/double-conversion"
"${BUILD_DIR}/third-party-ndk/boost/boost_${BOOST_VERSION}"
)
]]
# includes

file (GLOB LIBFBJNI_INCLUDE_DIR ${FBJNI_HEADERS_DIR})
Expand All @@ -102,6 +133,7 @@ target_include_directories(
"${NODE_MODULES_DIR}/react-native/ReactCommon"
"${NODE_MODULES_DIR}/react-native/ReactCommon/callinvoker"
"${NODE_MODULES_DIR}/react-native/ReactCommon/jsi"
"${NODE_MODULES_DIR}/react-native/ReactCommon/hermes"
"${NODE_MODULES_DIR}/react-native/ReactCommon/react/renderer/graphics/platform/cxx"
"${NODE_MODULES_DIR}/react-native/ReactCommon/runtimeexecutor"
"${NODE_MODULES_DIR}/react-native/ReactCommon/turbomodule/core"
Expand All @@ -117,6 +149,7 @@ target_include_directories(
"${COMMON_SRC_DIR}/cpp/headers/Fabric"
"${COMMON_SRC_DIR}/cpp/hidden_headers"
"${SRC_DIR}/main/cpp/headers"
"${SRC_DIR}/main/cpp/NativeProxy.cpp"
)

find_library(
Expand All @@ -141,7 +174,28 @@ find_library(
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
#[[
find_library(
FB_LIB
fb
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)

find_library(
JS_INSPECTOR_LIB
jsinspector
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)

find_library(
FOLLY_FUTURES_LIB
folly_futures
PATHS ${LIBRN_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
]]
if(${REACT_NATIVE_TARGET_VERSION} LESS 69)
find_library(
FOLLY_LIB
Expand Down Expand Up @@ -256,9 +310,30 @@ if(${JS_RUNTIME} STREQUAL "hermes")
PATHS ${HERMES_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
file (GLOB HERMES_INSPECTOR_DIR "${BUILD_DIR}/third-party-ndk/hermes-inspector/${ANDROID_ABI}")
find_library(
HERMES_INSPECTOR_LIB
hermes-inspector
PATHS ${HERMES_INSPECTOR_DIR}
NO_CMAKE_FIND_ROOT_PATH
)
#[[
target_link_libraries(
hermes-inspector
${HERMES_LIB}
${FOLLY_LIB}
${FOLLY_FUTURES_LIB}
${JSI_LIB}
${GLOG_LIB}
${FB_LIB}
${FBJNI_LIB}
${JS_INSPECTOR_LIB}
)
]]
target_link_libraries(
${PACKAGE_NAME}
${HERMES_LIB}
${HERMES_INSPECTOR_LIB}
)
elseif(${JS_RUNTIME} STREQUAL "v8")
string(APPEND CMAKE_CXX_FLAGS " -DJS_RUNTIME_V8=1")
Expand Down
12 changes: 12 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,18 @@ task prepareHermes() {
from "$reactNative/ReactAndroid/src/main/jni/first-party/hermes/Android.mk"
into "$thirdPartyNdkDir/hermes"
}

// Hermes inspector and dependencies
copy {
include "**/*.so"
from "../hermes-inspector"
into "../FabricExample/android/app/build/intermediates/merged_native_libs/debug/out/lib"
}
copy {
include "**/*.so"
from "../hermes-inspector"
into "../FabricExample/android/app/build/intermediates/stripped_native_libs/debug/out/lib"
}
}
}

Expand Down
19 changes: 17 additions & 2 deletions android/src/fabric/java/com/swmansion/reanimated/NativeProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.ReactApplication;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.queue.MessageQueueThread;
import com.facebook.react.bridge.queue.QueueThreadExceptionHandler;
import com.facebook.react.bridge.queue.ReactQueueConfigurationImpl;
import com.facebook.react.bridge.queue.ReactQueueConfigurationSpec;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableNativeArray;
Expand Down Expand Up @@ -144,7 +148,9 @@ private native HybridData initHybrid(
LayoutAnimations LayoutAnimations,
FabricUIManager fabricUIManager);

private native void installJSIBindings(FabricUIManager fabricUIManager);
private native void installJSIBindings(
FabricUIManager fabricUIManager,
MessageQueueThread messageQueueThread);

public native boolean isAnyHandlerWaitingForEvent(String eventName);

Expand Down Expand Up @@ -270,7 +276,16 @@ public void prepare(LayoutAnimations LayoutAnimations) {
mNodesManager = mContext.get().getNativeModule(ReanimatedModule.class).getNodesManager();
FabricUIManager fabricUIManager =
(FabricUIManager) UIManagerHelper.getUIManager(mContext.get(), UIManagerType.FABRIC);
installJSIBindings(fabricUIManager);
ReactQueueConfigurationImpl queueHolder = ReactQueueConfigurationImpl.create(
ReactQueueConfigurationSpec.createDefault(),
new QueueThreadExceptionHandler() {
@Override
public void handleException(Exception e) {
throw new RuntimeException(e);
}
}
);
installJSIBindings(fabricUIManager, queueHolder.getUIQueueThread());
AnimationsManager animationsManager =
mContext
.get()
Expand Down
24 changes: 22 additions & 2 deletions android/src/main/cpp/NativeProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#include "ReanimatedUIManagerBinding.h"
#endif

#if JS_RUNTIME_HERMES
#include "HermesExecutorRuntimeAdapter.h"
#include "react/jni/JMessageQueueThread.h"
#endif

namespace reanimated {

using namespace facebook;
Expand Down Expand Up @@ -107,7 +112,8 @@ jni::local_ref<NativeProxy::jhybriddata> NativeProxy::initHybrid(
void NativeProxy::installJSIBindings(
#ifdef RCT_NEW_ARCH_ENABLED
jni::alias_ref<facebook::react::JFabricUIManager::javaobject>
fabricUIManager
fabricUIManager,
jni::alias_ref<JavaMessageQueueThread::javaobject> messageQueueThread
#endif
/**/) {
#ifdef RCT_NEW_ARCH_ENABLED
Expand Down Expand Up @@ -203,8 +209,22 @@ void NativeProxy::installJSIBindings(
#if JS_RUNTIME_HERMES
auto config =
::hermes::vm::RuntimeConfig::Builder().withEnableSampleProfiling(false);
std::shared_ptr<jsi::Runtime> animatedRuntime =
// OLD CODE
#if false
std::shared_ptr<jsi::Runtime> animatedRuntime =
facebook::hermes::makeHermesRuntime(config.build());
// NEW CODE
#else
std::unique_ptr<facebook::hermes::HermesRuntime> runtime =
facebook::hermes::makeHermesRuntime(config.build());
facebook::hermes::HermesRuntime &hermesRuntimeRef = *runtime;
auto jsQueue = std::make_shared<JMessageQueueThread>(messageQueueThread);
auto adapter = std::make_unique<HermesExecutorRuntimeAdapter>(
std::move(runtime), hermesRuntimeRef, jsQueue);
std::shared_ptr<jsi::Runtime> animatedRuntime = adapter->runtime_;
facebook::hermes::inspector::chrome::enableDebugging(
std::move(adapter), "Reanimated runtime");
#endif
#elif JS_RUNTIME_V8
auto config = std::make_unique<rnv8::V8RuntimeConfig>();
config->enableInspector = false;
Expand Down
50 changes: 50 additions & 0 deletions android/src/main/cpp/headers/HermesExecutorRuntimeAdapter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#pragma once

#include <hermes/hermes.h>
#include <hermes/inspector/RuntimeAdapter.h>
#include <hermes/inspector/chrome/Registration.h>
#include <memory>

namespace reanimated {

using namespace facebook;
using namespace react;

class HermesExecutorRuntimeAdapter
: public facebook::hermes::inspector::RuntimeAdapter {
public:
HermesExecutorRuntimeAdapter(
std::shared_ptr<facebook::jsi::Runtime> runtime,
facebook::hermes::HermesRuntime &hermesRuntime,
std::shared_ptr<MessageQueueThread> thread)
: runtime_(runtime),
hermesRuntime_(hermesRuntime),
thread_(std::move(thread)) {}

virtual ~HermesExecutorRuntimeAdapter(){};

facebook::jsi::Runtime &getRuntime() override {
return *runtime_;
}

facebook::hermes::debugger::Debugger &getDebugger() override {
return hermesRuntime_.getDebugger();
}

void tickleJs() override {
// The queue will ensure that runtime_ is still valid when this
// gets invoked.
thread_->runOnQueue([&runtime = runtime_]() {
auto func =
runtime->global().getPropertyAsFunction(*runtime, "__tickleJs");
func.call(*runtime);
});
}

public:
std::shared_ptr<facebook::jsi::Runtime> runtime_;
facebook::hermes::HermesRuntime &hermesRuntime_;
std::shared_ptr<MessageQueueThread> thread_;
};

} // namespace reanimated
3 changes: 2 additions & 1 deletion android/src/main/cpp/headers/NativeProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ class NativeProxy : public jni::HybridClass<NativeProxy> {
#endif
#ifdef RCT_NEW_ARCH_ENABLED
void installJSIBindings(
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager);
jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
jni::alias_ref<JavaMessageQueueThread::javaobject> messageQueueThread);
void synchronouslyUpdateUIProps(
jsi::Runtime &rt,
Tag viewTag,
Expand Down
Binary file added hermes-inspector/arm64-v8a/libfolly_futures.so
Binary file not shown.
Binary file added hermes-inspector/arm64-v8a/libfolly_json.so
Binary file not shown.
Binary file not shown.
Binary file added hermes-inspector/armeabi-v7a/libfolly_futures.so
Binary file not shown.
Binary file added hermes-inspector/armeabi-v7a/libfolly_json.so
Binary file not shown.
Binary file not shown.
Binary file added hermes-inspector/x86/libfolly_futures.so
Binary file not shown.
Binary file added hermes-inspector/x86/libfolly_json.so
Binary file not shown.
Binary file added hermes-inspector/x86/libhermes-inspector.so
Binary file not shown.
Binary file added hermes-inspector/x86_64/libfolly_futures.so
Binary file not shown.
Binary file added hermes-inspector/x86_64/libfolly_json.so
Binary file not shown.
Binary file added hermes-inspector/x86_64/libhermes-inspector.so
Binary file not shown.