| #
b1cbccf5 |
| 01-Sep-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Refactor dynamic properties to work well with shared objects (#24206)
# Why
A follow-up to the https://github.com/expo/expo/pull/20608.
Allows shared objects to be passed as a fi
[core][Android] Refactor dynamic properties to work well with shared objects (#24206)
# Why
A follow-up to the https://github.com/expo/expo/pull/20608.
Allows shared objects to be passed as a first argument of the dynamic properties.
# Test Plan
- tests ✅
show more ...
|
| #
29e8b6f8 |
| 25-May-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Bind `JNIDeallocator` to the context (#22610)
# Why
Binds the `JNIDeallocator` to the current context.
# How
I've discovered that making `JNIDeallocator` static wasn't a go
[core][Android] Bind `JNIDeallocator` to the context (#22610)
# Why
Binds the `JNIDeallocator` to the current context.
# How
I've discovered that making `JNIDeallocator` static wasn't a good decision. This approach failed to function properly when we migrated to our API in the dev-launcher context. Whenever the user switches between the app and launcher, the app will crash since the dev-launcher remains in memory, but the app context's destruction causes all registered objects inside the `JNIDeallocator` to deallocate. Consequently, we're removing js objects associated with the dev-launcher context, even if it's still valid.
# Test Plan
- bare-expo with and without dev-client ✅
- unit tests ✅
show more ...
|
| #
695fef9b |
| 18-Apr-2023 |
Kudo Chien <[email protected]> |
[core] fix build error on rn 0.72 (#22170)
# Why
after react-native 0.72, the `LongLivedObjectCollection` constructor is removed and only available for the singleton: https://github.com/facebook/
[core] fix build error on rn 0.72 (#22170)
# Why
after react-native 0.72, the `LongLivedObjectCollection` constructor is removed and only available for the singleton: https://github.com/facebook/react-native/blob/9e5c963e2dbd90dbf2d260b67c2897e924be066e/packages/react-native/ReactCommon/react/bridging/LongLivedObject.h#L41-L44
the original solution from #19699 will have a build error on react-native 0.72
# How
rather than create a dedicated `LongLivedObjectCollection`, use the singleton `LongLivedObjectCollection` and do cleanup when `~ExpoModulesHostObject()`.
note: for react-native, the only call path to `LongLivedObjectCollection::get().clear()` is from TurboModuleBinding. in old architecture mode, react-native will not cleanup the `LongLivedObjectCollection`.
# Test Plan
follow #19699 to test the reloading
show more ...
|
| #
879827bb |
| 06-Apr-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Add functions converter (#21976)
# Why
Adds functions converter.
# How
- Adds a frontend and backend converter for js function type
- Adds ability to call those functions
[core][Android] Add functions converter (#21976)
# Why
Adds functions converter.
# How
- Adds a frontend and backend converter for js function type
- Adds ability to call those functions via Kotlin code
# Test Plan
- unit tests ✅
show more ...
|
| #
7cfebc52 |
| 31-Mar-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Improve memory consumption (#21906)
# Why
Improves memory consumption.
Adds a native destructor to the shared object.
# How
- Adds a native destructor to the shared objec
[core][Android] Improve memory consumption (#21906)
# Why
Improves memory consumption.
Adds a native destructor to the shared object.
# How
- Adds a native destructor to the shared object instance.
- Patched memory leak caused by unreleased global reference inside of the MethodMetadata class.
- Adds a global registry to force deallocation of JNI objects that holds references to jsi values when the app is reloaded.
- Adds a memory inspector to check which of JNI objects are still present in the memory.
# Test Plan
- unit tests ✅
- bare-expo with JSC and Hermes ✅
show more ...
|
| #
ecb7f347 |
| 29-Mar-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Introduce shared object (#21855)
# Why
This's a follow-up to https://github.com/expo/expo/pull/17514.
# How
- Added a shared object registry
- Run a native constructor if
[core][Android] Introduce shared object (#21855)
# Why
This's a follow-up to https://github.com/expo/expo/pull/17514.
# How
- Added a shared object registry
- Run a native constructor if present when creating a js class
- Added a shared object with its js representation to the registry
- Added a converter for shared object
# TODO
- [ ] call native destructor when class is deallocated
- [ ] use weak refs to hold js objects in the registry
# Test Plan
- unit tests ✅
show more ...
|
| #
732f0c04 |
| 27-Mar-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Add converter for `View` (#21816)
# Why
Adds a converter for the `View` type.
If you're using our view, it will be converted from the view instance. If not, you can always pass t
[core][Android] Add converter for `View` (#21816)
# Why
Adds a converter for the `View` type.
If you're using our view, it will be converted from the view instance. If not, you can always pass the view tag.
# How
- Added a front-end and back-end for view type.
- Allowed conversion from int or expo view object to the view's class.
# Usage
```tsx
class ExpoView {
nativeRef = React.createRef<NativeViewRef>();
function() {
return this.nativeRef.current?.function?.();
}
render() {
return <NativeView nativeRef={this.nativeRef} />
}
}
```
```kotlin
AsyncFunction("function") { view: ExpoView ->
// your code
}
```
# Test Plan
- unit tests ✅
- clear function on expo-image
show more ...
|
| #
cf4fff55 |
| 22-Mar-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Add class component (#21799)
# Why
Adds class component. This's a follow-up to https://github.com/expo/expo/pull/17412.
# How
Added a class component similar to the one on i
[core][Android] Add class component (#21799)
# Why
Adds class component. This's a follow-up to https://github.com/expo/expo/pull/17412.
# How
Added a class component similar to the one on iOS. It's not finished yet - this's just the first part.
# To do
- Rename `JavaScriptModuleObject` to something more descriptive. That class is no longer used just to declare modules
- Call constructor defined in the class component
- Pass `this` to sync/async functions.
- Add shared objects
# Test Plan
- unit tests ✅
show more ...
|
| #
b627df43 |
| 21-Mar-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Make module initialization lazy (#21774)
# Why
This approach guarantees that module functions and properties are only initialized upon user request. When the module is required by
[core][Android] Make module initialization lazy (#21774)
# Why
This approach guarantees that module functions and properties are only initialized upon user request. When the module is required by JavaScript, it does not automatically mean that all of its members will be added at that moment. Instead, they will be added at a later time, as needed.
# How
Added `LazyObject` abstraction as it was done on iOS.
Used an arbitrary js object instead of HostObject to define modules - it'll be handy in the future when I'll be adding shared classes.
# Test Plan
- unit tests ✅
- bare-expo ✅
show more ...
|
| #
cb63a94c |
| 20-Jan-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Returning object definitions from sync functions (#20864)
# Why
This a follow-up to the https://github.com/expo/expo/pull/20623.
# How
Adds an ability to return objects from
[core][Android] Returning object definitions from sync functions (#20864)
# Why
This a follow-up to the https://github.com/expo/expo/pull/20623.
# How
Adds an ability to return objects from the sync functions. I've reused code responsible for handling modules. It's not the cleanest solution, but I plan to refactor that later.
# Test Plan
- bare-expo with custom code ✅
- test suite ✅
- I've doubled checked if all objects are deallocated ✅
show more ...
|
| #
e95df2f4 |
| 11-Jan-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Add support for the `Long` type as function parameters (#20787)
# Why
Adds support for a `Long` type as a function parameter or return type.
It could be used in the https://gith
[core][Android] Add support for the `Long` type as function parameters (#20787)
# Why
Adds support for a `Long` type as a function parameter or return type.
It could be used in the https://github.com/expo/expo/pull/20784.
# How
- Added a CPP frontend converter.
- Added new Kotlin converter.
- Ensured that react-native can understand Long as a return value.
# Test Plan
- Unit tests ✅
show more ...
|
| #
11660804 |
| 10-Jan-2023 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Allow to skip trailing optional arguments (#20756)
# Why
This a follow-up to the https://github.com/expo/expo/pull/20234.
# How
- Added requiredArgumentsCount property to fu
[core][Android] Allow to skip trailing optional arguments (#20756)
# Why
This a follow-up to the https://github.com/expo/expo/pull/20234.
# How
- Added requiredArgumentsCount property to functions
- Throw InvalidArgsNumberException only when the number is less than the required count or greater than the total count
- Improved the exception reason to note how many arguments are required
- Added new unit test
# Test Plan
- Unit tests ✅
show more ...
|
| #
aaf1c10d |
| 26-Oct-2022 |
Kudo Chien <[email protected]> |
[core] Fix reload crash from accessing callback dangling pointers (#19699)
# Why
fix crash from accessing callback dangling pointers when reloading. this issue is found from sdk 47 versioned qa a
[core] Fix reload crash from accessing callback dangling pointers (#19699)
# Why
fix crash from accessing callback dangling pointers when reloading. this issue is found from sdk 47 versioned qa and possibly relates to https://github.com/expo/expo/issues/19167#issuecomment-1280747562
close ENG-6811
# How
the `RAIICallbackWrapperDestroyer` is designed to collect callbacks even they are not called. it will collect callbacks when the std::function is destroyed. from our MethodMetadata design, the std::function is collected by java GC. my hypothesis is that when reloading if js runtime is destroyed before java GC, the underlying jsi::Function will be a dangling pointer when the `RAIICallbackWrapperDestroyer` trying to collect the callback.
the pr tries to use a dedicated `LongLivedObjectCollection` for each module, and we can reset the collection when reloading.
# Test Plan
- tested on bare-expo
1. set `USE_DEV_CLIENT = true` in MainApplication
2. update App.js with [the content](https://github.com/Kudo/demo-expo-auth-session/blob/master/App.js)
3. keep reloading the app
- android unversioned expo go + NCL AsyncStorage reload
show more ...
|
| #
d8bd928c |
| 19-Oct-2022 |
Łukasz Kosmaty <[email protected]> |
[modules][Android] Fix exceptions handling in async functions (#19611)
# Why
Fixes test-suites:
```
- Calendar
- First run only: getEventsAsync() resolves to an array with an event of the
[modules][Android] Fix exceptions handling in async functions (#19611)
# Why
Fixes test-suites:
```
- Calendar
- First run only: getEventsAsync() resolves to an array with an event of the correct shape (expected 0 to be 1)
- Subsequent runs: deleteEventAsync(), deletes an event -expected false to be true
```
This is a follow-up to https://github.com/expo/expo/pull/19605.
# How
- Made sure that promises reject with a coded error instead of the plain js object.
- If something was thrown in the CPP code, the promise will also be rejected.
# Test Plan
- test-suite ✅
- manually test some corner case behavior ✅
show more ...
|
| #
e0f520f5 |
| 19-Oct-2022 |
Kudo Chien <[email protected]> |
[packages] Fix expo-modules-core androidTest (#19559)
# Why
follow up with #19411 to make expo-modules-core androidTest correctly
# How
those commented test cases break because we try to ca
[packages] Fix expo-modules-core androidTest (#19559)
# Why
follow up with #19411 to make expo-modules-core androidTest correctly
# How
those commented test cases break because we try to catch exceptions across shared library boundaries. there are a couple root causes actually:
## incompatible ndk versions
before ndk r23, the unwind library is libgcc, and after r23, the implementation is llvm libunwind. these two unwind implementation is incompatible. [email protected] and prebuilt react-native libs are all built from ndk r21. if we run the androidTest on m1 machine, we will use ndk r24 to build libraries. that's why we cannot catch fbjni exceptions in this situation. the pr tries to re-implement fbjni method calls and throw exceptions inline. that would make jni exceptions catchable.
other than that, when targeting prebuilt react-native, we should also use the same ndk r21 to build expo-modules-core. even we are on m1 machines.
## jscexecutor missing `_Unwind_Resume` symbol
the case happens when ndk r21 + jsc only, and this is also our ci android instrumented test environment. as [the ndk document](https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#unwinding) mentioned, for ndk r21, we should take care linking order. [this react-native fork patch](https://github.com/expo/react-native/commit/3986a385502df3eb207ca05f0b558171a600166c) addressed the issue.
if we test jsc on bare-expo, these test cases will still crash. i don't want to fix it or proposing the fix to upstream in the meantime. the latest react-native with AGP 7.3, the side-by-side ndk is already r23. since these are actually error cases, it's just not crash with correct stacktrace (not from expo-modules-core, but jscexecutor)
## c++_static runtime in expo-modules-core androidTest
always uses c++_shared runtime: the c++_static runtime doesn't well support the throw exceptions between shared library boundaries. we used c++_static because we want to fix the `et android-native-unit-tests -t instrumented` failures where the `./gradlew :expo-modules-core:connectedAndroidTest :expo-eas-client:connectedAndroidTest` will have duplicated fbjni.so build errors. this pr also reorganizes `et android-native-unit-tests` to build expo-modules-core androidTest exclusively.
# Test Plan
android instrumented ci passed
show more ...
|
| #
5e538c67 |
| 26-Sep-2022 |
Łukasz Kosmaty <[email protected]> |
[modules][Android] Simplify unpacking of method results (#19226)
# Why
Simplifies unpacking of method results.
Before, we used a similar approach to the RN when receiving results from Kotlin fun
[modules][Android] Simplify unpacking of method results (#19226)
# Why
Simplifies unpacking of method results.
Before, we used a similar approach to the RN when receiving results from Kotlin functions in Cpp. The result was obtained as a WritableArray, and then it was unpaced. That solution isn't ideal in the long term because we always return a single value.
# How
That change for the sync function was pretty straightforward. Right now, the Kotlin function body returns an arbitrary object which is later unpaced and converted to the jsi value.
Unfortunately, to simplify the flow of async functions, I've to introduce my implementation of the callback and the promise.
# Test Plan
- tests ✅
- bare-expo and NCL ✅
show more ...
|
| #
7ed3a4bf |
| 20-Sep-2022 |
Łukasz Kosmaty <[email protected]> |
[modules][Android] Remove temporary array when passing args to java (#19170)
# Why
Removes temporary array which was used to pass arguments from C++ to java.
By doing that I could reduce the num
[modules][Android] Remove temporary array when passing args to java (#19170)
# Why
Removes temporary array which was used to pass arguments from C++ to java.
By doing that I could reduce the number of global references that have to be created before calling the async function.
# Test Plan
- unit tests ✅
- bare-expo and NCL ✅
show more ...
|
| #
65a981dd |
| 22-Aug-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet API][Kotlin] Add frontend argument conversion (#18714)
# Why
Redesigns the argument conversions system.
# How
- Adds frontend converts (converters that work in the CPP and do the ear
[sweet API][Kotlin] Add frontend argument conversion (#18714)
# Why
Redesigns the argument conversions system.
# How
- Adds frontend converts (converters that work in the CPP and do the early conversion to the JNI types which can be passed to the Kotlin code).
- Adds a cache for frontend converters
- Adds an abstraction over the expected type to the CPP layer.
# Test Plan
- unit tests ✅
show more ...
|
| #
6f5b8a20 |
| 16-Aug-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet API][Kotlin] Pass more information about expected types to C++ (#18653)
# Why
Another step to stop using `folly` on Android.
Passes more information about expected types to C++ to make th
[sweet API][Kotlin] Pass more information about expected types to C++ (#18653)
# Why
Another step to stop using `folly` on Android.
Passes more information about expected types to C++ to make the conversion there smarter.
Note that this PR is just a first step in that direction and that information isn't used in many cases. However, I've made a simple optimization to create classes like Integer and Float directly in C++. Before, we alwayse converted numbers to Double and then we did a second conversion. As a result, we created more objects than needed.
# How
- Added a class representing information about the expected type
- Added simple Integer/Float optimization.
# Test Plan
- unit tests ✅
show more ...
|
| #
b7d1787d |
| 12-Aug-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet API] Cache PropNameID and js objects (#18579)
# Why
Adds a cache for prop name IDs and js objects like `Promise` or `CodedError`.
# How
- Added a cache registry
- Added missing tr
[sweet API] Cache PropNameID and js objects (#18579)
# Why
Adds a cache for prop name IDs and js objects like `Promise` or `CodedError`.
# How
- Added a cache registry
- Added missing try catch in the async function
# Test Plan
- unit tests ✅
show more ...
|
| #
ce6f2823 |
| 12-Aug-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet API] Throw missing exceptions (#18578)
# Why
I forgot to throw exceptions in two corner cases:
- when js type is not convertible to a Kotlin object - like Symbol
- when the js value has
[sweet API] Throw missing exceptions (#18578)
# Why
I forgot to throw exceptions in two corner cases:
- when js type is not convertible to a Kotlin object - like Symbol
- when the js value has an unknown type
# How
- Exported `UnknownException` to the C++.
- Add missing exceptions.
# Test Plan
- unit tests that will be added in a separate PR
show more ...
|
| #
05c5e37d |
| 29-Jul-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet API][Kotlin] Implement sweet typed arrays (#18379)
# Why
A follow-up to the https://github.com/expo/expo/pull/17667.
# How
- Reused some C++ utils to deal with typed arrays
- Made c
[sweet API][Kotlin] Implement sweet typed arrays (#18379)
# Why
A follow-up to the https://github.com/expo/expo/pull/17667.
# How
- Reused some C++ utils to deal with typed arrays
- Made classes for typed arrays on both sides: native and JS
- Added new converters to obtain typed arrays as function arguments
- Added tests
# Test Plan
- unit tests ✅
show more ...
|
| #
8bd57a9a |
| 27-Jul-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet API][Kotlin] Improve JSI error handling (#18259)
# Why
Improves error handling in functions that are called via JSI.
All API errors should look like this:
```
expo.modules.kotlin.jni.Pr
[sweet API][Kotlin] Improve JSI error handling (#18259)
# Why
Improves error handling in functions that are called via JSI.
All API errors should look like this:
```
expo.modules.kotlin.jni.PromiseException: Call to function 'f.TestModule' has been rejected.
→ Caused by: java.lang.IllegalStateException
```
# How
- Exported `CodedError` and use it to wrap the bare Kotlin exceptioThathat makes expressions like this `exception instanceOf CodedError` work.
- Added more `exceptionDecorator` blocks to add more context to the exceptions inside of exported functions.
- Mocked `CodedError` class in the test environment.
# Test Plan
- unit tests ✅
show more ...
|
| #
22d99763 |
| 12-Jul-2022 |
Łukasz Kosmaty <[email protected]> |
[core][Android] Fix crashes in async functions (#18206)
# Why
Closes ENG-5686.
A follow-up to the https://github.com/expo/expo/pull/18200.
# How
`local_ref` may not be valid when we capt
[core][Android] Fix crashes in async functions (#18206)
# Why
Closes ENG-5686.
A follow-up to the https://github.com/expo/expo/pull/18200.
# How
`local_ref` may not be valid when we capture them in the lambdas. Therefore, I migrate them to `global_ref`.
Why won't copying references work here?
That solution also is open to the same problem. JNI is constructed in a way where everything is bound to the current stack frame. So when the program leaves a frame where something was allocated, is allowed to clear that. By coping references, we do not ensure that the underlying object will outlive the current scope.
# Test Plan
- NCL ✅
- unit tests ✅
show more ...
|
| #
47a022e6 |
| 29-Jun-2022 |
Łukasz Kosmaty <[email protected]> |
[sweet][Kotlin] Add properties (#18015)
# Why
Adds support for properties.
A follow-up to the https://github.com/expo/expo/pull/17988.
# How
The code behind this future is very similar to
[sweet][Kotlin] Add properties (#18015)
# Why
Adds support for properties.
A follow-up to the https://github.com/expo/expo/pull/17988.
# How
The code behind this future is very similar to the current implementation of the sync functions. I've reused the whole calling solution from jsi functions.
# Test Plan
- unit tests ✅
show more ...
|