Commit 8423272c authored by David Tseng's avatar David Tseng Committed by Commit Bot

Keep Google tts engine alive when Select to Speak is enabled

This change is somewhat of a workaround to shield Chrome from any issues
contained within the underlying tts engine.

Issues:
- the extension system evicts extensions that don't explicitly fire an Activity
  as defined by extensions/browser/activity.h
- audio playback isn't plumbed through as an activity
- engines like Espeak work even for long utterances that hit the eviction time,
  because they trigger the extension api activity via word callbacks
- the Google tts engine currently is buggy for some sentences in emitting
  callbacks

All interleavings of increment/decrements were considered:
- engine loads, enable ChromeVox/STS, disable ChromeVox/STS
- enable ChromeVox, engine loads, enable STS, disable STS/ChromeVox
- enable both STS and ChromeVox, engine loads, disable STS/ChromeVox

In all cases, the keep alive count will be 0 at the end.

R=dmazzoni@chromium.org

Fixed: 1128093
Change-Id: I92b3fc32cd777961e4fbba40c5891c49943b9645
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416571
Commit-Queue: David Tseng <dtseng@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808936}
parent b54f7564
...@@ -196,6 +196,11 @@ void TtsEngineExtensionObserver::OnExtensionLoaded( ...@@ -196,6 +196,11 @@ void TtsEngineExtensionObserver::OnExtensionLoaded(
UpdateGoogleSpeechSynthesisKeepAliveCount(browser_context, UpdateGoogleSpeechSynthesisKeepAliveCount(browser_context,
true /* increment */); true /* increment */);
} }
if (chromeos::AccessibilityManager::Get()->IsSelectToSpeakEnabled()) {
UpdateGoogleSpeechSynthesisKeepAliveCount(browser_context,
true /* increment */);
}
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
} }
...@@ -219,12 +224,14 @@ void TtsEngineExtensionObserver::OnExtensionUnloaded( ...@@ -219,12 +224,14 @@ void TtsEngineExtensionObserver::OnExtensionUnloaded(
void TtsEngineExtensionObserver::OnAccessibilityStatusChanged( void TtsEngineExtensionObserver::OnAccessibilityStatusChanged(
const chromeos::AccessibilityStatusEventDetails& details) { const chromeos::AccessibilityStatusEventDetails& details) {
if (details.notification_type != chromeos::AccessibilityNotificationType:: if (details.notification_type != chromeos::AccessibilityNotificationType::
ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK &&
details.notification_type != chromeos::AccessibilityNotificationType::
ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK)
return; return;
// Google speech synthesis might not be loaded yet. If it isn't, the call in // Google speech synthesis might not be loaded yet. If it isn't, the call in
// |OnExtensionLoaded| will do the increment. If it is, the call below will // |OnExtensionLoaded| will do the increment. If it is, the call below will
// increment. Decrements only occur when toggling off ChromeVox here. // increment. Decrements only occur when toggling off here.
UpdateGoogleSpeechSynthesisKeepAliveCount(profile(), details.enabled); UpdateGoogleSpeechSynthesisKeepAliveCount(profile(), details.enabled);
} }
#endif #endif
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