Mobile Monitoring Solutions

Search
Close this search box.

NativeScript Replaces JavaScriptCore with V8 for iOS Apps

MMS Founder
MMS Sergio De Simone

Article originally posted on InfoQ. Visit InfoQ

NativeScript 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 development process.

The fundamental reason to replace JavaScriptCore, 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 NativeScript team, V8 heap snapshots reduce by over 30% startup time of simple applications.

What made possible using V8 on iOS 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 specify language characteristics, but less significant for real-world applications.

As a last not, 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 requires still 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 you app as usual. Issues can be reported in the NativeScript V8 iOS runtime repository.

Subscribe for MMS Newsletter

By signing up, you will receive updates about our latest information.

  • This field is for validation purposes and should be left unchanged.