LightBlog

mercredi 18 juillet 2018

Android Q+ may use the Vulkan Graphics API to render the UI

Vulkan Graphics API Android Q

The next major version of Android, Android 9, is set to be released next month for multiple devices. Unlike Android Oreo where the main improvements were mostly under-the-hood, Android P offers more user-facing features such as the revamped user interface, navigation gestures, and Digital Wellbeing while also continuing work on Project Treble. But behind-the-scenes, Google has revamped how graphics rendering works on Android. In Android Oreo, Google began testing an OpenGL hardware-accelerated backend to the Skia graphics engine which was completed in Android P. Google isn't stopping there, however, as the company plans on implementing the Vulkan backend of the Skia graphics engine which will land in Android Q or a later release.

The evidence for this comes from a comment submitted by a Google engineer on the open source Chromium Gerrit. The comment is in reference to a bug report on the upcoming implementation of the Vulkan Graphics API for the Google Chrome browser on Android. The comment states that, sometime in the future, "there will be a requirement" to have Vulkan API support for the Android WebView when the "[Android] framework is going to start using Vulkan for HWUI."

Android Q Vulkan Graphics UI Rendering


Graphics Rendering in Android

For background knowledge, Skia is an open source, 2D graphics engine that's used in Google Chrome, Chrome OS, Android, Flutter, and other major projects. Skia is a graphics rendering engine used in early versions of Android to render View and Canvas (the classes used to build and draw the UI in most apps.) Android 3.0 Honeycomb partially replaced Skia with HWUI, a library that converts Canvas commands into hardware-accelerated OpenGL commands, though the 2D Skia graphics library was still used in some areas like path rasterization. In parallel, Google also created an OpenGL backend for Skia. The result is that some graphics calls would be made to the Skia library while others would go to the OpenGL backend. To clean up the graphics architecture, Google decided that HWUI will now talk to Skia, which itself talks to its hardware-accelerated OpenGL backend, to do UI rendering. The result is that graphics calls for the UI framework will follow one path and not two.

Some of you may remember a Developer Option called "Set GPU Renderer" in early Developer Previews of Android 8.0 Oreo. This developer option allowed you to force HWUI to use Skia and its hardware-accelerated OpenGL backend as the GPU renderer for the UI framework. The developer option was removed as this behavior is now the default.

Android Q Vulkan Graphics UI Rendering

"Set GPU Renderer" developer option in Android O Developer Previews

Android Q Vulkan UI Rendering Android Q Vulkan UI Rendering Android Q Vulkan UI Rendering

The next move by Google to improve graphics rendering is to switch from an OpenGL hardware-accelerated backend to a Vulkan hardware-accelerated backend. It's not at all an unexpected move and is a logical progression, but it's nice to see that work is being done on improving graphics rendering on Android. While the move won't fix every source of lag on Android, it should reduce frame render times by cutting down on processing done by the CPU. Given that this is very much a work-in-progress (it's unfinished in Android P), we expect it to launch with Android Q or another future Android release.


A Preview of using the Vulkan Graphics API to Render the UI

It's actually possible to test the Vulkan backend for Skia on Android P now. There's a debug parameter that you can set to force Android to use the Skia Vulkan pipeline. Simply reboot after adding the following line to /system/build.prop:

  debug.hwui.renderer=skiavk  
Android Q Vulkan UI Rendering Android Q Vulkan UI Rendering

Adding this line on a device running Android Oreo will result in a crash, so we don't recommend it. While your device will boot up with this flag on Android P, it's quite buggy at the moment. The Google Pixel Launcher mostly fails to render any backgrounds, animated videos in Settings fail to load, and there are several graphical glitches with the status bar and notifications. Other than that, most apps, even YouTube videos and games like Doodle Jump, seem to load just fine.

Many thanks to XDA Recognized Developer luca020400 for their help in writing this article, for providing the screenshots showing the disassembled libhwui.so code, and for providing the debug flag to test the Vulkan backend.


Source 1: Talkin' Treble: How Android engineers are winning the war on fragmentation [ArsTechnica]

Source 2: Android Graphics Pipeline: From Button to Framebuffer [inovex blog]

Source 3: Skia web page [Google]

Source 4: Comments by Romain Guy, Android Graphics & Kotlin @ Google [Reddit]



from xda-developers https://ift.tt/2Luymb9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire