15 This document describes how to run Native Client applications during
18 The workflow for PNaCl applications is straightfoward and will only be discussed
19 briefly. For NaCl applications distributed through the web-store, there is a
20 number of options and these will be discussed more in-depth.
22 Portable Native Client (PNaCl) applications
23 ===========================================
25 Running PNaCl applications from the open web is enabled in Chrome version 31 and
26 above; therefore, no special provisions are required to run and test such
27 applications locally. An application that uses a PNaCl module can be tested
28 similarly to any other web application that only consists of HTML, CSS and
31 To better simulate a production environment, it's recommended to start a local
32 web server to serve the application's files. The NaCl SDK comes with a simple
33 local server built in, and the process of using it to run PNaCl applications is
34 described in :ref:`the tutorial <tutorial_step_2>`.
36 Native Client applications and the Chrome Web Store
37 ===================================================
39 Before reading about how to run Native Client applications, it's important to
40 understand a little bit about how Native Client applications are distributed.
41 As explained in :doc:`Distributing Your Application <../distributing>`, Native
42 Client applications must currently be distributed through the **Chrome Web
43 Store (CWS)**. Applications in the CWS are one of three types:
45 * A **hosted application** is an application that you host on a server of your
46 choice. To distribute an application as a hosted application, you upload
47 application metadata to the CWS.
49 * A **packaged application** is an application that is hosted in the CWS and
50 downloaded to the user's machine. To distribute an application as a packaged
51 application, you upload the entire application, including all application
52 assets and metadata, to the CWS.
54 * An **extension** is a packaged application that has a tiny UI component
55 (extensions are typically used to extend the functionality of the Chrome
56 browser). To distribute an application as an extension, you upload the entire
57 application, including all application assets and metadata, to the CWS.
59 It's clearly not convenient to package and upload files to the Chrome Web Store
60 every time you want to run a new build of your application, but there are four
61 alternative techniques you can use to run the application during development.
62 These techniques are listed in the following table and described in detail
63 below. Each technique has certain requirements (NaCl flag, web server, and/or
64 CWS metadata); these are explained in the :ref:`Requirements <requirements>`
74 - Requires CWS Metadata
81 - Run a local server and simply point your browser to your application on
84 - Packaged application loaded as an unpacked extension
88 - Load your packaged application into Chrome as an unpacked extension and
89 run it without a server. An unpacked extension is simply an application
90 whose source and metadata files are located in a plain (unzipped) folder
91 on your development machine. The CWS manifest file (explained below) must
92 specify a ``local_path`` field.
94 - Hosted application loaded as an unpacked extension
98 - Load your hosted application into Chrome as an unpacked extension and run
99 it from a server (which can be a local server). The CWS manifest file
100 must specify a ``web_url`` field.
102 - CWS application with untrusted testers
106 - This is the standard technique for distributing a packaged or hosted
107 application in the CWS, but you can limit the application to a few
108 trusted testers. This technique requires a server if your application is
109 a hosted application.
111 .. |CHK| image:: /images/check-red.png
113 Which of the above techniques you use to run your application during development
114 is largely a matter of personal preference (i.e., would you rather start a local
115 server or create CWS metadata?). As a general rule, once you have an idea of how
116 you plan to distribute your application, you should use the corresponding
117 technique during development. Choosing a distribution option depends on a number
118 of factors such as application size, application start-up time, hosting costs,
119 offline functionality, etc. (see :doc:`Distributing Your Application
120 <../distributing>` for details), but you don't need to make a decision about how
121 to distribute your application at the outset.
123 The next two sections of this document describe a couple of prerequisites for
124 running applications during development, and explain the three requirements
125 listed in the table above (NaCl flag, web server, and CWS metadata). The
126 subsequent sections of the document provide instructions for how to use each of
132 Browser and Pepper versions
133 ---------------------------
135 Before you run a new build of your application, make sure that you're using the
136 correct version of Chrome. Each version of Chrome supports a corresponding
137 version of the Pepper API. You (and your users) must use a version of Chrome
138 that is equal to or higher than the version of the Pepper API that your
139 application uses. For example, if you compiled your application using the
140 ``pepper_31`` bundle, your application uses the Pepper 31 API, and you must run
141 the application in Chrome 31 or higher. To check which version of Chrome you're
142 using, type ``about:version`` in the Chrome address bar.
149 Chrome caches resources aggressively. You should disable Chrome's cache whenever
150 you are developing a Native Client application in order to make sure Chrome
151 loads new versions of your application. Follow the instructions :ref:`in the
152 tutorial <tutorial_step_3>`.
164 Native Client is automatically enabled for applications that are installed from
165 the Chrome Web Store. To enable Native Client for applications that are not
166 installed from the Chrome Web Store, you must explicitly turn on the Native
167 Client flag in Chrome as follows:
169 #. Type ``about:flags`` in the Chrome address bar.
170 #. Scroll down to "Native Client".
171 #. If the link below "Native Client" says "Disable", then Native Client is
172 already enabled and you don't need to do anything else.
173 #. If the link below "Native Client" says "Enable":
175 * Click the "Enable" link.
176 * Click the "Relaunch Now" button in the bottom of the screen. **Native
177 Client will not be enabled until you relaunch your browser**. All browser
178 windows will restart when you relaunch Chrome.
180 If you enable the Native Client flag and still can't run applications from
181 outside the Chrome Web Store, you may need to enable the Native Client plugin:
183 #. Type ``about:plugins`` in the Chrome address bar.
184 #. Scroll down to "Native Client".
185 #. If the link below "Native Client" says "Enable", click the link to enable
186 the Native Client plugin. You do not need to relaunch Chrome after enabling
187 the Native Client plugin.
194 For security reasons, Native Client applications must come from a server (you
195 can't simply drag HTML files into your browser). The Native Client SDK comes
196 with a lightweight Python web server that you can run to serve your application
197 locally. The server can be invoked from a Makefile. Here is how to run the
206 By default, the server listens for requests on port 5103. You can use the server
207 to run most applications under the ``examples`` directory where you started the
208 server. For example, to run the ``flock`` example in the SDK, start the server
209 and point your browser to http://localhost:5103/demo/flock/.
211 Some of the applications need special flags to Chrome, and must be run with the
212 ``make run`` command. See :ref:`running_the_sdk_examples` for more details.
216 Chrome Web Store metadata
217 ~~~~~~~~~~~~~~~~~~~~~~~~~
219 Applications published in the Chrome Web Store must be accompanied by CWS
220 metadata; specifically, a Chrome Web Store manifest file named
221 ``manifest.json``, and at least one icon.
223 Below is an example of a CWS manifest file for a **hosted application**:
228 "name": "My NaCl App",
229 "description": "Simple game implemented using Native Client",
236 "http://mysubdomain.example.com/"
239 "web_url": "http://mysubdomain.example.com/my_app_main_page.html"
245 For a **packaged application**, you can omit the urls field, and replace the
246 ``web_url`` field with a ``local_path`` field, as shown below:
251 "name": "My NaCl App",
252 "description": "Simple game implemented using Native Client",
260 "local_path": "my_app_main_page.html"
265 You must put the ``manifest.json`` file in the same directory as your
266 application's main HTML page.
268 If you don't have icons for your application, you can use the following icons as
275 .. |ICON16| image:: /images/icon16.png
276 .. |ICON128| image:: /images/icon128.png
278 Put the icons in the same directory as the CWS manifest file. For more
279 information about CWS manifest files and application icons, see:
281 * `Chrome Web Store Tutorial: Getting Started
282 <https://developers.google.com/chrome/web-store/docs/get_started_simple>`_
283 * `Chrome Web Store Formats: Manifest Files
284 <http://code.google.com/chrome/extensions/manifest.html>`_
286 Technique 1: Local server
287 =========================
289 To run your application from a local server:
291 * Enable the :ref:`Native Client flag <flag>` in Chrome.
292 * Start a :ref:`local web server <web_server>`.
293 * Put your application under the examples directory in the SDK bundle you are
294 using (e.g., in the directory ``pepper_31/examples/my_app``).
295 * Access your application on the local server by typing the location of its
296 HTML file in Chrome, e.g.:
297 ``http://localhost:5103/my_app/my_app_main_page.html``.
302 **Note:** You don't have to use a local web server---you can use another
303 server if you already have one running. You must still enable the Native
304 Client flag in order to run your application from the server.
306 Technique 2: Packaged application loaded as an unpacked extension
307 =================================================================
309 For development purposes, Chrome lets you load a packaged application as an
310 unpacked extension. To load and run your packaged application as an unpacked
313 #. Create a Chrome Web Store manifest file and one or more icons for your
316 * Follow the instructions above under Chrome Web Store metadata to create
318 * Note that the CWS manifest file should contain the ``local_path`` field
319 rather than the ``web_url`` field.
320 #. Put the CWS manifest file and the application icon(s) in the same directory
321 as your application's main HTML page.
322 #. Load the application as an unpacked extension in Chrome:
324 * Bring up the extensions management page in Chrome by clicking the menu
325 icon |menu-icon| and choosing **Tools > Extensions**.
326 * Check the box for **Developer mode** and then click the **Load unpacked
329 * In the file dialog that appears, select your application directory. Unless
330 you get an error dialog, you've now installed your app in Chrome.
331 #. Open a new tab in Chrome and click the **Apps** link at the bottom of the
332 page to show your installed apps:
334 #. The icon for your newly installed app should appear on the New Tab page.
335 Click the icon to launch the app.
337 For additional information about how to create CWS metadata and load your
338 application into Chrome (including troubleshooting information), see the
339 `Chrome Web Store Tutorial: Getting Started
340 <https://developers.google.com/chrome/web-store/docs/get_started_simple>`_.
342 See also :ref:`run_sdk_examples_as_packaged`.
344 Technique 3: Hosted application loaded as an unpacked extension
345 ===============================================================
347 For development purposes, Chrome lets you load a hosted application as an
348 unpacked extension. To load and run your hosted application as an unpacked
351 #. Start a web server to serve your application.
353 * You can use the :ref:`local web server <web_server>` included with the
354 Native Client SDK if you want.
355 #. Upload your application (.html, .nmf, .nexe, .css, .js, image files, etc.)
358 * If you're using the local server included with the Native Client SDK,
359 simply put your application under the ``examples`` directory in the SDK
360 bundle you are using (e.g., in the directory
361 ``pepper_31/examples/my_app``).
362 #. Create a Chrome Web Store manifest file and one or more icons for your
365 * Follow the instructions above under :ref:`Chrome Web Store metadata
366 <metadata>` to create these files.
367 * In the CWS manifest file, the ``web_url`` field should specify the
368 location of your application on your server. If you're using the local
369 server included with the SDK, the ``web_url`` field should look something
370 like ``http://localhost:5103/my_app/my_app_main_page.html``.
371 #. Put the CWS manifest file and the application icon(s) in the same directory
372 as your application's main HTML page.
373 #. Load the application as an unpacked extension in Chrome:
375 * Bring up the extensions management page in Chrome by clicking the menu
376 icon |menu-icon| and choosing **Tools > Extensions**.
377 * Check the box for **Developer mode** and then click the **Load unpacked
380 * In the file dialog that appears, select your application directory. Unless
381 you get an error dialog, you've now installed your app in Chrome.
382 #. Open a new tab in Chrome and click the **Apps** link at the bottom of the
383 page to show your installed apps:
385 #. The icon for your newly installed app should appear on the New Tab page.
386 Click the icon to launch the app.
388 For additional information about how to create CWS metadata and load your
389 application into Chrome (including troubleshooting information), see the
390 `Chrome Web Store Tutorial: Getting Started
391 <https://developers.google.com/chrome/web-store/docs/get_started_simple>`_.
393 Technique 4: Chrome Web Store application with trusted testers
394 ==============================================================
396 When you're ready to test your application more broadly, you can upload the
397 application to the Chrome Web Store and let some trusted testers run it. Here
400 #. Create the Chrome Web Store metadata required to publish your application:
402 * First, create a Chrome Web Store manifest file and one or more icons for
403 your application, as described above under :ref:`Chrome Web Store metadata
404 <metadata>`. Note that packaged applications must have at least two icons
405 (a 16x16 icon and a 128x128 icon).
406 * You also need to create the following additional assets before you can
407 publish your application:
409 * a screenshot (size must be 640x400 or 1280x800)
410 * a promotional image called a "small tile" (size must be 440x280)
412 #. For a **packaged application**:
414 * Create a zip file with the CWS manifest file, the application icons, and
415 all your application files (.html, .nmf, .nexe, .css, .js, image files,
418 #. For a **hosted application**:
420 * Create a zip file with the CWS manifest file and the application icon(s).
421 * Upload the application files (.html, .nmf, .nexe, .css, .js, image files,
422 etc.) to the server on which the application is being hosted.
423 * Use `Google Webmaster Tools <http://www.google.com/webmasters/tools/>`_ to
424 verify ownership of the web site on which the application runs.
426 #. Log in to the `Chrome Web Store Developer Dashboard
427 <https://chrome.google.com/webstore/developer/dashboard>`_.
429 * The first time you log in, click the "Add new item" button to display the
430 Google Chrome Web Store Developer Agreement. Review and accept the
431 agreement and then return to the `Developer Dashboard
432 <https://chrome.google.com/webstore/developer/dashboard>`_.
434 #. Click "Edit your tester accounts" at the bottom of the Developer Dashboard.
435 #. Enter a series of email addresses for your testers (separated by commas or
436 whitespace), and click the "Save Changes" button.
437 #. Click the "Add new item" button to add your application to the Chrome Web
439 #. Click the "Choose file" button and select the zip file you created earlier.
440 #. Click the "Upload" button; this uploads your zip file and opens the "Edit
442 #. Edit the following required fields on the "Edit item" page:
444 * Upload an application icon.
445 * Upload a screenshot.
446 * Upload a small tile.
447 * Select a category for your application (accounting application, action
449 * Select a language for your application.
450 #. If you are an owner or manager of a Google Group, you can select that group
451 in the "Trusted testers" field.
453 * You may want to create a Google Group specifically for your testers. When
454 you add a group to the "Trusted testers" field, all group members will be
455 able to test the application, in addition to the individuals you added to
456 the "trusted tester accounts" field on the Developer Dashboard.
457 #. Click the "Publish to test accounts" button at the bottom of the page and
459 #. A page comes up that shows your application's listing in the Chrome Web
460 Store. Copy the URL and mail it to your trusted testers.
462 * When you publish an application to test accounts, the application's CWS
463 listing is visible only to you and to people who are logged into those
464 accounts. Your application won't appear in search results, so you need to
465 give testers a direct link to your application's CWS listing. Users won't
466 be able to find the application by searching in the CWS.
468 To publish an application to the world after publishing it to test accounts,
469 you must first unpublish the application. For additional information see
471 <https://developers.google.com/chrome/web-store/docs/publish>`_, and in
472 particular `Publishing to test accounts
473 <https://developers.google.com/chrome/web-store/docs/publish#testaccounts>`_.
475 .. |menu-icon| image:: /images/menu-icon.png
476 .. |extensions| image:: /images/extensions-management.png
477 .. |new-tab-apps| image:: /images/new-tab-apps.png