Wear OS apps that use standard views already benefit from hardware-accelerated graphics rendering. In contrast, watch faces are usually implemented using canvases, so they don't automatically get hardware acceleration.
Why use a hardware-accelerated canvas for your watch face?
In most cases, your watch face renders at a higher frame rate when using a hardware-accelerated canvas. At higher frame rates, animations and transitions appear smoother to the eye. For your users, these benefits are self-evident.
When you use a hardware-accelerated canvas, you can also access more UI performance data about your watch face. For example, you can only access the detailed frame information mentioned in Measure UI performance when you are using a hardware-accelerated canvas.
Request hardware acceleration for your watch face
Is my watch face using hardware acceleration?
You can check whether your watch face is currently using hardware acceleration using either the developer options or adb.
Check using developer options
To check whether your watch face is using hardware acceleration using the developer options, follow these steps:
- On a Wear OS device, navigate to Settings > Developer options.
Enable Debug GPU profiling.
This option draws an overlay on top of visible surfaces (one per each surface) to show the amount of time spent in each stage of GPU rendering for that surface.
On the device, navigate back to your watch face.
If your watch face is using hardware accelerated canvas, you'll see a new bar (moving from right to left) for each rendered frame of your watch face.
Check using adb
To check whether your watch face is using hardware acceleration using adb, follow these steps:
- On a Wear OS device, change the watch face to your watch face that you want to test.
- Let the watch face run for a few seconds in interactive mode.
Run the following adb command to check whether your watch face is using hardware acceleration:
adb shell dumpsys gfxinfo [package-name]
After running the command, you get an output similar to the following example:
Applications Graphics Acceleration Info: Uptime: 2239933 Realtime: 13568751 ** Graphics info for pid 1100 [package-name] ** Stats since: 59875589194ns Total frames rendered: 1213 Janky frames: 0 (0.00%) 50th percentile: 7ms 90th percentile: 18ms 95th percentile: 25ms 99th percentile: 150ms Number Missed Vsync: 0 Number High input latency: 0 Number Slow UI thread: 0 Number Slow bitmap uploads: 0 Number Slow issue draw commands: 0 Number Frame deadline missed: 0 ...
In this sample output, notice the line that says
Total frames rendered.
Generally, if you see this frame data in your output, then your watch face is
using an accelerated canvas. Otherwise the number for
Total frames rendered
(and other frame data numbers in the report) will normally be zero.
However, because the
gfxinfo is output for your app's full package, you might
see some frame time information from something other than a hardware-accelerated
canvas, such as an
Activity that your app uses for a configuration screen. To
tell the difference, make sure that your watch face is the only surface that is
visible and then rerun the
adb shell dumpsys gfxinfo command to verify if the
Total frames rendered increases.
Follow these best practices to ensure the best possible experience for your users.
Maximize battery life
If your watch face has long-running animations, using hardware acceleration can greatly lower the battery life of a device. This problem can get even worse if your watch face tries to draw in every frame. To avoid negatively impacting your users, you shouldn't have long-running animations in your watch face. This guideline is not specific to using hardware acceleration, but because using hardware acceleration increases the number of frames you're able to draw, it is even more important to follow. For more information, see Best practices for animations.
Use supported drawing operations
Some drawing operations are not supported when using hardware
If you have a small code path that uses an unsupported operation, you can create
a bitmap backed canvas and then draw that bitmap into the watch face's canvas
Maintain compatibility when using hardware acceleration
Hardware acceleration is available on Wearuld OS devices that run Android 9 (API
level 28) or higher. If you want to avoid a specific draw operation on older
devices (where hardware acceleration is not available) or an unsupported draw
operation on a hardware accelerated canvas, you can check
and then provide the alternative functionality.