History log of /expo/packages/expo-modules-core/android/src/main/cpp/JavaScriptModuleObject.h (Results 1 – 16 of 16)
Revision Date Author Comments
# 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 ...


# 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 ...


# 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 ...


# 3852c14f 23-Mar-2023 Łukasz Kosmaty <[email protected]>

[core][Android] Native functions on native component instances (#21809)

# Why

This's a follow-up to the https://github.com/expo/expo/pull/21746.
Closes ENG-6234.

# How

- Added async functi

[core][Android] Native functions on native component instances (#21809)

# Why

This's a follow-up to the https://github.com/expo/expo/pull/21746.
Closes ENG-6234.

# How

- Added async functions definition to the `ViewDefinitionBuiler`
- Exported information about those functions to js
- Exported `ViewPrototype` from the module object

# Test Plan

- unit tests ✅
- add a function that clears the content of the image to the `expo-image` (will be added in a separate PR)

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 ...


# 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 ...


# 33ae33ea 11-Oct-2022 Łukasz Kosmaty <[email protected]>

[modules][Android] Fix `JSCRuntime destroyed with a dangling API object` (#19487)

# Why

Closes https://github.com/expo/expo/issues/19221.

# How

In the current memory modal, all of our JSI r

[modules][Android] Fix `JSCRuntime destroyed with a dangling API object` (#19487)

# Why

Closes https://github.com/expo/expo/issues/19221.

# How

In the current memory modal, all of our JSI references are cleared when GC runs through java unused objects. It turns out that is not the best flow, because JSC has an assertion that checks if all references were cleared. So we have to remove dangling references before the JSC runtime fully deallocates.

# Test Plan

- bare-expo with JSC and Heremes ✅

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 ...


# 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 ...


# e6ec10db 28-Jun-2022 Łukasz Kosmaty <[email protected]>

[sweet][Kotlin] Use `unordered_map` instead of `map` (#17990)

# Why

Starts using `unordered_map` instead of `map` to cached data.
It isn't a huge change, but in my opinion, the `unordered_map`

[sweet][Kotlin] Use `unordered_map` instead of `map` (#17990)

# Why

Starts using `unordered_map` instead of `map` to cached data.
It isn't a huge change, but in my opinion, the `unordered_map` (hash map) fits better when we just want to cache data ��

# Test Plan

- unit tests ✅

show more ...


# 9ebf31e6 27-Jun-2022 Łukasz Kosmaty <[email protected]>

[sweet API][Kotlin] Move preliminary args conversion to Cpp (#17944)

# Why

Moves preliminary args conversion to Cpp.
Needs to work:
- https://github.com/expo/expo/pull/17938
- https://github.c

[sweet API][Kotlin] Move preliminary args conversion to Cpp (#17944)

# Why

Moves preliminary args conversion to Cpp.
Needs to work:
- https://github.com/expo/expo/pull/17938
- https://github.com/expo/expo/pull/17940
- https://github.com/expo/expo/pull/17942
- https://github.com/expo/expo/pull/17943

# How

- Created the `CachedReferencesRegistry` that stores references to often used Java classes. In the future, we may want to store also jsi object there too.
- Reduced the usage of `folly`.
- Added unit tests.

# Benefits

- You can obtain `JavaScriptValue` and `JavaScriptObject` as a function argument

# Test Plan

- unit tests (that covers sync and async functions call too) ✅

show more ...


# a764be12 13-Jun-2022 Łukasz Kosmaty <[email protected]>

[sweet API][Kotlin] Export constants via JSI (#17834)

# Why

Exports constatns via JSI.

Resolves ENG-5251

# How

One of the essential functionalities that had to be added before the RC re

[sweet API][Kotlin] Export constants via JSI (#17834)

# Why

Exports constatns via JSI.

Resolves ENG-5251

# How

One of the essential functionalities that had to be added before the RC release.
> Note:
The way of converting Java constants to a jsi object isn't final and will be replaced in the future by our custom converter.

# Test Plan

- unit tests ✅

show more ...


# 64f5c95f 17-May-2022 Łukasz Kosmaty <[email protected]>

[module-core][Kotlin] Add basic support for sync function (#16977)

# Why

Closes ENG-4608.
Adds basic support for sync function.

# How

- Created ExpoModulesHostObject that installs into the

[module-core][Kotlin] Add basic support for sync function (#16977)

# Why

Closes ENG-4608.
Adds basic support for sync function.

# How

- Created ExpoModulesHostObject that installs into the runtime as `global.ExpoModules`. A host object is an abstract object where we can define our property getter, allowing us to create JS object for each module lazily.
- Added `isAsync` property to sweet functions and `runSynchronously()` modifier - that will be changed in the future.
- Created `JavaScriptModuleObject` that represents a module in the JS world. It has a map of methods with a cached body.
- All the communication goes via two kotlin methods - `getJavaScriptModuleObject` (which returns a hybrid representation of the module) and `callMethodSync` (which is calling correct implementation). Right now, I'm not using lambdas to pass Kotlin functions into CPP, because I don't see any reason why should I.

# Test Plan

- tested with bare-expo ✅

show more ...