Windows on Arm has really gathered momentum and the ecosystem is continuing to grow. It now has the supporting tools to make it easy to port Windows apps to run natively.
With the Electron framework ready for Arm, there are a few simple steps to get your code running natively. Electron is an open-source software framework for developing cross-platform GUI applications using web technology. With the Electron framework, but also through more libraries, open-source software projects and other dependencies moving over to Arm64, you can now jump that last hurdle to fast, efficient native code.
Let us look at an example of how one developer ported their Electron app to native Arm64.
Tweeten is a popular free Twitter client. It is a TweetDeck-based app and in 2017 when TweetDeck stopped having its own Windows client Tweeten quickly filled the gap.
Tweeten is electron-based, and primarily JavaScript. Other popular electron-based apps include Slack, Visual Studio Code, WhatsApp, Skype, and Discord. The platform is well set up for being cross-platform, and with Arm’s help, it has been great for Windows on Arm apps too. Especially since 7.0 came out last year.
Tweeten’s Windows version was built against x86_64. Windows on Arm has x86 emulation, but non-native 64-bit apps do not run, so Tweeten was missing platform entirely.
const electron = require('electron')
The first and biggest task was updating Electron and the accompanying dependencies. For any Windows on Arm port, dependencies will be the major hurdle. In Tweeten’s case, this mainly involved updating from Electron 3 to Electron 7 and all the accompanying libraries with it.
Once updated to Electron 7 and up-to-date APIs, Arm 64 support was there.
And with Electron doing the multi-platform work for you, converting your code is easy.
Mostly when you go to build your code, it is a case of setting the target to Arm64, compiling and then you are done.
As Tweeten was one of the first Electron apps to be ported to Windows on Arm, they hit one or two minor issues when they first compiled. To make sure others do not hit these issues, they contributed to the Electron documentation, so it is now updated and straightforward for everyone else.
Once built, Tweeten was ready to try on the Microsoft Surface Pro X for testing. As the Electron code was JavaScript, the developer could easily see and tweak any last minor changes without Remote Debugging.
Remote Debugging is available through Visual Studio 2019, or Visual Studio 2017 if you download the 15.9 update and then the Arm64 toolset with it. Visual Studio Code can run on a Windows on Arm device now so you can do local debugging. However, depending on the language you use, the required libraries or compilers may still be being ported across.
The next step was how to deploy the app to users. At the time, Tweeten used the NSIS installer and it did not support Windows on Arm properly. Shortly afterwards, NSIS was fixed, so now if you use the latest NSIS release (3.06) it works.
But Tweeten needed to release before the NSIS fix, so the solution chosen was the Windows Store. The Store allows easy deployment for different architectures, so is perfect for adding a Windows on Arm version.
However, when initially uploading Tweeten to the Store, there were ‘package is invalid’ errors. After a bit of research, this turned out to be an issue with the minimum Windows 10 version requirements.
So Tweeten was updated to have a minimum version of 1809 (10.0 Build 17763). This solved the problem and allowed Windows Store deployment. Native Arm64 Tweeten was then released.
For the benefit of comparison, and because it was not too much effort, a Win32 version of Tweeten was created.
Often the difference between emulation and native will not be immediately obvious, and most of the time this was the case with Tweeten. However, looking at the CPU usage revealed significant savings that would add up to important differences in battery life, and performance if there are multiple hungry apps running.
For Tweeten, during start-up the native version of the app used 20% CPU versus the 30% used by the win32 emulation. And when actively using the app, the CPU usage was 4% on the native app versus 7% when running under emulation. So a CPU performance improvement of between 33% and 42% is delivered, along with the battery savings of not doing that extra work.
When moving the Tweeten window, and especially re-sizing it, there is also a ‘smoother’ feel, but generally the emulation is impressive in how well it copes from a user perspective. From a system point of view, however, those CPU savings are important, especially for battery life and if you are running other CPU-hungry apps.
As you have seen through this example, porting your Electron app to Windows on Arm is generally easy. There can be some issues with dependencies and libraries, but more of them are producing Windows on Arm versions. Many open-source projects are already compatible or may not require much effort to get them going, if they are a dependency.
And once the dependencies are sorted, it is easy from there. Target Arm64, build, and deploy.
Indeed, after porting Tweeten, the developer looked at another very popular Electron app and was able to port it in about an hour.
So, it is do-able and worth it for the performance improvements.
The following resources provide more Windows on Arm and Electron information:
[CTAToken URL = "https://developer.arm.com/solutions/os/windows-on-arm" target="_blank" text="Learn more about Windows on Arm" class ="green"]
Sign up to the Arm DevSummit technical sessions where you will learn more about developing, deploying and debugging for Windows on Arm .
[CTAToken URL = "https://devsummit.arm.com/en/about" target="_blank" text="Sign up to Arm DevSummit" class ="green"]