facebookresearch / playtorch

PlayTorch is a framework for rapidly creating mobile AI experiences.
https://playtorch.dev/
MIT License
830 stars 101 forks source link

React Native 0.71 compatibility is required #195

Open SomaKishimoto opened 1 year ago

SomaKishimoto commented 1 year ago

Version

0.2.4

Problem Area

react-native-pytorch-core (core package)

Steps to Reproduce

Create empty project

$ npx react-native init AwesomeTSProject
$ cd AwesomeTSProject 

Add PlayTorch to Existing App

$ yarn add react-native-pytorch-core

Additional steps on Android

Expected Results

I expect the build to complete and the Android emulator to launch, but the following error occurs.

BUILD FAILED in 1m 14s

Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build failed with an exception.

* Where:
Build file '/AwesomeTSProject/node_modules/react-native-pytorch-core/android/build.gradle' line: 132

* What went wrong:
A problem occurred evaluating project ':react-native-pytorch-core'.
> Expected directory '/AwesomeTSProject/android/../node_modules/react-native/android' to contain exactly one file, however, it contains no files.

This is likely related to a significant fix regarding RNGP that occurred in React Native 0.71.

I attempted to modify the CMake files of react-native-pytorch-core, taking reference from the React Native 0.71 compatibility implementation carried out by react-native-vision-camera. However, the build failed due to compatibility issues with the fbjni 0.2.2 version.

If there is anything I can do to help, please let me know.

Code example, screenshot, or link to repository

No response

raedle commented 1 year ago

@SomaKishimoto , yes, the recent changes in RN 0.71 break compatibility with third-party libraries including react-native-pytorch-core. I think looking at how react-native-vision-camera upgraded support to 0.71 is a good approach.

The fbjni 0.2.2 comes with PyTorch Mobile 1.12. What's the exact issue with fbjni?

SomaKishimoto commented 1 year ago

@raedle , I don't have knowledge about building React Native apps for Android, but could the inconsistency between FBJNI_VERSION and PlayTorch, as mentioned here, be an issue?

As a result of modifying the build-related files myself, the following error occurred.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.facebook.jni.CppException found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.CppSystemErrorException found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$1 found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$Destructor found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$DestructorList found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$DestructorStack found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$Terminus found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.HybridClassBase found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.HybridData found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.HybridData$Destructor found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.IteratorHelper found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.MapIteratorHelper found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.NativeRunnable found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.ThreadScopeSupport found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.UnknownCppException found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.annotations.DoNotStrip found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

The patch file is as attached. However, please be careful that the version of react-native-pytorch-core is 0.2.1. react-native-pytorch-core+0.2.1.patch

Sorry for that I can only provide this data due to other issue. I'm ready to provide the bug data of version 0.2.4 if needed.

fencer-yd commented 1 year ago

@SomaKishimoto , yes, the recent changes in RN 0.71 break compatibility with third-party libraries including react-native-pytorch-core. I think looking at how react-native-vision-camera upgraded support to 0.71 is a good approach.

The fbjni 0.2.2 comes with PyTorch Mobile 1.12. What's the exact issue with fbjni?

After I upgraded expo to version 48, I encountered an incompatibility problem with the fbjni version. Is this problem solved now?

fencer-yd commented 1 year ago

Has the compatibility problem of the rn71 version been resolved now? This question is very important to me.

SomaKishimoto commented 1 year ago

@fencer-yd , it's not solved yet. I will try asking the PyTorch community about the fbjni version.

SomaKishimoto commented 1 year ago

@fencer-yd , I asked about that problem on the PyTorch forum. I hope this will be the key to solving the problem.

rhelck commented 1 year ago

Had the exact same issue with expo app. Any known fixes or updates?

fencer-yd commented 1 year ago

Is this problem solved now?

heejae-kwon commented 1 year ago

When can I know this problem is solved?

cauyyl commented 11 months ago

@raedle , I don't have knowledge about building React Native apps for Android, but could the inconsistency between FBJNI_VERSION and PlayTorch, as mentioned here, be an issue?

As a result of modifying the build-related files myself, the following error occurred.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class com.facebook.jni.CppException found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.CppSystemErrorException found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$1 found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$Destructor found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$DestructorList found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$DestructorStack found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.DestructorThread$Terminus found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.HybridClassBase found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.HybridData found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.HybridData$Destructor found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.IteratorHelper found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.MapIteratorHelper found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.NativeRunnable found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.ThreadScopeSupport found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.UnknownCppException found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)
     Duplicate class com.facebook.jni.annotations.DoNotStrip found in modules jetified-fbjni-0.3.0-runtime (com.facebook.fbjni:fbjni:0.3.0) and jetified-fbjni-java-only-0.2 (com.facebook.fbjni:fbjni-java-only:0.2.2)

     Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
java.lang.StackOverflowError (no error message)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

The patch file is as attached. However, please be careful that the version of react-native-pytorch-core is 0.2.1. react-native-pytorch-core+0.2.1.patch

Sorry for that I can only provide this data due to other issue. I'm ready to provide the bug data of version 0.2.4 if needed.

when i add patch to my pure react native 0.72.4project, i am faceing [CXX1101] NDK at /Users/bishen/Library/Android/sdk/ndk/23.1.7779620 did not have a source.properties file, i have found a similar issue in react-native-reanimated here. But i have no idea to solve this error.