Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News NativeScript Replaces JavaScriptCore with V8 for iOS Apps

NativeScript Replaces JavaScriptCore with V8 for iOS Apps

This item in japanese

NativeScript's new JavaScript runtime for iOS, based on Google's V8 engine, is now in beta after several months of development. This change should bring reduced app startup time for iOS apps as well as simplify NativeScript's development process.

The fundamental reason to replace JavaScriptCore, the iOS native JavaScript engine, lies with a fundamental simplification of maintenance work for the NativeScript team, writes NativeScript product manager Emil Tabakov. Indeed, the NativeScript team has heavily adapted JavaScriptCore, which Tabakov describes as a non-embedding friendly framework, to provide support for all they needed.

In spite of all the extra effort, using JavaScriptCore for iOS made it impossible to reach full feature parity with Android, mostly due to features that are only available when using V8. This is the case, for example, with V8 heap snapshots, which enable the possibility of initializing a JavaScript context from a pre-made image stored in the app package. According to the NativeScript team, V8 heap snapshots reduce the startup time of simple applications by over 30%.

What made using V8 on iOS possible was the introduction of a JIT-less mode for V8 in the first months of 2019. This switched off executable memory allocation at runtime, which was not permitted on iOS and other embedded platforms. Unfortunately, this comes with a performance penalty, since JIT-less V8 will basically work as a JavaScript interpreter. According to V8 team's benchmarks, the performance hit is large with peak optimized code, i.e., code exercising specific language characteristics, but less significant for real-world applications.

As a last note, switching to V8, Tabakov says, paves the way to future support for Bitcode, which is a requirement for writing Apple Watch apps.

Being in beta, NativeScript V8 runtime for iOS still requires some work to be production ready, in particular armv7 support and fully functioning multithreading, so developers should use it at their own risk.

To use the new runtime, you first install it by executing tns platform add ios@beta-v8, then launch your app as usual. Issues can be reported in the NativeScript V8 iOS runtime repository.

Rate this Article