Google Native Client | |
Developer: | Google, others |
Programming Language: | C, C++ |
Released: | [1] |
Latest Release Version: | SDK: Pepper 45 / Clients: Same as Google Chrome |
Operating System: | Windows, Linux, macOS, ChromeOS |
Platform: | x86, ARM, MIPS |
Replaced By: | WebAssembly |
Genre: | Sandbox in web browsers for native code |
License: | New BSD |
Google Native Client (NaCl) is a discontinued sandboxing technology for running either a subset of Intel x86, ARM, or MIPS native code, or a portable executable, in a sandbox. It allows safely running native code from a web browser, independent of the user operating system, allowing web apps to run at near-native speeds, which aligns with Google's plans for ChromeOS. It may also be used for securing browser plugins, and parts of other applications or full applications[2] such as ZeroVM.[3]
To demonstrate the readiness of the technology, on 9 December 2011, Google announced the availability of several new Chrome-only versions of games known for their rich and processor-intensive graphics, including Bastion (no longer supported on the Chrome Web Store). NaCl runs hardware-accelerated 3D graphics (via OpenGL ES 2.0), sandboxed local file storage, dynamic loading, full screen mode, and mouse capture. There were also plans to make NaCl available on handheld devices.[4] [5]
Portable Native Client (PNaCl) is an architecture-independent version. PNaCl apps are compiled ahead-of-time. PNaCl is recommended over NaCl for most use cases.[6] The general concept of NaCl (running native code in web browser) has been implemented before in ActiveX, which, while still in use, has full access to the system (disk, memory, user-interface, registry, etc.). Native Client avoids this issue by using sandboxing.
An alternative by Mozilla was asm.js, which also allows applications written in C or C++ to be compiled to run in the browser and also supports ahead-of-time compilation, but is a subset of JavaScript and hence backwards-compatible with browsers that do not support it directly.
On 12 October 2016, a comment on the Chromium issue tracker indicated that Google's Pepper and Native Client teams had been destaffed.[7] On 30 May 2017, Google announced deprecation of PNaCl in favor of WebAssembly.[8] Although initially Google planned to remove PNaCl in first quarter of 2018, and later in the second quarter of 2019,[9] it has been removed in June 2022 (together with Chrome Apps).[10] [11]
Native Client was an open-source project developed by Google.[12] Games such as Quake,[13] XaoS, Battle for Wesnoth,[14] Doom,[15] Lara Croft and the Guardian of Light,[16] From Dust,[17] and MAME, as well as the sound processing system Csound, have been ported to Native Client. Native Client has been available in the Google Chrome web browser since version 14, and has been enabled by default since version 31, when the Portable Native Client (PNaCl, pronounced: pinnacle) was released.[18] [19] [20]
An ARM implementation was released in March 2010.[21] x86-64, IA-32, and MIPS were also supported.
To run an application portably under PNaCl, it must be compiled to an architecture-agnostic and stable subset of the LLVM intermediate representation bytecode.[22] The executables are called PNaCl executables (pexes). The PNaCl Toolchain makes .pexe files; NaCl Toolchain .nexe files. The magic number of .nexe files is 0x7F 'E' 'L' 'F', which is ELF. In Chrome, they are translated to architecture-specific executables so that they can be run.
NaCl uses software fault detection and isolation for sandboxing on x86-64 and ARM.[23] The x86-32 implementation of Native Client is notable for its novel sandboxing method, which makes use of the x86 architecture's rarely used segmentation facility.[24] Native Client sets up x86 segments to restrict the memory range that the sandboxed code can access. It uses a code verifier to prevent use of unsafe instructions such as those that perform system calls. To prevent the code from jumping to an unsafe instruction hidden in the middle of a safe instruction, Native Client requires that all indirect jumps be jumps to the start of 32-byte-aligned blocks, and instructions are not allowed to straddle these blocks.[24] Because of these constraints, C and C++ code must be recompiled to run under Native Client, which provides customized versions of the GNU toolchain, specifically GNU Compiler Collection (GCC), GNU Binutils, and LLVM.
Native Client is licensed under a BSD-style license.
Native Client uses Newlib as its C library, but a port of GNU C Library (GNU libc) is also available.[25]
NaCl denotes sodium chloride, common table salt; as a pun, the name of pepper was also used. Pepper API is a cross-platform, open-source API for creating Native Client modules.[26] Pepper Plugin API, or PPAPI[27] [28] is a cross-platform API for Native Client-secured web browser plugins, first based on Netscape's NPAPI, then rewritten from scratch. It was used in Chromium and Google Chrome to enable the PPAPI version of Adobe Flash[29] and the built-in PDF viewer.[30]
On 12 August 2009, a page on Google Code introduced a new project, Pepper, and the associated Pepper Plugin API (PPAPI),[31] "a set of modifications to NPAPI to make plugins more portable and more secure".[32] This extension is designed specifically to ease implementing out-of-process plugin execution. Further, the goals of the project are to provide a framework for making plugins fully cross-platform. Topics considered include:
The Pepper API also supports Gamepads (version 19) and WebSockets (version 18).[33]
, Google's open source browser, Chromium, was the only web browser to use the new browser plug-in model.[34] As of 2020, Pepper is supported by Chrome, Chromium and Blink layout engine-based browsers such as Opera and Microsoft Edge.
In August 2020, Google announced that support for PPAPI would be removed from Google Chrome and Chromium in June 2022.[35]
Firefox developers stated in 2014 that they would not support Pepper, as there were no full specification of the API beyond its implementation in Chrome, which itself was designed for use with Blink layout engine only, and had private APIs specific to the Flash Player plugin which were not documented.[36] In October 2016 Mozilla announced that it had re-considered and was exploring whether to incorporate the Pepper API and PDFium in future releases of Firefox,[37] however no such steps were taken. In July 2017, Adobe deprecated Flash and announced its end-of-life in the end of 2020.[38] By January 2021, Adobe Flash Player, Google Chrome, Firefox, Safari, and Windows[39] received updates disabling or entirely removing Flash.
One website[40] used NaCL on the server to let users experiment with the Go programming language from their browsers.[41]
Some groups of browser developers supported the Native Client technology while others did not.
Chad Austin (of IMVU) praised the way Native Client can bring high-performance applications to the web (with about 5% penalty compared to native code) in a secure way, while also accelerating the evolution of client-side applications by giving a choice of the programming language used (besides JavaScript).[42]
Id Software's John D. Carmack praised Native Client at QuakeCon 2012, saying: "if you have to do something inside a browser, Native Client is much more interesting as something that started out as a really pretty darn clever x86 hack in the way that they could sandbox all of this in user mode interestingly. It's now dynamic recompilation, but something that you program in C or C++ and it compiles down to something that's going to be not your -O4 optimization level for completely native code but pretty damn close to native code. You could do all of your evil pointer chasings, and whatever you want to do as a to-the-metal game developer."[43]
Other IT professionals were more critical of this sandboxing technology as it had substantial or substantive interoperability issues.
Mozilla's vice president of products, Jay Sullivan, said that Mozilla has no plans to run native code inside the browser, as "These native apps are just little black boxes in a webpage. [...] We really believe in HTML, and this is where we want to focus."[44]
Mozilla's Christopher Blizzard criticized NaCl, claiming that native code cannot evolve in the same way that the source code-driven web can. He also compared NaCl to Microsoft's ActiveX technology, plagued with DLL Hell.[2]
Håkon Wium Lie, Opera's CTO, believed that "NaCl seems to be 'yearning for the bad old days, before the web'", and that "Native Client is about building a new platform – or porting an old platform into the web [...] it will bring in complexity and security issues, and it will take away focus from the web platform."[2]
The second generation of sandboxing developed in Google is gVisor.[45] [46] It is intended to replace NaCl in Google Cloud, to be more exact in Google App Engine. Google has also been promoting WebAssembly.[47]