Chromium's process architecture has graphics access restricted to a separate GPU-process. There are several reasons why this could make sense, three common ones are: Security, Robustness and Dependency Separation.
GPU access restricted to a single process requires an efficient framework for communication over IPC from the other processes, and most likely a framework for composition of surfaces. This talk describes both the possible motivations for this kind of architecture and Chromium's solution for the IPC framework. We will demonstrate how a multi-process program can compose into a single window on Linux.
2. Isolating GPU Access
in its own process
@pati_gallardo Patricia Aas
Foss-North, Gothenburg, Sweden, 2018
3. Patricia Aas - Vivaldi Browser
Programmer - mainly in C++
Currently : Vivaldi Technologies
Previously : Cisco Systems, Knowit, Opera Software
Master in Computer Science - main language Java
Twitter : @pati_gallardo
16. Example
Texture memory being leaked across processes
- From Other Programs on the Users Machine
- From Other Tabs
- From the Browser
@pati_gallardo
20. Graphics Drivers Crashing the Browser
- Prevent bugs in GPU drivers from crashing the browser
- Make sure graphics code in WebGL can’t crash the browser
- Compensate for Graphics Driver Bugs/Inconsistencies
@pati_gallardo
25. “We can solve any problem by introducing an extra
level of indirection.
…except for the problem of too many levels of
indirection”
Fundamental theorem of software engineering
Andrew Koenig/Butler Lampson/David J. Wheeler
@pati_gallardo
26. - What is Chromium?
- Why have a GPU process?
- Communication Architecture
- Passing A Video Frame
- Can I Use?
@pati_gallardo
30. High Level Design
Client - Server Architecture
Emulates OpenGl ES2.0
Actual Graphics Implementation is Platform Specific
Composition in GPU Process
Page Composition Controlled From Renderer
@pati_gallardo
31. OpenGL ES2 calls are serialized into “Commands” That are
placed in a Ring Buffer in Shared Memory called a
“Command Buffer”. The GPU process de-serializes them,
does validation, maybe some workarounds, and executes
them using the Platform Graphics System.
@pati_gallardo
Implementation Design
32. Client
Renderer / Browser
- Write commands to
shared memory
- Update ‘put’ pointer
- Signal GPU process
@pati_gallardo
33. Server
GPU Process
- Read commands from
shared memory
- Validate command and
arguments
- Make actual call@pati_gallardo
36. Sync Token - Inserts a synchronization
fence into the command
stream
- Can be attached to a
resource (texture) that
cannot be used before all
previous commands have
been processed
@pati_gallardo
37. Mailbox Holder
1. Mailbox - unique name
2. SyncToken - fence
3. Texture Target Type (if
texture backed)
@pati_gallardo
38. - What is Chromium?
- Why have a GPU process?
- Communication Architecture
- Passing A Video Frame
- Can this work for you?
@pati_gallardo
40. Compositing in Chromium
- Software Compositing is Done In the Browser Process
- Hardware/GPU Compositing is Done in the GPU Process
(Except on Android where there is a GPU thread in the Browser Process)
@pati_gallardo
41. Insert Some Hand Waving
The full architecture is
massive
We will follow one path
A software decoded video
frame
@pati_gallardo
43. Software Decoded Video Frame
- Decoded Frame in Memory in RENDERER PROCESS
- GPU Composition is done in the GPU PROCESS
- The Frame needs to be uploaded to the GPU as a Texture
@pati_gallardo
44. “At a high enough level of
abstraction, everything looks the
same.”
Law of PowerPoint Architecture
Patricia Aas, 2018
@pati_gallardo
49. OES_EGL_image_external
Extension that creates EGLImage texture targets from EGLImages
“Each TEXTURE_EXTERNAL_OES texture object may require up to 3
texture image units for each texture unit to which it is bound.”
@pati_gallardo
50. VideoFrame VideoFrame
Memory Buffer
V Plane
Y Plane
U Plane
Shared Memory Gpu ProcessRenderer
Transform the Video Frame into a GPU Resource
Y Plane Texture
UV Plane Texture
Plane Resources
Y Plane
GpuMemoryBufferUV Planes
GpuMemoryBuffer
MailboxHolder
SyncToken
MailboxMailbox
MailboxHolder
74. Share Group
- Command Buffers in the same share group
must be in the same Command Stream
- gl::GLFence
- eglFenceSyncKHR (EGL_KHR_fence_sync)
- eglWaitSyncKHR (EGL_KHR_wait_sync)
@pati_gallardo