Commit 8c88ac45 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[WebLayer] Guard against crash due to race condition in translation

In https://chromium-review.googlesource.com/c/chromium/src/+/2297817,
dougarnett@ added a guard against the Java translate infobar
disappearing in between translation being initiated and it completing.
This CL was done in response to Chrome crashes observed in the wild.
While the root cause is not completely known, the hypothesis is that it
is due to InfoBarContainer.java invoking
InfoBarContainerAndroid::SetWebContents(null) in response to changes in
Tab state. That invocation can result in a state where the Java infobar
is gone but the native infobar is still present. Hence, if that change
in Tab state occurs while translation is happening, when translation
finishes the native infobar would receive a callback but without the
Java infobar actually being present.

This flow also occurs in WebLayer, when the Tab loses being active.
Hence this CL preemptively ports the //chrome fix to //weblayer.

Bug: 1093320
Change-Id: Ic967c3fbf2b668b8884841a4cee8c435de49ab7c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302757Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789507}
parent 78537f98
...@@ -205,6 +205,11 @@ translate::TranslateInfoBarDelegate* TranslateCompactInfoBar::GetDelegate() { ...@@ -205,6 +205,11 @@ translate::TranslateInfoBarDelegate* TranslateCompactInfoBar::GetDelegate() {
void TranslateCompactInfoBar::OnTranslateStepChanged( void TranslateCompactInfoBar::OnTranslateStepChanged(
translate::TranslateStep step, translate::TranslateStep step,
translate::TranslateErrors::Type error_type) { translate::TranslateErrors::Type error_type) {
// If the tab lost active state while translation was occurring, the Java
// infobar will now be gone. In that case there is nothing to do here.
if (!HasSetJavaInfoBar())
return; // No connected Java infobar
if (!owner()) if (!owner())
return; // We're closing; don't call anything. return; // We're closing; don't call anything.
......
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