16 This document describes how to run Native Client applications during
19 The workflow for PNaCl applications is straightfoward and will only be discussed
20 briefly. For NaCl applications distributed through the web-store, there is a
21 number of options and these will be discussed more in-depth.
23 Portable Native Client (PNaCl) applications
24 ===========================================
26 Running PNaCl applications from the open web is enabled in Chrome version 31 and
27 above; therefore, no special provisions are required to run and test such
28 applications locally. An application that uses a PNaCl module can be tested
29 similarly to any other web application that only consists of HTML, CSS and
32 To better simulate a production environment, it's recommended to start a local
33 web server to serve the application's files. The NaCl SDK comes with a simple
34 local server built in, and the process of using it to run PNaCl applications is
35 described in :ref:`the tutorial <tutorial_step_2>`.
37 Native Client applications and the Chrome Web Store
38 ===================================================
40 Before reading about how to run Native Client applications, it's important to
41 understand a little bit about how Native Client applications are distributed.
42 As explained in :doc:`Distributing Your Application <../distributing>`, Native
43 Client applications must currently be distributed through the **Chrome Web
44 Store (CWS)**. Applications in the CWS are one of three types:
46 * A **hosted application** is an application that you host on a server of your
47 choice. To distribute an application as a hosted application, you upload
48 application metadata to the CWS. Learn more on the `Chrome App </apps>`_
51 * A **packaged application** is an application that is hosted in the CWS and
52 downloaded to the user's machine. To distribute an application as a packaged
53 application, you upload the entire application, including all application
54 assets and metadata, to the CWS. Learn more on the `Chrome App </apps>`_
57 * An **extension** is a packaged application that has a tiny UI component
58 (extensions are typically used to extend the functionality of the Chrome
59 browser). To distribute an application as an extension, you upload the entire
60 application, including all application assets and metadata, to the CWS. Learn
61 more on the `Chrome extensions </extensions>`_ documentation page.
63 The web store documentation contains a handy guide to `help you choose which to
64 use <https://developer.chrome.com/webstore/choosing>`_.
66 It's clearly not convenient to package and upload files to the Chrome Web Store
67 every time you want to run a new build of your application, but there are four
68 alternative techniques you can use to run the application during development.
69 These techniques are listed in the following table and described in detail
70 below. Each technique has certain requirements (NaCl flag, web server, and/or
71 CWS metadata); these are explained in the :ref:`Requirements <requirements>`
75 +--------------------------------------------------------+----------+----------+
76 | Technique | Requires | Requires |
78 | | Server | Metadata |
79 +========================================================+==========+==========+
80 |**1. Local server** | |CHK| | |
84 | Run a local server and simply point your browser to | | |
85 | your application on the server. | | |
90 | This technique requires the NaCl flag. | | |
91 +---------------------------------------------+----------+----------+----------+
92 |**2. Packaged application loaded as an unpacked | | |CHK| |
97 | Load your packaged application into Chrome as an | | |
98 | unpacked extension and run it without a server. An | | |
99 | unpacked extension is an application whose source and | | |
100 | metadata files are located in an unzipped folder on | | |
101 | your development machine. The CWS manifest file | | |
102 | (explained below) must specify a local_path field. | | |
103 +--------------------------------------------------------+----------+----------+
104 |**3. Hosted application loaded as an unpacked | |CHK| | |CHK| |
109 | Load your hosted application into Chrome as an | | |
110 | unpacked extension and run it from a server (which can| | |
111 | be a local server). The CWS manifest file must specify| | |
112 | a web_url field. | | |
113 +--------------------------------------------------------+----------+----------+
114 |**4. CWS application with untrusted testers** | | |CHK| |
118 | The standard technique for distributing a packaged or | | |
119 | hosted application in the CWS. You can limit the | | |
120 | application to trusted testers. This technique | | |
121 | requires a server if your application is a hosted | | |
123 +--------------------------------------------------------+----------+----------+
126 .. |CHK| image:: /images/check-red.png
128 Which of the above techniques you use to run your application during development
129 is largely a matter of personal preference (i.e., would you rather start a local
130 server or create CWS metadata?). As a general rule, once you have an idea of how
131 you plan to distribute your application, you should use the corresponding
132 technique during development. Choosing a distribution option depends on a number
133 of factors such as application size, application start-up time, hosting costs,
134 offline functionality, etc. (see :doc:`Distributing Your Application
135 <../distributing>` for details), but you don't need to make a decision about how
136 to distribute your application at the outset.
138 The next two sections of this document describe a couple of prerequisites for
139 running applications during development, and explain the three requirements
140 listed in the table above (NaCl flag, web server, and CWS metadata). The
141 subsequent sections of the document provide instructions for how to use each of
147 Browser and Pepper versions
148 ---------------------------
150 Before you run a new build of your application, make sure that you're using the
151 correct version of Chrome. Each version of Chrome supports a corresponding
152 version of the Pepper API. You (and your users) must use a version of Chrome
153 that is equal to or higher than the version of the Pepper API that your
154 application uses. For example, if you compiled your application using the
155 ``pepper_37`` bundle, your application uses the Pepper 37 API, and you must run
156 the application in Chrome 37 or higher. To check which version of Chrome you're
157 using, type ``about:version`` in the Chrome address bar.
164 Chrome caches resources aggressively. You should disable Chrome's cache whenever
165 you are developing a Native Client application in order to make sure Chrome
166 loads new versions of your application. Follow the instructions :ref:`in the
167 tutorial <tutorial_step_3>`.
179 Native Client is automatically enabled for applications that are installed from
180 the Chrome Web Store. To enable Native Client for applications that are not
181 installed from the Chrome Web Store, you must explicitly turn on the Native
182 Client flag in Chrome as follows:
184 #. Type ``about:flags`` in the Chrome address bar.
185 #. Scroll down to "Native Client".
186 #. If the link below "Native Client" says "Disable", then Native Client is
187 already enabled and you don't need to do anything else.
188 #. If the link below "Native Client" says "Enable":
190 * Click the "Enable" link.
191 * Click the "Relaunch Now" button in the bottom of the screen. **Native
192 Client will not be enabled until you relaunch your browser**. All browser
193 windows will restart when you relaunch Chrome.
195 If you enable the Native Client flag and still can't run applications from
196 outside the Chrome Web Store, you may need to enable the Native Client plugin:
198 #. Type ``about:plugins`` in the Chrome address bar.
199 #. Scroll down to "Native Client".
200 #. If the link below "Native Client" says "Enable", click the link to enable
201 the Native Client plugin. You do not need to relaunch Chrome after enabling
202 the Native Client plugin.
209 For security reasons, Native Client applications must come from a server (you
210 can't simply drag HTML files into your browser). The Native Client SDK comes
211 with a lightweight Python web server that you can run to serve your application
212 locally. The server can be invoked from a Makefile. Here is how to run the
221 By default, the server listens for requests on port 5103. You can use the server
222 to run most applications under the ``examples`` directory where you started the
223 server. For example, to run the ``flock`` example in the SDK, start the server
224 and point your browser to ``http://localhost:5103/demo/flock/``.
226 Some of the applications need special flags to Chrome, and must be run with the
227 ``make run`` command. See :ref:`running_the_sdk_examples` for more details.
231 Chrome Web Store metadata
232 ~~~~~~~~~~~~~~~~~~~~~~~~~
234 Applications published in the Chrome Web Store must be accompanied by CWS
235 metadata; specifically, a Chrome Web Store manifest file named
236 ``manifest.json``, and at least one icon.
238 Below is an example of a CWS manifest file for a **hosted application**:
243 "name": "My NaCl App",
244 "description": "Simple game implemented using Native Client",
251 "http://mysubdomain.example.com/"
254 "web_url": "http://mysubdomain.example.com/my_app_main_page.html"
260 For a **packaged application**, you can omit the urls field, and replace the
261 ``web_url`` field with a ``local_path`` field, as shown below:
266 "name": "My NaCl App",
267 "description": "Simple game implemented using Native Client",
275 "local_path": "my_app_main_page.html"
280 You must put the ``manifest.json`` file in the same directory as your
281 application's main HTML page.
283 If you don't have icons for your application, you can use the following icons as
290 .. |ICON16| image:: /images/icon16.png
291 .. |ICON128| image:: /images/icon128.png
293 Put the icons in the same directory as the CWS manifest file. For more
294 information about CWS manifest files and application icons, see:
296 * `Chrome Web Store Tutorial: Getting Started </webstore/get_started_simple>`_
297 * `Chrome Web Store Formats: Manifest Files </extensions/manifest>`_
299 Technique 1: Local server
300 =========================
302 To run your application from a local server:
304 * Enable the :ref:`Native Client flag <flag>` in Chrome.
305 * Start a :ref:`local web server <web_server>`.
306 * Put your application under the examples directory in the SDK bundle you are
307 using (for example, in the directory ``pepper_35/examples/my_app``).
308 * Access your application on the local server by typing the location of its
309 HTML file in Chrome, for example:
310 ``http://localhost:5103/my_app/my_app_main_page.html``.
315 **Note:** You don't have to use a local web server---you can use another
316 server if you already have one running. You must still enable the Native
317 Client flag in order to run your application from the server.
319 Technique 2: Packaged application loaded as an unpacked extension
320 =================================================================
322 For development purposes, Chrome lets you load a packaged application as an
323 unpacked extension. To load and run your packaged application as an unpacked
326 #. Create a Chrome Web Store manifest file and one or more icons for your
329 * Follow the instructions above under Chrome Web Store metadata to create
331 * Note that the CWS manifest file should contain the ``local_path`` field
332 rather than the ``web_url`` field.
333 #. Put the CWS manifest file and the application icon(s) in the same directory
334 as your application's main HTML page.
335 #. Load the application as an unpacked extension in Chrome:
337 * Bring up the extensions management page in Chrome by clicking the menu
338 icon |menu-icon| and choosing **Tools > Extensions**.
339 * Check the box for **Developer mode** and then click the **Load unpacked
342 * In the file dialog that appears, select your application directory. Unless
343 you get an error dialog, you've now installed your app in Chrome.
344 #. Open a new tab in Chrome and click the **Apps** link at the bottom of the
345 page to show your installed apps:
347 #. The icon for your newly installed app should appear on the New Tab page.
348 Click the icon to launch the app.
350 For additional information about how to create CWS metadata and load your
351 application into Chrome (including troubleshooting information), see the
352 `Chrome Web Store Tutorial: Getting Started </webstore/get_started_simple>`_.
354 See also :ref:`run_sdk_examples_as_packaged`.
356 Technique 3: Hosted application loaded as an unpacked extension
357 ===============================================================
359 For development purposes, Chrome lets you load a hosted application as an
360 unpacked extension. To load and run your hosted application as an unpacked
363 #. Start a web server to serve your application.
365 * You can use the :ref:`local web server <web_server>` included with the
366 Native Client SDK if you want.
367 #. Upload your application (.html, .nmf, .nexe, .css, .js, image files, etc.)
370 * If you're using the local server included with the Native Client SDK,
371 simply put your application under the ``examples`` directory in the SDK
372 bundle you are using (e.g., in the directory
373 ``pepper_37/examples/my_app``).
374 #. Create a Chrome Web Store manifest file and one or more icons for your
377 * Follow the instructions above under :ref:`Chrome Web Store metadata
378 <metadata>` to create these files.
379 * In the CWS manifest file, the ``web_url`` field should specify the
380 location of your application on your server. If you're using the local
381 server included with the SDK, the ``web_url`` field should look something
382 like ``http://localhost:5103/my_app/my_app_main_page.html``.
383 #. Put the CWS manifest file and the application icon(s) in the same directory
384 as your application's main HTML page.
385 #. Load the application as an unpacked extension in Chrome:
387 * Bring up the extensions management page in Chrome by clicking the menu
388 icon |menu-icon| and choosing **Tools > Extensions**.
389 * Check the box for **Developer mode** and then click the **Load unpacked
392 * In the file dialog that appears, select your application directory. Unless
393 you get an error dialog, you've now installed your app in Chrome.
394 #. Open a new tab in Chrome and click the **Apps** link at the bottom of the
395 page to show your installed apps:
397 #. The icon for your newly installed app should appear on the New Tab page.
398 Click the icon to launch the app.
400 For additional information about how to create CWS metadata and load your
401 application into Chrome (including troubleshooting information), see the
402 `Chrome Web Store Tutorial: Getting Started </webstore/get_started_simple>`_.
404 Technique 4: Chrome Web Store application with trusted testers
405 ==============================================================
407 When you're ready to test your application more broadly, you can upload the
408 application to the Chrome Web Store and let some trusted testers run it. Here
411 #. Create the Chrome Web Store metadata required to publish your application:
413 * First, create a Chrome Web Store manifest file and one or more icons for
414 your application, as described above under :ref:`Chrome Web Store metadata
415 <metadata>`. Note that packaged applications must have at least two icons
416 (a 16x16 icon and a 128x128 icon).
417 * You also need to create the following additional assets before you can
418 publish your application:
420 * a screenshot (size must be 640x400 or 1280x800)
421 * a promotional image called a "small tile" (size must be 440x280)
423 #. For a **packaged application**:
425 * Create a zip file with the CWS manifest file, the application icons, and
426 all your application files (.html, .nmf, .nexe, .css, .js, image files,
429 #. For a **hosted application**:
431 * Create a zip file with the CWS manifest file and the application icon(s).
432 * Upload the application files (.html, .nmf, .nexe, .css, .js, image files,
433 etc.) to the server on which the application is being hosted.
434 * Use `Google Webmaster Tools <http://www.google.com/webmasters/tools/>`_ to
435 verify ownership of the website on which the application runs.
437 #. Log in to the `Chrome Web Store Developer Dashboard
438 <https://chrome.google.com/webstore/developer/dashboard>`_.
440 * The first time you log in, click the "Add new item" button to display the
441 Google Chrome Web Store Developer Agreement. Review and accept the
442 agreement and then return to the `Developer Dashboard
443 <https://chrome.google.com/webstore/developer/dashboard>`_.
445 #. Click "Edit your tester accounts" at the bottom of the Developer Dashboard.
446 #. Enter a series of email addresses for your testers (separated by commas or
447 whitespace), and click the "Save Changes" button.
448 #. Click the "Add new item" button to add your application to the Chrome Web
450 #. Click the "Choose file" button and select the zip file you created earlier.
451 #. Click the "Upload" button; this uploads your zip file and opens the "Edit
453 #. Edit the following required fields on the "Edit item" page:
455 * Upload an application icon.
456 * Upload a screenshot.
457 * Upload a small tile.
458 * Select a category for your application (accounting application, action
460 * Select a language for your application.
461 #. If you are an owner or manager of a Google Group, you can select that group
462 in the "Trusted testers" field.
464 * You may want to create a Google Group specifically for your testers. When
465 you add a group to the "Trusted testers" field, all group members will be
466 able to test the application, in addition to the individuals you added to
467 the "trusted tester accounts" field on the Developer Dashboard.
468 #. Click the "Publish to test accounts" button at the bottom of the page and
470 #. A page comes up that shows your application's listing in the Chrome Web
471 Store. Copy the URL and mail it to your trusted testers.
473 * When you publish an application to test accounts, the application's CWS
474 listing is visible only to you and to people who are logged into those
475 accounts. Your application won't appear in search results, so you need to
476 give testers a direct link to your application's CWS listing. Users won't
477 be able to find the application by searching in the CWS.
479 To publish an application to the world after publishing it to test accounts,
480 you must first unpublish the application. For additional information see
481 `Publishing Your App </webstore/docs/publish>`_, and in particular `Publishing
482 to test accounts </webstore/publish#testaccounts>`_.
484 .. |menu-icon| image:: /images/menu-icon.png
485 .. |extensions| image:: /images/extensions-management.png
486 .. |new-tab-apps| image:: /images/new-tab-apps.png