Google Earth, the hulking C++ application that allows you to explore the world from the comfort of your desk, has previously been ported into smartphones through NDK and Objective C and into the Chrome browser through Google’s Native Client. Now, thanks to WebAssembly, the Google Earth team has been working to create a cross browser version of the popular app. The app will work on all Chromium-based browsers, and since the OS has nearly monopolized browsers for better or for worse, that means your favorite browser will soon be able to run Google Earth. As of now, the team put out a preview for anyone hungry to get their hands on Google Earth for the Web.
The preview aside, the fact that WebAssembly is being leveraged in this way continues to highlight the innovation that this technology brings to web development. No longer do developers have to learn another framework to port C++ code into their web projects to varying degrees of success; WebAssembly allows a cross-functional approach to sandboxing performant C++ code within the context of a web browser. Here’s what WebAssembly’s product manager, Thomas Nattestad, had to say about Web Assembly’s role in the evolution of Google Earth on the web:
In WebAssembly (Wasm), the W3C web standard for bringing native code to the web, the Earth team found a solution to allow Google Earth to move across multiple browsers—something we’ve been working on for a while now. Earth first came to the Web about two years ago using Native Client (NaCl), a Chrome-only solution—at the time. It was the only way to run native code in the browser and offer the performance users expect in modern web applications. But cross-browser compatibility is not as easy as we would like, since not every browser supports new technologies the same way…Using WebAssembly, we see more possibilities not just for making apps more accessible across browsers, but smoothing out the online experience, as we’ve seen with Google Earth.
With the case of Google Earth, true cross browser compatibility may be difficult to achieve; that’s if we decide to define true compatibility in terms of near equality in usability. Since Google Earth is a massive 3D simulation, good performance is crucial to a good user experience. To allow for good performance WebAssembly uses multithreading. According to the Chromium Blog, “[multithreading] has shown a clear improvement in the performance of Earth in the browser.” The problem is that not all browsers support multithreading, which means Firefox(which doesn’t support multithreading) will not run Google Earth as smoothly as Chrome.
One final thing to note is that moving Google Earth to WebAssembly was made possible by an unsung hero called Emscripten. To put it simply, Emscripten’s magic lies in its ability to mock common OS calls and translate those calls into something a browser can recognize so that functionality remains intact. Recently, the toolchain has been used to bring AutoCAD, the popular design and drafting software, to the browser.