1--- 2title: 'How to capture an SKP file from the Android Framework' 3linkTitle: 'How to capture an SKP file from the Android Framework' 4--- 5 6## Prerequisites 7 8To set up a newly flashed device for capturing, run the following to make it 9possible for the recording process to write its file: 10 11``` 12adb root 13adb remount 14``` 15 16MSKP files may capture any use of a Skia canvas, and there are two uses in 17Android instrumented to capture them. HWUI, which will show the contents of a 18single application, and RenderEngine which will show interleaved buffers from 19multiple applications and transitions such as portrait-landscape. 20 21## Capturing from HWUI 22 23Set the capture_skp property to enable (but not start) HWUI capture capability. 24This will only affect applications started after setting the 25capture_skp property so you may have to restart the application you wish to 26capture from. 27 28``` 29adb root 30adb shell setprop debug.hwui.capture_skp_enabled true 31``` 32 33Then, each time you want to capture a file: 34 35First, open the application you will be capturing from. Then, trigger capture 36with the following script from the root of your Android tree. (See 37https://source.android.com/docs/setup/download.) 38 39``` 40frameworks/base/libs/hwui/tests/scripts/skp-capture.sh PACKAGE_NAME FRAMES 41``` 42 43`PACKAGE_NAME` is the name of the component or app you want to capture, for 44example: **com.google.android.apps.nexuslauncher**. 45 46`FRAMES` is the number of frames to capture. This is optional and defaults to 1. 47 48## Capturing from RenderEngine 49 50Once before capturing, run the following from the Android root. 51 52``` 53frameworks/native/libs/renderengine/skia/debug/record.sh rootandsetup 54``` 55 56To record all frames that RenderEngine handles over the span of 2 seconds. 57 58``` 59frameworks/native/libs/renderengine/skia/debug/record.sh 2000 60``` 61 62The output file is copied to your current working directory when the device is 63finished serializing it. This can take up to 30 seconds. 64 65There is a small chance that the capture script incorrectly detects that the 66file is complete too early and copies a truncated file off the device. 67It will be unreadable in the debugger. If you suspect this has happened, it's 68likely that you can still retrieve the complete file from the device at 69`/data/user/re_skiacapture_*.mskp` 70 71## Reading the file 72 73Open the resulting file in the [Skia Debugger]. For single frame SKPs, you could 74also use the [Skia Viewer] to view it, or rasterize it with `dm` (see [Skia 75Build Instructions] for how to build `dm`): 76 77``` 78out/Release/dm --src skp --skps FILENAME.skp -w /tmp --config 8888 gpu pdf --verbose 79ls -l /tmp/*/skp/FILENAME.skp.* 80``` 81 82[Skia Build Instructions]: /docs/user/build 83[Skia Debugger]: https://debugger.skia.org 84[Skia Viewer]: /docs/user/sample/viewer/ 85