Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Nov 25, 2021
1 parent 23260f4 commit b0aa0d5
Show file tree
Hide file tree
Showing 35 changed files with 2,819 additions and 1,866 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
10.20.0-alpha.2 Release notes (2021-??-??)
=============================================================
NOTE: DO NOT USE THIS RELEASE IN PRODUCTION!
NOTE: This is an early (alpha) release with Hermes/JSI support: We expect crashes and bugs.

### Enhancements
* None.

### Fixed
* Hot reloading on Android no longer crash the app.

### Compatibility
* MongoDB Realm Cloud.
* Realm Studio v11.0.0.
* APIs are backwards compatible with all previous releases of Realm JavaScript in the 10.5.x series.
* File format: generates Realms with format v22 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

### Internal
* Restructured C++ namespaces and files to reflect that we support JSI, not just Hermes.

10.20.0-alpha.1 Release notes (2021-9-22)
=============================================================
NOTE: DO NOT USE THIS RELEASE IN PRODUCTION!
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ ENV LD_LIBRARY_PATH /opt/rh/httpd24/root/usr/lib64:/opt/rh/python27/root/usr/lib

# Ensure a new enough version of CMake is available.
RUN cd /opt \
&& curl -O -J https://cmake.org/files/v3.15/cmake-3.15.2-Linux-x86_64.tar.gz \
&& tar zxf cmake-3.15.2-Linux-x86_64.tar.gz
ENV PATH "/opt/cmake-3.15.2-Linux-x86_64/bin:$PATH"
&& curl -O -J https://cmake.org/files/v3.21/cmake-3.21.3-linux-x86_64.tar.gz \
&& tar zxf cmake-3.21.3-linux-x86_64.tar.gz
ENV PATH "/opt/cmake-3.21.3-linux-x86_64/bin/:$PATH"
12 changes: 6 additions & 6 deletions Dockerfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ RUN echo 'Installing Android SDK' && \
"platform-tools" \
"build-tools;${ANDROID_BUILD_TOOLS_VERSION}" \
"platforms;android-26" \
"cmake;3.10.2.4988404"\
"cmake;3.18.1"\
"system-images;android-29;default;x86" && \
\
echo 'Installing Android NDK' && \
Expand All @@ -75,8 +75,8 @@ RUN mkdir -p $NVM_DIR \
&& chmod a+rwX -R $NVM_DIR

