Commit 4ade6b1b authored by Bo Liu's avatar Bo Liu Committed by Commit Bot

gpu: Allow embedder to stop gpu process launch

Add a method to ContentBrowserClient. Note this controls gpu process
"launch" for in-process GPU as well. The method still allows using an
existing GPU process, so in-process case should be minimally impacted so
probably not worth carving out special conditions for it.

For now, only call this new API from BrowserGpuChannelHostFactory, which
controls GPU clients in the browser process. Clients in child process is
more risky, so holding going to do that part in a follow up CL instead.

ChromeContentBrowserClient on android implements the API by checking if
there are running or paused activities. Paused activity may still be
visible, so allow it to launch GPU in that case.

Bug: 779211
Change-Id: Ic48acc9f9ab6134371d7f193d9031e912a05d947
Reviewed-on: https://chromium-review.googlesource.com/783495Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519529}
parent 30eb61bd
......@@ -286,6 +286,7 @@
#elif defined(OS_LINUX)
#include "chrome/browser/chrome_browser_main_linux.h"
#elif defined(OS_ANDROID)
#include "base/android/application_status_listener.h"
#include "chrome/browser/android/app_hooks.h"
#include "chrome/browser/android/chrome_context_util.h"
#include "chrome/browser/android/devtools_manager_delegate_android.h"
......@@ -1054,6 +1055,18 @@ content::WebContentsViewDelegate*
return CreateWebContentsViewDelegate(web_contents);
}
bool ChromeContentBrowserClient::AllowGpuLaunchRetryOnIOThread() {
#if defined(OS_ANDROID)
const base::android::ApplicationState app_state =
base::android::ApplicationStatusListener::GetState();
return base::android::APPLICATION_STATE_UNKNOWN == app_state ||
base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES == app_state ||
base::android::APPLICATION_STATE_HAS_PAUSED_ACTIVITIES == app_state;
#else
return true;
#endif
}
void ChromeContentBrowserClient::RenderProcessWillLaunch(
content::RenderProcessHost* host) {
int id = host->GetID();
......
......@@ -98,6 +98,7 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
bool* in_memory) override;
content::WebContentsViewDelegate* GetWebContentsViewDelegate(
content::WebContents* web_contents) override;
bool AllowGpuLaunchRetryOnIOThread() override;
void RenderProcessWillLaunch(content::RenderProcessHost* host) override;
GURL GetEffectiveURL(content::BrowserContext* browser_context,
const GURL& url,
......
......@@ -139,7 +139,10 @@ void BrowserGpuChannelHostFactory::EstablishRequest::OnEstablishedOnIO(
const gpu::GpuFeatureInfo& gpu_feature_info,
GpuProcessHost::EstablishChannelStatus status) {
if (!channel_handle.is_valid() &&
status == GpuProcessHost::EstablishChannelStatus::GPU_HOST_INVALID) {
status == GpuProcessHost::EstablishChannelStatus::GPU_HOST_INVALID &&
// Ask client every time instead of passing this down from UI thread to
// avoid having the value be stale.
GetContentClient()->browser()->AllowGpuLaunchRetryOnIOThread()) {
DVLOG(1) << "Failed to create channel on existing GPU process. Trying to "
"restart GPU process.";
main_task_runner_->PostTask(
......
......@@ -64,6 +64,10 @@ WebContentsViewDelegate* ContentBrowserClient::GetWebContentsViewDelegate(
return nullptr;
}
bool ContentBrowserClient::AllowGpuLaunchRetryOnIOThread() {
return true;
}
GURL ContentBrowserClient::GetEffectiveURL(BrowserContext* browser_context,
const GURL& url,
bool is_isolated_origin) {
......
......@@ -201,6 +201,9 @@ class CONTENT_EXPORT ContentBrowserClient {
virtual WebContentsViewDelegate* GetWebContentsViewDelegate(
WebContents* web_contents);
// Allow embedder control GPU process launch retry on failure behavior.
virtual bool AllowGpuLaunchRetryOnIOThread();
// Notifies that a render process will be created. This is called before
// the content layer adds its own BrowserMessageFilters, so that the
// embedder's IPC filters have priority.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment