dtrainor | ac84a37 | 2015-10-05 18:01:48 | [diff] [blame] | 1 | # Running Blimp |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 2 | [TOC] |
dtrainor | ac84a37 | 2015-10-05 18:01:48 | [diff] [blame] | 3 | |
| 4 | See [build](build.md) for instructions on how to build Blimp. |
| 5 | |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 6 | ## Android Client |
dtrainor | ac84a37 | 2015-10-05 18:01:48 | [diff] [blame] | 7 | |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 8 | ### Installing the client |
| 9 | |
| 10 | Install the Blimp APK with the following: |
| 11 | |
| 12 | ```bash |
| 13 | ./build/android/adb_install_apk.py $(PRODUCT_DIR)/apks/Blimp.apk |
| 14 | ``` |
| 15 | |
| 16 | This is equivalent to just running: |
| 17 | |
| 18 | ```bash |
| 19 | adb install $(PRODUCT_DIR)/apks/Blimp.apk |
| 20 | ``` |
| 21 | |
| 22 | ### Setting up command line flags |
| 23 | |
| 24 | Set up any command line flags with: |
| 25 | |
| 26 | ```bash |
| 27 | ./build/android/adb_blimp_command_line --your-flag-here |
| 28 | ``` |
| 29 | |
| 30 | To see your current command line, run `adb_blimp_command_line` without any |
| 31 | arguments. |
| 32 | |
| 33 | The Blimp client reads command line arguments from the file |
| 34 | `/data/local/blimp-command-line` and the above script reads/writes that file. |
| 35 | Typical format of the file is `chrome --your-flag-here`. So one can use `adb` |
| 36 | directly to create the file: |
| 37 | |
| 38 | ```bash |
| 39 | echo 'chrome --engine-ip=10.0.2.2 --engine-port=25467 --engine-transport=tcp' \ |
| 40 | '--blimp-client-token-path=/data/data/org.chromium.blimp/blimp_client_token' \ |
| 41 | '--vmodule="*=1""' > /tmp/blimp-command-line |
| 42 | adb push /tmp/blimp-command-line /data/local/blimp-command-line |
| 43 | adb shell start chmod 0664 /data/local/blimp-command-line |
| 44 | ``` |
dtrainor | ac84a37 | 2015-10-05 18:01:48 | [diff] [blame] | 45 | |
khushalsagar | a77412e1 | 2016-04-05 22:23:33 | [diff] [blame] | 46 | ### Instructing client to connect to specific host |
| 47 | |
| 48 | To have the client connect to a custom engine use the `--engine-ip`, |
| 49 | `--engine-port`, and `--engine-transport` flags. The possible valid |
| 50 | values for `--engine-transport` are 'tcp' and 'ssl'. |
| 51 | An example valid endpoint would be |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 52 | `--engine-ip=127.0.0.1 --engine-port=25467 --engine-transport=tcp`. |
khushalsagar | a77412e1 | 2016-04-05 22:23:33 | [diff] [blame] | 53 | |
| 54 | SSL-encrypted connections take an additional flag |
| 55 | `--engine-cert-path` which specifies a path to a PEM-encoded certificate |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 56 | file (e.g. `--engine-cert-path=/path_on_device_to/file.pem`). Remember to also |
| 57 | copy the file to the device when using this option. |
khushalsagar | a77412e1 | 2016-04-05 22:23:33 | [diff] [blame] | 58 | |
| 59 | ### Requesting the complete page from the engine |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 60 | The engine sends partially rendered content to the client. To request the |
| 61 | complete page from the engine, use the `--download-whole-document` flag on the |
| 62 | client. |
khushalsagar | a77412e1 | 2016-04-05 22:23:33 | [diff] [blame] | 63 | |
lethalantidote | f16b3ac | 2016-05-16 19:06:52 | [diff] [blame] | 64 | ### Specifying the client auth token file |
| 65 | The client needs access to a file containing a client auth token. One should |
| 66 | make sure this file is available by pushing it onto the device before running |
| 67 | the client. One can do this by running the following command: |
| 68 | |
| 69 | ```bash |
| 70 | adb push /path/to/blimp_client_token \ |
| 71 | /data/data/org.chromium.blimp/blimp_client_token |
| 72 | ``` |
| 73 | |
| 74 | To have the client use the given client auth token file, use the |
| 75 | `--blimp-client-token-path` flag (e.g. |
| 76 | `--blimp-client-token-path=/data/data/org.chromium.blimp/blimp_client_token`) |
| 77 | |
lethalantidote | fb98d14 | 2016-05-16 23:42:03 | [diff] [blame] | 78 | An example of a client token file is |
| 79 | [test_client_token](https://code.google.com/p/chromium/codesearch#chromium/src/blimp/test/data/test_client_token). |
lethalantidote | f16b3ac | 2016-05-16 19:06:52 | [diff] [blame] | 80 | |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 81 | ### Start the Client |
dtrainor | ac84a37 | 2015-10-05 18:01:48 | [diff] [blame] | 82 | Run the Blimp APK with: |
| 83 | |
| 84 | ```bash |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 85 | ./build/android/adb_run_blimp_client |
dtrainor | ac84a37 | 2015-10-05 18:01:48 | [diff] [blame] | 86 | ``` |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 87 | The script under the cover uses adb to start the application: |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 88 | |
| 89 | ```bash |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 90 | adb shell am start -a android.intent.action.VIEW -n org.chromium.blimp/org.chromium.blimp.BlimpRendererActivity |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 91 | ``` |
| 92 | |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 93 | ### Connecting to an Engine running on a workstation |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 94 | To run the engine on a workstation and make your Android client connect to it, |
| 95 | you need to forward a port from the Android device to the host, and also |
| 96 | instruct the client to connect using that port on its localhost address. |
| 97 | |
| 98 | #### Port forwarding |
kmarshall | 6c98508d | 2016-01-11 21:06:28 | [diff] [blame] | 99 | If you are running the engine on your workstation and are connected to the |
| 100 | client device via USB, you'll need remote port forwarding to allow the Blimp |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 101 | client to talk to your computer. |
marcinjb | 446acf65 | 2016-01-15 22:18:36 | [diff] [blame] | 102 | |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 103 | ##### Option A |
| 104 | Follow the |
| 105 | [remote debugging instructions](https://developer.chrome.com/devtools/docs/remote-debugging) |
| 106 | to get started. You'll probably want to remap 25467 to "localhost:25467". |
| 107 | *Note* This requires the separate `Chrome` application to be running on the |
| 108 | device. Otherwise you will not see the green light for the port forwarding. |
dtrainor | 6df6164 | 2016-02-19 16:10:25 | [diff] [blame] | 109 | |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 110 | ##### Option B |
| 111 | If you are having issues with using the built-in Chrome port forwarding, you can |
| 112 | also start a new shell and keep the following command running: |
| 113 | |
| 114 | ```bash |
| 115 | ./build/android/adb_reverse_forwarder.py --debug -v 25467 25467 |
| 116 | ``` |
| 117 | |
sriramsr | 0b6a45f4 | 2016-06-30 19:42:18 | [diff] [blame] | 118 | ### Running the client in an Android emulator |
| 119 | Running the client using an Android emulator is similar to running it on device. |
| 120 | Here are a few gotchas: |
| 121 | |
| 122 | * Build an APK matching the emulator cpu type. The emulator cpu type is most |
| 123 | likely x86, while the default Android build cpu type is ARM. Follow the |
| 124 | Android build instructions above to change the CPU type. |
| 125 | |
| 126 | * Ensure that the emulator is running at least Android Marshmallow so that |
| 127 | fonts are rendered correctly. Also ensure that you have the latest Play |
| 128 | services binaries. |
| 129 | |
| 130 | * Some of scripts under `build/android` will fail to run as it uses `adb scp`. |
| 131 | Follow the instruction above to use `adb` directly. |
| 132 | |
| 133 | * To connect to an Engine running on the host machine, you should use |
| 134 | `10.0.2.2` as `engine-ip` instead of `127.0.0.1` as `127.0.0.1` will refer to |
| 135 | the emulator itself. There is no need of set up |
| 136 | [port forwarding](#Port-forwarding) when this approach is used. |
| 137 | |
| 138 | ## Linux Client |
| 139 | |
| 140 | The Linux client is used for development purpose while the Android client is |
| 141 | shipped. The Linux client is built as part of the `blimp` target. |
| 142 | To run it with local logging enabled, execute: |
| 143 | |
| 144 | ```bash |
| 145 | ./out-linux/Debug/blimp_shell \ |
| 146 | --user-data-dir=/tmp/blimpclient \ |
| 147 | --enable-logging=stderr \ |
| 148 | --vmodule="*=1" |
| 149 | ``` |
| 150 | |
| 151 | ## Running the engine |
| 152 | |
| 153 | ### In a container |
| 154 | For running the engine in a container, see [container](container.md). |
| 155 | |
| 156 | ### On a workstation |
| 157 | The following flags are required to start an Engine instance: |
| 158 | |
nyquist | f87e503 | 2016-02-23 18:45:26 | [diff] [blame] | 159 | * `--blimp-client-token-path=$PATH`: Path to a file containing a nonempty |
| 160 | token string. If this is not present, the engine will fail to boot. |
| 161 | * `--use-remote-compositing`: Ensures that the renderer uses the remote |
| 162 | compositor. |
| 163 | * `--disable-cached-picture-raster`: Ensures that rasterized content is not |
| 164 | destroyed before serialization. |
nyquist | b4fd570 | 2016-03-09 01:42:13 | [diff] [blame] | 165 | * `--android-fonts-path=$PATH`: Path to where the fonts are located. |
| 166 | Typically this would be `out-linux/Debug/gen/third_party/blimp_fonts`. |
khushalsagar | a612bb87 | 2016-03-22 23:02:37 | [diff] [blame] | 167 | * `--disable-remote-fonts`: Disables downloading of custom web fonts in the |
| 168 | renderer. |
lethalantidote | fb98d14 | 2016-05-16 23:42:03 | [diff] [blame] | 169 | |
| 170 | #### Typical invocation |
| 171 | |
| 172 | One can start the engine using these flags: |
| 173 | |
| 174 | ```bash |
| 175 | out-linux/Debug/blimp_engine_app \ |
| 176 | --android-fonts-path=out-linux/Debug/gen/third_party/blimp_fonts \ |
| 177 | --blimp-client-token-path=/tmp/blimpengine-token \ |
| 178 | --enable-logging=stderr \ |
| 179 | --vmodule="blimp*=1" |
| 180 | ``` |