Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise out android-jsc issues in current master #22274

Closed
3 tasks done
Kudo opened this issue Nov 14, 2018 · 18 comments
Closed
3 tasks done

Raise out android-jsc issues in current master #22274

Kudo opened this issue Nov 14, 2018 · 18 comments
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@Kudo
Copy link
Contributor

Kudo commented Nov 14, 2018

Environment

React Native Environment Info:
System:
OS: macOS 10.14
CPU: x64 Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
Memory: 4.55 GB / 16.00 GB
Shell: 5.6.2 - /usr/local/bin/zsh
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.12.1 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
Build Tools: 21.1.2, 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 27.0.0, 27.0.1, 27.0.3, 28.0.0, 28.0.2, 28.0.3
API Levels: 17, 19, 22, 23, 25, 26, 27, 28
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.1/10B61 - /usr/bin/xcodebuild

Description

There are two issues for current approach of android-jsc adoption. Related to #18754.

  1. The minSdkVersion is implicitly changed to API 21.
    Running on Android < 5 will have launch crash.
    Since this android-jsc is built by NDK APP_PLATFORM 21,
    there are some unresolved symbols for Android < 5 devices. E.g. sigemptyset

  2. Build break once published out as AAR format.
    Currently the dependency of android-jsc is added by this line.
    compile project(':android-jsc')
    For Android library as AAR, this dependency just tells the integrated application there is a 'android-jsc' package need to further resolved. Neither jar nor *.so will be packed into react-native AAR.
    User does not have android-jsc in their gradle projects, the dependency not found problem will cause build break.
    (Google plans to officially support fat aar in gradle plugin, which is fulfill this case to bundle all things in one AAR, but not ready yet.)

Reproducible Demo

  1. The minSdkVersion is implicitly changed to API 21.
    Simply do ./gradlew :RNTester:android:app:installDebug on Android 4.1 emulator and check adb log for missing symbols.
    E.g.
         AndroidRuntime  E  FATAL EXCEPTION: create_react_context
                         E  java.lang.ExceptionInInitializerError
                         E      at com.facebook.react.jscexecutor.JSCExecutorFactory.create(JSCExecutorFactory.java:25)
                         E      at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944)
                         E      at java.lang.Thread.run(Thread.java:856)
                         E  Caused by: java.lang.UnsatisfiedLinkError: couldn't find DSO to load: libreactnativejni.so caused by: couldn't find DSO to load: libjsc.so caused by: Can
                            not load library: reloc_library[1306]:  1138 cannot locate 'sigemptyset'...
                         E      at com.facebook.soloader.SoLoader.doLoadLibraryBySoName(SoLoader.java:703)
                         E      at com.facebook.soloader.SoLoader.loadLibraryBySoName(SoLoader.java:564)
                         E      at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:500)
                         E      at com.facebook.soloader.SoLoader.loadLibrary(SoLoader.java:455)
                         E      at com.facebook.react.bridge.ReactBridge.staticInit(ReactBridge.java:30)
                         E      at com.facebook.react.bridge.NativeMap.<clinit>(NativeMap.java:19)
                         E      ... 3 more
  1. For RNTester to use AAR dependency.
    1. Apply this patch. Assume your $HOME is /Users/foo.
    2. Build AAR and deployed at mavenLocal: ./gradlew :ReactAndroid:uploadArchives
    3. Build RNTester: ./gradlew :RNTester:android:app:assembleDebug
    4. This is the build error:
FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':RNTester:android:app:debugCompileClasspath'.
> Could not find react-native:android-jsc:unspecified.
@kelset kelset added the Platform: Android Android applications. label Nov 14, 2018
@react-native-bot

This comment has been minimized.

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. 📋No Template labels Nov 14, 2018
@kelset kelset reopened this Nov 14, 2018
@gengjiawen
Copy link
Contributor

I will take a look at RNTester build tormorrow, I have tested it, maybe I miss something.

@gengjiawen
Copy link
Contributor

For the first, the miniSDK it's still 16, I am using a fork of buck when build it.

@Kudo
Copy link
Contributor Author

Kudo commented Nov 15, 2018

@gengjiawen The problem of minSDK is caused by this line in fact.
app_platform = android-21
If not specified this, BUCK will by default use android-16.

For APP_PLATFORM, there is some reference on stackoverflow.
Even minSdkVersion was not changed, the actual expected API need to reference APP_PLATFORM.
During apk installation, Android does not have information about what APP_PLATFORM specified.
It will crash when there are unresolved symbols at runtime.
That's why I said the minSdkVersion is implicitly changed to 21.

@gengjiawen
Copy link
Contributor

Yes, I know that. I only change app_platform when I bundle 64bit.

@hey99xx
Copy link

hey99xx commented Nov 15, 2018

So then did you use facebookarchive/android-jsc#30 to create the android-jsc.aar that you checked into this project, or you only used to create 64bit .so files, then created the .aar by hand by adding all of regular 32bit .so files and the new 64bit .so files?

@gengjiawen
Copy link
Contributor

I put the buck patch link in pr description, and want to update the buck version later, but buck team seems not care this issue.

@Kudo
Copy link
Contributor Author

Kudo commented Nov 15, 2018

@gengjiawen FYI, BUCK support an option app_platform_per_cpu_abi.
This is from facebook/buck#1889 which is to fix your opened issue.
And that's I used in https://github.com/Kudo/android-jsc/blob/clang/.buckconfig#L3 in fact.

