BROWSIX: Bridging the Gap Between Unix and the Browser Bobby Powers, John Vilk, Emery D

BROWSIX: Bridging the Gap Between Unix and the Browser Bobby Powers, John Vilk, Emery D

BROWSIX: Bridging the Gap Between Unix and the Browser Bobby Powers, John Vilk, Emery D. Berger University of Massachusetts Amherst Abstract As a representative example, websites like ShareLaTeX1 2 A Applications written to run on conventional operating sys- and Overleaf let users write and edit LTEX documents in the tems typically depend on OS abstractions like processes, pipes, browser without the need to install a TEX distribution locally. signals, sockets, and a shared file system. Porting these ap- This workflow lowers the barrier for students and first-time A plications to the web currently requires extensive rewriting LTEX authors and enables real-time collaboration, eliminating or hosting significant portions of code server-side because some of the complexity of creating multi-author documents. browsers present a nontraditional runtime environment that These applications achieve this functionality by providing a lacks OS functionality. browser-based frontend for editing; user input is sent to the server for persistence and collaboration purposes. When the This paper presents BROWSIX, a framework that bridges pdflatex the considerable gap between conventional operating systems user requests a generated PDF, the website runs bibtex and the browser, enabling unmodified programs expecting a and server-side on the user’s behalf, with the resulting PDF sent to the browser when complete. Unix-like environment to run directly in the browser. BROWSIX comprises two core parts: (1) a JavaScript-only system that These web applications generate PDFs server-side out of makes core Unix features (including pipes, concurrent pro- necessity because browsers lack the operating system services cesses, signals, sockets, and a shared file system) available to and execution environment that Unix programs expect. Creat- web applications; and (2) extended JavaScript runtimes for C, ing PDFs from LATEX requires spawning multiple processes to C++, Go, and Node.js that support running programs written run pdflatex and bibtex, which need to read from and write to a shared file system. If PDF generation takes too long and in these languages as processes in the browser. BROWSIX supports running a POSIX shell, making it straightforward to the user cancels the request, the application needs to send a connect applications together via pipes. SIGTERM or SIGKILL signal to clean up any running processes. If PDF generation encounters an error, the application needs to We illustrate BROWSIX’s capabilities via case studies that demonstrate how it eases porting legacy applications to the pipe the output of the relevant process back to the client over browser and enables new functionality. We demonstrate a the network. Since browsers do not support processes, signals, pipes, sockets, or a shared filesystem, they cannot perform any BROWSIX-enabled LATEX editor that operates by executing un- modified versions of pdfLaTeX and BibTeX. This browser-only of these steps without program modification. Previous attempts to cope with this impedance mismatch LATEX editor can render documents in seconds, making it fast enough to be practical. We further demonstrate how BROWSIX between conventional applications and the browser fall short lets us port a client-server application to run entirely in the of providing the environment needed by many programs (see browser for disconnected operation. Creating these applica- Section7). Emscripten and Doppio provide a POSIX-like run- tions required less than 50 lines of glue code and no code time system for single processes, including a single-process modifications, demonstrating how easily BROWSIX can be file system, limited support for threads, synchronous I/O, and used to build sophisticated web applications from existing proxying support for TCP/IP sockets [9, 12]. While these parts without modification. single-process runtimes are useful for some applications, they are severely limited because they are unable to provide the arXiv:1611.07862v2 [cs.OS] 29 Apr 2019 1. Introduction range of operating system functionality that many legacy ap- plications demand. Web browsers make it straightforward to build user interfaces, To overcome these limitations, we introduce BROWSIX, but they can be difficult to use as a platform to build sophis- a framework that brings Unix abstractions to the browser ticated applications. Code must generally be written from through a shared kernel and common system-call conventions, scratch or heavily modified; compiling existing code or li- bridging the gap between conventional operating systems and braries to JavaScript is not sufficient because these applica- the browser. BROWSIX consists of two core components: (1) a tions depend on standard OS abstractions like processes and a JavaScript-only operating system that exposes a wide array of shared file system, which browsers do not support. Many web OS services that applications expect (including pipes, concur- applications are thus divided between a browser front-end and rent processes, signals, sockets, and a shared file system); and a server backend. The server runs on a traditional operating (2) extended JavaScript runtimes for C, C++, Go, and Node.js system, where the application can take advantage of familiar OS abstractions and run a wide variety of off-the-shelf libraries 1https://www.sharelatex.com/ and programs. 2https://www.overleaf.com/ and pipes their standard output and standard error to the ap- plication. These TEX programs use BROWSIX’s shared file system to read in the user’s source files, and any packages, class files, and fonts referenced within, as in a traditional Unix environment. The filesystem transparently loads any needed external packages from the TeX Live distribution over HTTP upon first access. Subsequent accesses to the same files are in- stantaneous, as the browser caches them. While a full TeX Live distribution is several gigabytes in size, a typical paper only needs to retrieve several megabytes worth of packages before it can be built. If the user cancels PDF generation, BROWSIX sends a SIGKILL signal to these processes. If PDF generation Figure 1: A LATEX editor built using BROWSIX.BROWSIX’s OS services and language runtimes make it possible to run com- fails, the application can display the captured standard out plex legacy code (including pdflatex and bibtex) directly and standard error. The result is serverless PDF generation in the browser, without code modifications (See Section2 for composed from off-the-shelf parts, with minimal engineering details.) effort required to glue them together. We demonstrate the utility of BROWSIX with two further that let unmodified programs written in these languages and case studies. Using BROWSIX, we build an application that dy- compiled to JavaScript run directly in the browser. Because namically routes requests to a remote server or an in-BROWSIX BROWSIX’s components are written entirely in JavaScript and server, both compiled from the same source code, depending require no plugins, applications using BROWSIX can run in a on the client’s performance and battery characteristics. We also wide range of modern web browsers including Google Chrome, use BROWSIX to build a UNIX terminal exposing a POSIX Mozilla Firefox, and Microsoft Edge. BROWSIX makes it pos- shell, enabling developers to launch and compose applications sible to port a wide range of existing applications and their and inspect BROWSIX state in a familiar way. language runtimes to the browser by providing the core func- tionality of a full operating system: Contributions • Processes: BROWSIX implements a range of process related This paper makes the following contributions: system calls (including fork, spawn, exec, and wait4) and • Bringing OS Abstractions and Services to the Browser. provides a process primitive on top of Web Workers, letting We demonstrate that it is possible to provide a wide range applications run in parallel and spawn subprocesses. of key Unix abstractions and services in the browser on top • ROWSIX Signals: B supports a substantial subset of the of existing web APIs. We implement these in BROWSIX, a POSIX signals API, including kill and signal handlers, JavaScript-only framework featuring a kernel and system letting processes communicate with each other asyn- calls that runs on all modern browsers (§3). chronously. • Runtime Integration for Existing Languages. We ex- • Shared Filesystem: BROWSIX lets processes share state tend the JavaScript runtimes of Emscripten (a C/C++ to through a shared FS. JavaScript toolchain), GopherJS (a Go to JavaScript com- • ROWSIX pipe Pipes: B exposes the standard API, making it piler), and Node.js with BROWSIX support, letting unmodi- simple for developers to compose processes into pipelines. fied C, C++, Go, and Node.js programs execute and inter- • ROWSIX Sockets: B supports TCP socket servers and clients, operate with one another within the browser as BROWSIX making it possible to run server applications like databases processes (§4). and HTTP servers together with their clients in the browser. • Case Studies. We demonstrate BROWSIX’s utility by build- • Language Agnostic: BROWSIX includes integration with ing a LATEX editor, a serverless client-server web application, the runtime libraries of Emscripten (C/C++), GopherJS and a Unix terminal out of off-the-shelf components without (Go), and Node.js (JavaScript) to allow unmodified applica- modification. We characterize BROWSIX’s performance un- tions written in these languages to run directly as processes der these case studies

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    12 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us