react-native-community / jsc-android-buildscripts

Script for building JavaScriptCore for Android (for React Native but not only)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to determine JSC version at runtime

bourquep opened this issue · comments

I have followed the steps in the readme to build my React Native Android app with the latest JSC, but am not noticing any performance improvements.

How can I determine if my app is really using that JSC build and not the default, old one bundled with RN?

See if the Proxy object exists. It is not implemented by the JSC shipped with RN, but this more modern one has it.

Thanks!

commented

May you feedback if there are any upsides using this engine on Android performancewise during your tests?

That makes sense since the RN Babel settings convert most of the modern JS into ES5.
I'm also not sure how much JIT-compiling is going on with the newer runtime.

I think its a good idea to add some metadata file with version/build information, or some other way to expose that.

Performance should be noticeably better when compared to stock react-native (30% is a conservative figure I measured).. if it's not, you're probably didn't inject it correctly to the apk. One thing I would suggest to check is to use the apk explorer in android studio and check the size of the jsc.so inside the apk. This will be a good indication wether it's the stock version or the new one.

@DanielZlotin Thanks for the tip. I have x86/libjsc.so at 2.8 MB and armeabi-v7a/libjsc.so at 2.2 MB. What can I infer from this?

@bourquep weird, that doesn't match any of the versions. Trying to reproduce myself encountered with a weird issue: the apk analyzer file size is vastly different than the actual .so file size. (for example apk analyze shows 2MB but when you unzip and check the file itself is 4.3Mb!)
So I would suggest to check the actual file size by unzipping the apk and looking inside 😕
until we have a version info inside the lib

check this table for (total) size of jsc versions. Keep in mind it represents more than 1 so file, depending on the version.

commented

I tried to check it with the availability of console.time.

It's available in RN iOS. On Android it is one of the missing functions. I followed the installation instructions, but no success yet.... it's still missing. I guess this means, that the wrong jsc version is loaded or an older Webkit Version is compiled. As far as i know console.time got released in January 2017 and the compiled Webkit Version is from 2017-10-27. So it should have included this Feature - something seems to be off here.

//Edit:
Following ./gradlew app:dependencies it seems to use the correct dependency.
\--- org.webkit:android-jsc:r174650 -> r224109

Still strange, that "no" new functions are available.

@K-Leon The console object is implemented by React Native, not by JavaScriptCore.
You should test for the existence of Symbol or Proxy.

By testing for the existence of Symbol or Proxy, what do you mean? I followed the instructions in the Readme, but the bug described in AirBNBs latest RN post still persists...

Those are globals like Object and Function. Execute typeof Symbol or typeof Proxy. If you are using the newer JavaScriptCore, the type will be "function". If you're using the RN built-in one, the type will be "undefined".

typeof Proxy and typeof Symbol both evaluate to function. However, I'm still having the issue where Number.toLocalString doesn't work, and just returns the number it was called on...

Number.toLocaleString requires the JSC build with the Intl library enabled. What is typeof Intl?
If it is not object, then you're missing the support for those APIs. You need to reference jsc-android-intl instead of jsc-android in your gradle. I can't remember the exact steps because we don't use that build. @DanielZlotin can point you in the right direction.

I just left the office, but I'll try that first thing in the morning. Thank you, this bug has troubled our team for weeks.

@DanielZlotin Thanks, I've unzipped the APK and the sizes I'm observing don't match anything in that table...

I'm using r224109:

configurations.all {
    resolutionStrategy {
        force 'org.webkit:android-jsc:r224109'
    }

image

the size column in the measure table is the combined size of all compiled libs (in your case its libjsc.so + libicudata_jsc.so + libicuuc_jsc.so)

judging by your screenshot, it seems that you indeed have the correct 224109 version in the apk

Version info will be printed to logcat under tag "JavaScriptCore.Version" as soon as jsc is loaded