@gengjiawen
Copy link
Contributor

gengjiawen commented Nov 15, 2018

@Kudo Thanks. So the master branch actually won't crash on pre-sdk-21 device.
But I am intended to replace it with jsc-android-buildscript after react-native-community/jsc-android-buildscripts#66 got merged.

cc @DanielZlotin @dulmandakh @kelset

@Kudo
Copy link
Contributor Author

Kudo commented Nov 15, 2018

@gengjiawen How did you test that master branch code will not crash on pre-sdk-21 devices?
Because I could reproduced the problem on Android 4.1 emulator.

One way to check the unresolved symbols:

  1. Dump undefined symbols from your *.so (unzip from android-jsc.aar)
    ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-nm -D -u jni/armeabi-v7a/libjsc.so
  2. Dump libc.so symbols
    ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-nm -D ndk-bundle/platforms/android-16/arch-arm/usr/lib/libc.so
  3. Check if libjsc.so undefined symbols exists in libc.so or not. And there are actually some undefined symbols. E.g. sigemptyset or log2.
    (Note that there are a few symbols not expected in libc.so, such as C++ symbols. However, you can differentiate them as C++ symbol name are mangled.)

Also agreed to migrate jsc-android-buildscript. Maybe #22263 (comment) will fix the issue right now.

@gengjiawen
Copy link
Contributor

gengjiawen commented Nov 15, 2018

To keep consistency, I keep the original libjsc.so from the old jcenter aar for armeabi and x86 (see original pr #18754 (comment)). I tested it on a x86 4.4 emulator.

@Kudo
Copy link
Contributor Author

Kudo commented Nov 15, 2018

Could you check your libjsc.so MD5 checksum?
From my environment:
libjsc.so from master branch android-jsc.aar

MD5 (master/jni/armeabi-v7a/libjsc.so) = f6cde1058f849907a6bb79746c8c5d59
MD5 (master/jni/x86/libjsc.so) = 0f088f4e8396cb80bb3f8571a3d7e2f3

jcenter JSC download from https://bintray.com/react-native/android/download_file?file_path=org%2Fwebkit%2Fandroid-jsc%2Fr174650%2Fandroid-jsc-r174650.aar

MD5 (jcenter/jni/armeabi-v7a/libjsc.so) = f0fee7b93142ca1d9eb08f12538921a3
MD5 (jcenter/jni/x86/libjsc.so) = 0eff645ce7406c8d4142716d23fd4708

Most of unresolved symbols are implemented after API 18, so please ensure to test on Android 4.1 environment.

@gengjiawen
Copy link
Contributor

gengjiawen commented Nov 15, 2018

@Kudo Yes, l checked again the hash on macOS, looks you result is right. The md5 I tested is on windows. Guess I maybe miss something.

@gengjiawen
Copy link
Contributor

Replace the so with the old one or just upgrade to new jsc ? @DanielZlotin looks like testing it.

@Kudo
Copy link
Contributor Author

Kudo commented Nov 15, 2018

OK, I'll wait for a while.

@grabbou
Copy link
Contributor

grabbou commented Nov 17, 2018

Another way to try reproducing the #2 case is to run:

npm pack
react-native init --version /absolute/path/to/archive/react-native.tgz

and then, try running the Android app. This is how I stumbled upon this issue while initing an app with master of React Native.

@gengjiawen
Copy link
Contributor

Related pr: #22293.

@react-native-bot

This comment has been minimized.

@gengjiawen gengjiawen reopened this Nov 21, 2018
@kelset kelset added Core Team and removed Ran Commands One of our bots successfully processed a command. 📋No Template labels Nov 21, 2018
grabbou pushed a commit that referenced this issue Nov 22, 2018
Summary:
My silly mistake when tinkering with the jsc lib. Also you have this patch first #22295.
Kudo plz review.

![image](https://user-images.githubusercontent.com/3759816/48561684-758f6f00-e92b-11e8-905b-e394f72349f7.png)
Pull Request resolved: #22293

Differential Revision: D13153931

Pulled By: hramos

fbshipit-source-id: 8a6efa0cd8abbff359f082d5ea7713933b6e7ac6
t-nanava pushed a commit to microsoft/react-native-macos that referenced this issue Jun 17, 2019
Summary:
My silly mistake when tinkering with the jsc lib. Also you have this patch first facebook#22295.
Kudo plz review.

![image](https://user-images.githubusercontent.com/3759816/48561684-758f6f00-e92b-11e8-905b-e394f72349f7.png)
Pull Request resolved: facebook#22293

Differential Revision: D13153931

Pulled By: hramos

fbshipit-source-id: 8a6efa0cd8abbff359f082d5ea7713933b6e7ac6
t-nanava pushed a commit to microsoft/react-native-macos that referenced this issue Jun 17, 2019
Summary:
My silly mistake when tinkering with the jsc lib. Also you have this patch first facebook#22295.
Kudo plz review.

![image](https://user-images.githubusercontent.com/3759816/48561684-758f6f00-e92b-11e8-905b-e394f72349f7.png)
Pull Request resolved: facebook#22293

Differential Revision: D13153931

Pulled By: hramos

fbshipit-source-id: 8a6efa0cd8abbff359f082d5ea7713933b6e7ac6
@facebook facebook locked as resolved and limited conversation to collaborators Nov 21, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants