The Snake Oil of Native Code

Andrew Sampson
Blog | Rainway

--

Over the decades the Web has evolved from those early days of static HTML pages into a fast and robust environment capable of emulating and running game consoles, complete operating systems and even producing amazing games like CrossCode using nothing more than regular JavaScript — all in the browser.

More often than not you’ll see someone mention that because something is running in the browser, it is slower than native solutions. Because we are such colossal Web nerds at Rainway, we wanted to take this opportunity to clear up some misconceptions.

The Web is powered by native code.

Technologies like WebRTC and WebSockets power Rainway. You can even look at the source code for our WebRTC library Spitfire and see that 86.2% of all the code is C++ (native code). All real-time network operations are happening at a native level in the browser and the only point it stops being “native” is when the data is fully received. Even then, our JavaScript-based code is so efficient; we can parse and handle data in under a millisecond even for something as complex as real-time video.

1080p @ 60 FPS sub millisecond message decode time on average

Which brings us to our next point.

The Web is hardware accelerated.

Anyone that tells you they have a fancy or unique video decoder isn’t giving you the full picture. After all, paying hefty license fees to MPEG-LA does not scale, and the only way to avoid these fees is by making use of existing OEM’s encoder/decoder API’s. Companies like Google and Mozilla have spent a considerable amount of time and resources highly optimizing their pipeline to these hardware decoders (which are all native) to ensure they have the best performance around in the browser. The low latency rendering of the video is equally hardware accelerated either using OpenGL or DirectX depending on the system.

Overwatch played inside Chrome (1080p @ 60 FPS)

However, if you need an extra boost in performance, there is another option.

You can run native code in the browser.

All the way back in 2013 Mozilla was able to produce near-native performance on the Web. In just five years, however, the Web has evolved to be even faster and using modern techniques like WebAssembly you’re able to run native code like C++, C, C#, Rust and more all inside the browser. We are taking advantage of WebAssembly for our next networking update, Coffee, to enable astronomical performance boost on unstable networks.

WebAssembly was matching native Rust performance even a year ago.

In closing.

We don’t discredit the performance of native code and aim to use it when necessary in all of our stack, such as our upcoming Android app which will be completely native. It is crucial to understand native code does not mean more performant code, and at the end of the day, performance comes down to the talents of the team behind the product — and I’d like to say we have the best one out there.

Rainway is a web-based game-streaming platform that lets users play their favorite PC games anywhere, across a variety of different devices. Enjoy games like Overwatch, Cuphead, PlayerUnknown’s Battlegrounds and much more anywhere. Download Rainway

Come work with us!

Join our Discord

Follow us on Twitter

Subscribe to our YouTube

--

--

Andrew Sampson
Blog | Rainway

Co-Founder and CEO of Rainway / Forbes 30 Under 30.