Search code examples
google-nativeclient

Samples don't work in Google NaCl rev 18


I'm trying to use the latest Google NaCl SDK. Following the instructions at https://developers.google.com/native-client/pepper18/devguide/tutorial

I downloaded the naclsdk tool from their site, ran update, and got a pepper_18 folder.

I set NACL_SDK_ROOT to the pepper_18 folder, went in to 'examples' and ran make. Everything seemed to compile just fine.

I started Chrome, looked in about: flags and about: plugins, and verified that NaCl is enabled. I installed the SDK Examples app (from: https://developers.google.com/native-client/pepper18/sdk/examples) and that works just fine.

Then I tried to run my locally built and hosted examples, going to http://localhost: 5301. The HTML loads fine but the NaCl content does not load. In the hello world examples, it says "Status: LOADING..." forever.

I double checked the HTTP server logs and I don't see any errors there. Is there another place I should be looking for logged errors?


Solution

  • Check for version mismatch

    In Chrome navigate to about:version and check that the major version of Chrome is at least that of the Pepper version you used to build your examples.

    Check the JavaScript console in Chrome for any errors

    You can find it by clicking the wrench icon in the upper right-hand corner in Chrome and selecting Tools -> JavaScript Console.

    Inspect the NaCl module for further information

    In the JavaScript console, you can also inspect the embed element of the NaCl module. E.g., if the embed tag has id="nacl_module" you can inspect it by typing

    theModule = document.getElementById('nacl_module');

    theModule.lastError;

    Check Chrome's output to stdout/stderr

    On Mac or Linux start Chrome from the terminal and look at the output on the console. E.g., on the Mac, you'd typically go

    /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --enable-nacl

    On Windows, Chrome does not write to the terminal if started from a command prompt. For this reason you need to redirect stdout/stderr from Chrome by setting the environment variables NACLLOG, NACL_EXE_STDOUT, and NACL_EXE_STDERR. Point them to different files, e.g.,

    NACLLOG = c:\my_project\nacl.log

    NACL_EXE_STDOUT = c:\my_project\nacl_stdout.log

    NACL_EXE_STDERR = c:\my_project\nacl_stderr.log

    Then (re-)start Chrome (making sure these environment variables are in effect).

    Connect a debugger

    Instructions on using the debugging support (currently only 64-bit Windows and 64-bit Linux) are available at https://developers.google.com/native-client/pepper18/beta-docs/debugging.

    Restarting Chrome means closing all windows

    When developing for Native Client one often restarts Chrome. It is important to close all Chrome windows; otherwise it hasn't actually restarted.