Bug 1811160 - Disable out-of-process WebGL and accelerated canvas when GPU process does not exists on android r=gfx-reviewers,lsalzman

On Android, GPU process exists by default. When GPU process does not exist, an error should disable GPU process.

On Android, WebGL handling process could easily crash. The crash could trigger disable GPU process. Current out-of-process WebGL implementation creates WebGLParent in parent process. Then a crash in parent process could be triggered by WebGL. Then it seems better to disable out-of-process WebGL when GPU process does not exist.

And it seems also better to disable accelerated canvas, since it uses WebGL for acceleration.

Differential Revision: https://phabricator.services.mozilla.com/D167512
This commit is contained in:
sotaro 2023-01-24 06:05:13 +00:00
parent 425961bf5d
commit 53393b26d4
2 changed files with 23 additions and 1 deletions

View File

@ -280,6 +280,8 @@ bool GPUProcessManager::MaybeDisableGPUProcess(const char* aMessage,
gfxConfig::SetFailed(Feature::GPU_PROCESS, FeatureStatus::Failed, aMessage);
}
MOZ_ASSERT(!gfxConfig::IsEnabled(Feature::GPU_PROCESS));
gfxCriticalNote << aMessage;
gfxPlatform::DisableGPUProcess();

View File

@ -2907,7 +2907,13 @@ void gfxPlatform::InitWebGLConfig() {
bool allowWebGLOop =
IsFeatureOk(nsIGfxInfo::FEATURE_ALLOW_WEBGL_OUT_OF_PROCESS);
gfxVars::SetAllowWebglOop(allowWebGLOop);
if (!kIsAndroid) {
gfxVars::SetAllowWebglOop(allowWebGLOop);
} else {
// On android, enable out-of-process WebGL only when GPU process exists.
gfxVars::SetAllowWebglOop(allowWebGLOop &&
gfxConfig::IsEnabled(Feature::GPU_PROCESS));
}
bool threadsafeGL = IsFeatureOk(nsIGfxInfo::FEATURE_THREADSAFE_GL);
threadsafeGL |= StaticPrefs::webgl_threadsafe_gl_force_enabled_AtStartup();
@ -3109,6 +3115,11 @@ static void AcceleratedCanvas2DPrefChangeCallback(const char*, void*) {
feature.UserForceEnable("Force-enabled by pref");
}
if (kIsAndroid && !gfxConfig::IsEnabled(Feature::GPU_PROCESS)) {
feature.Disable(FeatureStatus::Blocked, "Disabled by GPU Process disabled",
"FEATURE_FAILURE_DISABLED_BY_GPU_PROCESS_DISABLED"_ns);
}
// Check if blocklisted despite the default pref.
nsCString message;
nsCString failureId;
@ -3685,6 +3696,15 @@ bool gfxPlatform::FallbackFromAcceleration(FeatureStatus aStatus,
/* static */
void gfxPlatform::DisableGPUProcess() {
gfxVars::SetRemoteCanvasEnabled(false);
if (kIsAndroid) {
// On android, enable out-of-process WebGL only when GPU process exists.
gfxVars::SetAllowWebglOop(false);
// On android, enable accelerated canvas only when GPU process exists.
gfxVars::SetUseAcceleratedCanvas2D(false);
gfxConfig::Disable(Feature::ACCELERATED_CANVAS2D, FeatureStatus::Blocked,
"Disabled by GPU Process disabled",
"FEATURE_FAILURE_DISABLED_BY_GPU_PROCESS_DISABLED"_ns);
}
RemoteTextureMap::Init();
if (gfxVars::UseCanvasRenderThread()) {