• Bo Liu's avatar
    Allow shutdown GPU when not in use · 95570f3a
    Bo Liu authored
    There are roughly two changes in this CL.
    
    First is in CompositorImpl and BrowserGpuChannelHostFactory to drop the
    gpu channel from the browser process when all CompositorImpls are
    destroyed. BGCHF will check if it has the only reference to the
    GpuChannelHost, and if so, destroy it. The check is performed in
    CompositorImpl destructor to minimize impact to chrome; it is possible
    to consider checking when CompositorImpl becomes invisible in the
    future.
    
    Second piece is GpuChannelManager in the GPU process will send a message
    when all GpuChannels are destroyed. This message is passed to
    GpuHostImpl, which will has a timeout of 10s. If there are no pending
    or new establish channel requests in this time, then it will tell
    GpuProcessHost. GpuProcessHost will give the content embedder a chance
    to decide whether to kill the GPU process, and if yes, shutdown
    the GPU process.
    
    There are different GPU shutdown paths. This implementation just
    deletes GpuProcessHost. The benefit over paths that tell the GPU process
    to quit its main loop is deleting GpuProcessHost can guarantee no
    trasient failures. All establish channel request are routed through the
    browser IO thread. GpuHostImpl makes sure to only shutdown when there
    are no requests and the GpuProcessHost is deleted synchrnously on the IO
    thread. So subsequent requests will start by creating a new
    GpuProcessHost and launching a new GPU process.
    
    On Android, deleting GpuProcessHost will remove all bindings to the GPU
    process, at which point Android OS will kill the GPU process; most
    desktop platforms will send sigterm, then after a timeout, sigkill to
    the GPU process. This does not involve cleanly exiting the GPU main
    loop, which in the past has caused crashes.
    
    Enable this behavior in weblayer, which does not use any other
    gpu-hosted services.
    
    Bug: 1058509
    Change-Id: I81055a118d0e9b3f7e8ed8203780ad1b124e3f6c
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102592
    Commit-Queue: Bo <boliu@chromium.org>
    Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
    Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
    Reviewed-by: default avatarkylechar <kylechar@chromium.org>
    Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#750780}
    95570f3a
gpu_process_host.h 9.45 KB