From b0979bd854c10ee87d1227fc7cb9befd50fcbdc0 Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 26 Oct 2021 18:25:18 -0400 Subject: [PATCH] use workaround for Chromebook on first user gesture so that first speech is still quick, see https://github.com/phetsims/gravity-force-lab-basics/issues/303 --- js/accessibility/voicing/voicingManager.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/accessibility/voicing/voicingManager.js b/js/accessibility/voicing/voicingManager.js index 16312e5..1b4454d 100644 --- a/js/accessibility/voicing/voicingManager.js +++ b/js/accessibility/voicing/voicingManager.js @@ -211,6 +211,17 @@ class VoicingManager extends Announcer { // No dispose, as this singleton exists for the lifetime of the runtime. stepTimer.addListener( this.stepQueue.bind( this ) ); + // To get Voicing to happen quickly on Chromebooks we set the counter to a value that will trigger the "engine + // wake" interval on the next animation frame the first time we get a user gesture. See ENGINE_WAKE_INTERVAL + // for more information about this workaround. + const startEngineListener = () => { + this.timeSinceWakingEngine = ENGINE_WAKE_INTERVAL; + + // Display is on the namespace but cannot be imported due to circular dependencies + scenery.Display.userGestureEmitter.removeListener( startEngineListener ); + }; + scenery.Display.userGestureEmitter.addListener( startEngineListener ); + this.initialized = true; }