Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange `gpu-preferences` of Chrome

When execute ps -ef on my machine, I found a very strange/special command line parameter of chrome:

501   536   493   0 二11上午 ??       13:11.48 /Applications/Google Chrome.app/Contents/Versions/69.0.3497.100/Google Chrome Helper.app/Contents/MacOS/Google Chrome Helper --type=gpu-process --field-trial-handle=3535656472344341962,3817030915272013891,131072 --gpu-preferences=KAAAAAAAAACAAAAAAQAAAAAAAAAAAGAAAAAAAAAAAAAIAAAAAAAAADgBAAAmAAAAMAEAAAAAAAA4AQAAAAAAAEABAAAAAAAASAEAAAAAAABQAQAAAAAAAFgBAAAAAAAAYAEAAAAAAABoAQAAAAAAAHABAAAAAAAAeAEAAAAAAACAAQAAAAAAAIgBAAAAAAAAkAEAAAAAAACYAQAAAAAAAKABAAAAAAAAqAEAAAAAAACwAQAAAAAAALgBAAAAAAAAwAEAAAAAAADIAQAAAAAAANABAAAAAAAA2AEAAAAAAADgAQAAAAAAAOgBAAAAAAAA8AEAAAAAAAD4AQAAAAAAAAACAAAAAAAACAIAAAAAAAAQAgAAAAAAABgCAAAAAAAAIAIAAAAAAAAoAgAAAAAAADACAAAAAAAAOAIAAAAAAABAAgAAAAAAAEgCAAAAAAAAUAIAAAAAAABYAgAAAAAAABAAAAAAAAAAAAAAAAUAAAAQAAAAAAAAAAAAAAALAAAAEAAAAAAAAAAAAAAADAAAABAAAAAAAAAAAAAAAA0AAAAQAAAAAAAAAAAAAAAPAAAAEAAAAAAAAAAAAAAAEAAAABAAAAAAAAAAAAAAABIAAAAQAAAAAAAAAAAAAAATAAAAEAAAAAAAAAABAAAABQAAABAAAAAAAAAAAQAAAAsAAAAQAAAAAAAAAAEAAAAMAAAAEAAAAAAAAAABAAAADQAAABAAAAAAAAAAAQAAAA8AAAAQAAAAAAAAAAEAAAAQAAAAEAAAAAAAAAABAAAAEgAAABAAAAAAAAAAAQAAABMAAAAQAAAAAAAAAAQAAAAFAAAAEAAAAAAAAAAEAAAACwAAABAAAAAAAAAABAAAAAwAAAAQAAAAAAAAAAQAAAANAAAAEAAAAAAAAAAEAAAADwAAABAAAAAAAAAABAAAABAAAAAQAAAAAAAAAAQAAAASAAAAEAAAAAAAAAAEAAAAEwAAABAAAAAAAAAABgAAAAUAAAAQAAAAAAAAAAYAAAALAAAAEAAAAAAAAAAGAAAADQAAABAAAAAAAAAABgAAAA8AAAAQAAAAAAAAAAYAAAAQAAAAEAAAAAAAAAAGAAAAEgAAABAAAAAAAAAABgAAABMAAAAQAAAAAAAAAAcAAAAFAAAAEAAAAAAAAAAHAAAACwAAABAAAAAAAAAABwAAAA0AAAAQAAAAAAAAAAcAAAAPAAAAEAAAAAAAAAAHAAAAEAAAABAAAAAAAAAABwAAABIAAAAQAAAAAAAAAAcAAAATAAAA --service-request-channel-token=17030867567105907743

enter image description here

For curiosity, I find the source of chromium, which seems very normal:

namespace gl {
// On dual-GPU systems, expresses a preference for using the integrated
// or discrete GPU. On systems that have dual-GPU support (see
// GpuDataManagerImpl), resource sharing only works between
// contexts that are created with the same GPU preference.
//
// This API will likely need to be adjusted as the functionality is
// implemented on more operating systems.
enum GpuPreference {
  GpuPreferenceNone,
  PreferIntegratedGpu,
  PreferDiscreteGpu,
  GpuPreferenceLast = PreferDiscreteGpu
};
}  // namespace gl

So, is this parameter (KAAAA....) is obscured or some encoding of GPU name? Why such a strange encoding?

like image 623
Tony Avatar asked Oct 06 '18 09:10

Tony


People also ask

Why is Google Chrome using so much of my GPU?

Chrome uses GPU to accelerate web-page rendering, typical HTML, CSS, and graphics elements. In the latest chrome, even the video was offloaded to the graphics chip. Basically it serves two purposes. GPU takes less power than CPU.

Is Chrome using my GPU?

The best way to check whether hardware acceleration is turned on in Chrome is to type chrome://gpu into the address bar at the top of the browser. A whole host of results will be returned but the bit you're interested in is the section titled "Graphics Feature Status."


1 Answers

Any time you see an encoding with lots of AAAA in it, you can bet that it's a Base64 encoding of a binary with lots of nulls in it.

>>> a=b'KAAAAAAAAAQAAAAAAAAAAAGAAAAAAAAAAAAAIAAAAAAAAADgBAAAmAAAAM=='
>>> base64.b64decode(a).hex()
'2800000000000004000000000000000001800000000000000000002000000000000000e004000098000000'

(And speaking more generally, any encoding that uses both upper- and lowercase letters is quite likely Base64. For example, a SHA256 is often given in Base64 compared to hexadecimal for SHA1.)

This corresponds to this interface: https://cs.chromium.org/chromium/src/gpu/ipc/common/gpu_preferences.mojom

The wire format does not seem to be very heavily documented, so if you want to interpret this value you might be best off checking out the chromium tree and building the bindings generator. https://chromium.googlesource.com/chromium/src/+/master/mojo/public/tools/bindings/README.md

like image 78
Josh Lee Avatar answered Oct 18 '22 22:10

Josh Lee