# Ensure a new enough version of CMake is available.
RUN mkdir -p /home/jenkins/cmake && \
cd /home/jenkins/cmake && \
curl -O -J https://cmake.org/files/v3.17/cmake-3.17.5-Linux-x86_64.tar.gz &&\
tar zxf cmake-3.17.5-Linux-x86_64.tar.gz
ENV PATH "/home/jenkins/cmake/cmake-3.17.5-Linux-x86_64/bin:$PATH"
RUN mkdir -p /home/jenkins/cmake \
&& cd /home/jenkins/cmake \
&& curl -O -J https://cmake.org/files/v3.21/cmake-3.21.3-linux-x86_64.tar.gz \
&& tar zxf cmake-3.21.3-linux-x86_64.tar.gz
ENV PATH "/home/jenkins/cmake/cmake-3.21.3-linux-x86_64/bin/:$PATH"
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ def buildWindows(nodeVersion, arch) {

def buildiOS() {
return buildMacOS {
sh 'npm ci'
sh './scripts/build-iOS.sh -c Release'
dir('react-native/ios') {
// Uncomment this when testing build changes if you want to be able to download pre-built artifacts from Jenkins.
Expand Down
2 changes: 1 addition & 1 deletion RealmJS.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Pod::Spec.new do |s|
'HEADER_SEARCH_PATHS' => [
'"$(PODS_TARGET_SRCROOT)/react-native/ios/RealmReact/"',
'"$(PODS_TARGET_SRCROOT)/src/"',
'"$(PODS_TARGET_SRCROOT)/src/hermes/"',
'"$(PODS_TARGET_SRCROOT)/src/jsi/"',
'"$(PODS_ROOT)/Headers/Public/React-Core/"'
#"'#{app_path}/ios/Pods/Headers/Public/React-Core'" # Use this line instead of 👆 while linting
].join(' ')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
3B8FAB7E5A5B93DA46B76C0E /* libPods-RealmReactNativeTests-RealmReactNativeTestsTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 89CF544B997845C9F64DE611 /* libPods-RealmReactNativeTests-RealmReactNativeTestsTests.a */; };
680A7E1CDDE42AF42D31E178 /* libPods-RealmReactNativeTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 94940631F74C922FA25416F2 /* libPods-RealmReactNativeTests.a */; };
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
F7BEFC8033C76CBEC124044B /* libPods-RealmReactNativeTests-RealmReactNativeTestsTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA2A032A4CADCC321F5F8C8B /* libPods-RealmReactNativeTests-RealmReactNativeTestsTests.a */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -107,6 +108,18 @@
name = Frameworks;
sourceTree = "<group>";
};
593EEEBE2C9A1FF5FB7C532F /* Pods */ = {
isa = PBXGroup;
children = (
AD65688DEA7C8A86B7E48D75 /* Pods-RealmReactNativeTests.debug.xcconfig */,
DC1D2F0AC1905A586449CDBA /* Pods-RealmReactNativeTests.release.xcconfig */,
FCB75108123041D5F45607F2 /* Pods-RealmReactNativeTests-RealmReactNativeTestsTests.debug.xcconfig */,
2600807299414367FDAC3C3E /* Pods-RealmReactNativeTests-RealmReactNativeTestsTests.release.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,21 @@ public RealmReactModule(ReactApplicationContext reactContext) {
setDefaultRealmFileDirectory(fileDir, assetManager);

// Get the javascript runtime and install our native module with it

// TODO: Update this to use reactContext.getRuntimeExecutor() instead (since this is calling a deprecated method underneath)
// Using the RuntimeExecutor however, requires that we link our native module against fbjni.

JavaScriptContextHolder jsContext = reactContext.getJavaScriptContextHolder();
synchronized(jsContext) {
install(jsContext.get());
}
}

@Override
public void invalidate() {
invalidateCaches();
}

@Override
public String getName() {
return NAME;
Expand All @@ -89,4 +98,6 @@ public Map<String, Object> getConstants() {
private native void setDefaultRealmFileDirectory(String fileDir, AssetManager assets);

private native void install(long runtimePointer);

private native void invalidateCaches();
}
6 changes: 3 additions & 3 deletions react-native/ios/RealmReact/RealmReact.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import "RealmReact.h"
#import "RealmAnalytics.h"

#import <realm-js-ios/hermes_init.h>
#import <realm-js-ios/jsi_init.h>

#import <React/RCTBridge+Private.h>
#import <jsi/jsi.h>
Expand Down Expand Up @@ -94,7 +94,7 @@ - (void)removeListenerForEvent:(NSString *)eventName handler:(RealmReactEventHan
}

- (void)invalidate {
realm_hermes_invalidate_caches();
realm_jsi_invalidate_caches();
}

- (void)dealloc {
Expand Down Expand Up @@ -130,7 +130,7 @@ - (void)setBridge:(RCTBridge *)bridge {

auto& rt = *static_cast<facebook::jsi::Runtime*>(bridge.runtime);
auto exports = jsi::Object(rt);
realm_hermes_init(rt, exports);
realm_jsi_init(rt, exports);
} queue:RCTJSThread];
}
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ fi
DESTINATIONS=()
LIBRARIES=()
BUILD_LIB_CMDS=()

for platform in "${PLATFORMS[@]}"; do
case "$platform" in
ios)
Expand Down Expand Up @@ -107,7 +108,7 @@ done

rm -rf _include
mkdir -p _include/realm-js-ios
cp "$PROJECT_ROOT"/src/hermes/hermes_init.h _include/realm-js-ios/
cp "$PROJECT_ROOT"/src/jsi/jsi_init.h _include/realm-js-ios/

rm -rf ../realm-js-ios.xcframework
xcodebuild -create-xcframework \
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ target_include_directories(realm-js-shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if(DEFINED CMAKE_JS_VERSION)
add_subdirectory(node)
elseif(ANDROID)
add_subdirectory(hermes)
add_subdirectory(jsi)
add_subdirectory(android)
elseif(CMAKE_SYSTEM_NAME STREQUAL iOS)
add_subdirectory(hermes)
add_subdirectory(jsi)
add_subdirectory(ios)
endif()
9 changes: 8 additions & 1 deletion src/android/io_realm_react_RealmReactModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "jni_utils.hpp"
#include "platform.hpp"
#include <hermes/hermes_init.h>
#include <jsi/jsi_init.h>

#include "io_realm_react_RealmReactModule.h"

Expand Down Expand Up @@ -100,6 +101,12 @@ JNIEXPORT void JNICALL Java_io_realm_react_RealmReactModule_install(
"Building an exports object");
auto exports = jsi::Object(*runtime);
__android_log_print(ANDROID_LOG_VERBOSE, "JSRealm", "Initializing ...");
realm_hermes_init(*runtime, exports);
realm_jsi_init(*runtime, exports);
}
}

JNIEXPORT void JNICALL
Java_io_realm_react_RealmReactModule_invalidateCaches(JNIEnv *, jclass) {
__android_log_print(ANDROID_LOG_VERBOSE, "JSRealm", "invalidateCaches");
realm_jsi_invalidate_caches();
}
8 changes: 8 additions & 0 deletions src/android/io_realm_react_RealmReactModule.h

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

2 changes: 1 addition & 1 deletion src/hermes/CMakeLists.txt → src/jsi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set(REACT_NATIVE_ROOT_DIR "${PACKAGE_ROOT_DIR}/node_modules/react-native")
set(JSI_HEADER_DIR "${REACT_NATIVE_ROOT_DIR}/ReactCommon/jsi")

add_library(realm-js-hermes OBJECT
hermes_init.cpp
jsi_init.cpp
)

target_include_directories(realm-js-hermes PRIVATE ${JSI_HEADER_DIR})
Expand Down
Loading

0 comments on commit b0aa0d5

Please sign in to comment.