Skip to content

Comments

Autoinstall Android#3005

Merged
piaskowyk merged 3 commits intomainfrom
jgonet/autoinstall
Feb 21, 2022
Merged

Autoinstall Android#3005
piaskowyk merged 3 commits intomainfrom
jgonet/autoinstall

Conversation

@jgonet
Copy link
Member

@jgonet jgonet commented Feb 16, 2022

Description

This patch removes setup instructions for Android. iOS is in progress (there's some complexity with bridge init lifecycle - Reanimated replaces native RN modules).

Changes

  • Move initialization from ReanimatedJSIModulePackage to ReanimatedModule by utilizing @ReactMethod(isBlockingSynchronousMethod = true) annotation.

Test code and steps to reproduce

I tested it on the example app but maybe it's worth building the package and checking on the freshly generated app.

Copy link
Member

@kmagiera kmagiera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 Left a couple of comments. Would be good to test jest environment with these changes as well

@jgonet
Copy link
Member Author

jgonet commented Feb 17, 2022

I can confirm that yarn test passes.

public class ReanimatedJSIModulePackage implements JSIModulePackage {

@Override
public List<JSIModuleSpec> getJSIModules(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that I think of now is that we can actually make the transition less of a pain and keep this class with empty implementation + some warning message. This way people won't get compile errors after upgrading. We can show a yellow box for them to update MainApplication.java

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added @Deprecation annotation and Log.w(). LogBox doesn't have a native interface so we'd need to set some global variable or emit an event which isn't ideal.

@renchap
Copy link

renchap commented Mar 11, 2022

Is this supposed to work?
I am upgrading our app to the latest 0.68-rc2 RN version and I replaced the dependancy in package.json to use this repo's main branch, but I can not get it working:

> Task :app:compileDebugJavaWithJavac FAILED
/Users/renchap/dev/notos/packages/mobile/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:43: error: cannot find symbol
import com.swmansion.reanimated.ReanimatedPackage;
                               ^
  symbol:   class ReanimatedPackage
  location: package com.swmansion.reanimated
/Users/renchap/dev/notos/packages/mobile/android/app/build/generated/rncli/src/main/java/com/facebook/react/PackageList.java:111: error: cannot find symbol
      new ReanimatedPackage(),
          ^
  symbol:   class ReanimatedPackage
  location: class PackageList

I cleaned all Gradle caches and tried to reinstall multiple times, but it looks like Reanimated it not built, or not found

@Kudo Kudo mentioned this pull request Mar 29, 2022
6 tasks
piaskowyk pushed a commit that referenced this pull request Apr 1, 2022
## Description

with #3005, we don't need the expo adapter to install JSI bindings. by removing the adapter, this pr will also fix #3084 and fix #3021

## Changes

remove expo adapter

## Test code and steps to reproduce

1. `$ createNPMPackage.sh`
2. create an expo sdk44 project, `yarn add file:/path/to/react-native-reanimated-2.5.0.tgz` and test launching.
2. create an react-native 0.67 project, `yarn add file:/path/to/react-native-reanimated-2.5.0.tgz` and test launching.

## Checklist

- [ ] Included code example that can be used to test this change
- [ ] Updated TS types
- [ ] Added TS types tests
- [ ] Added unit / integration tests
- [ ] Updated documentation
- [ ] Ensured that CI passes
@pjc0247 pjc0247 mentioned this pull request Apr 25, 2022
3 tasks
@ugurdalkiran
Copy link

@renchap i am getting the same issue. did you solve it?

@renchap
Copy link

renchap commented Nov 11, 2022

@ugurdalkiran I did solve it, but I dont remember how. Probably either:

  • upgrading to a latest RN and/or reanimated version (I am running RN 0.70 and reanimated 3.0.0-rc4)j
  • by re-reading the updated installation guide and ensuring I did not miss anything

tomekzaw added a commit that referenced this pull request Jun 7, 2023
## Summary

This PR bumps react-native to 0.72.0-rc.5 and slightly changes
initialization path on iOS (Paper) due to recent changes in the
framework (facebook/react-native#37523).

Fixes #4521. Continues #3005.

On iOS, Reanimated needs to overwrite two React internal modules:
* `RCTUIManager` &rarr; `REAUIManager` to intercept `manageChildren`
calls in order to observe React tree changes
([here](https://github.com/software-mansion/react-native-reanimated/blob/main/ios/LayoutReanimation/REAUIManager.mm))
* `RCTEventDispatcher` &rarr; `REAEventDispatcher` to intercept events
in the native code while still on the UI thread
([here](https://github.com/software-mansion/react-native-reanimated/blob/663ee74925cafa4a1a802f4722466dc02cb1760f/ios/REAEventDispatcher.m#L9-L10))

The rest of the initialization (injecting JSI bindings) can be safely
done in `installTurboModule` method, as we already do on Android and
iOS/Fabric.

Previously, this was done using categories (see
[`UIResponder+Reanimated.mm`](https://github.com/software-mansion/react-native-reanimated/blob/663ee74925cafa4a1a802f4722466dc02cb1760f/ios/native/UIResponder%2BReanimated.mm#L19-L30)),
in particular by overwriting `jsExecutorFactoryForBridge:` method which
is called during initialization. However, since 0.72.0-rc.4, this method
is already implemented in `RCTAppDelegate` so the trick does no longer
work, making the app fail with the following error "[Reanimated] The
native part of Reanimated doesn't seem to be initialized".

In this PR, I've used a category to overwrite another method
`extraModulesForBridge` which swizzles the implementation of
`jsExecutorFactoryForBridge` method and runs `REAInitializer` before the
original call.

As suggested by @kmagiera, alternatively we could just swizzle the
methods of `RCTUIManager` and `RCTEventDispatcher`.

## TODO

- [x] Restore support for 0.71 and below with #ifdefs

## Test plan

<!-- Provide a minimal but complete code snippet that can be used to
test out this change along with instructions how to run it and a
description of the expected behavior. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants