WEB BROWSER JAVASCRIPT THROTTLING Started: 2021-03-25 Updated: 2023-03-07 This document will go over issues related to Javascript timer action throttling and the Memory/Energy Savers features in web browsers and how these affect the VICIdial Agent Screen. WHAT IS JAVASCRIPT THROTTLING AND HOW DOES IT AFFECT THE VICIDIAL AGENT SCREEN? Prior to 2017, most web browsers limited the frequency of Javascript timers to once-per-second in all tabs and windows. This does not affect VICIdial operations because none of our timers need to run more frequently than once a second. In 2017, the Google Chrome development team announced that, in an effort to reduce power usage, they would begin "throttling" Javascript past the previous once-per-second standard for tabs in the "background" that use more than 1% of CPU cycles on your computer. This change went into effect in Chrome build 57 in March of 2017. In early 2021, Google Chrome build 88 changed this behavior by default and enabled what they call "Intensive Javascript Throttling" which would only affect hidden tabs starting at 5 minutes being hidden, with no audio having played for 30 seconds and no Web RTC connections on the page(like VICIphone). This "Intensive" throttling actually begins as soon as the VICIdial Agent Screen is hidden from view by only allowing it to refresh every 2 seconds, instead of the standard every 1 second that happens when the agent screen is visible. Then after 5 minutes of being hidden, the refresh rate is limited to once every minute(usually at a set number of seconds past the minute, like :02, :22, etc...). At this point, the VICIdial Agent Screen will become unusable unless you make it visible right away, and the agent session will pause automatically. In early 2023, Google Chrome build 110 made a change to Javascript Throttling and also introduced "Memory Saver" and "Energy Saver" features that are enabled by default to further restrict non-active browser tabs. The Throttling change means that hidden tabs will start being throttled after only 10 seconds now(as opposed to 5 minutes before). As for the new "Saver" features, they can be turned off in the Settings -> Performance options. These new chrome browser optimizations do seem to follow the same exemptions as the "Intensive Javascript Throttling" did above, so in most cases agents using Chrome with one of the exemptions methods for that should remain unaffected by these new Chrome features. In our testing, if you are using the "Agent Hidden Browser Sound" method, you may need to reduce the "Agent Hidden Browser Sound Seconds" setting to 10 or even 5 to get it to work 100% of the time. The "Memory Saver" feature also has a session-specific URL-specific exemption available by going to the chrome://discards/ URL in your Chrome browser and selecting a discarded tab and setting it to not be "Auto Discardable", it is important to note this only works for the current browser session, it is not persistent to the URL. NOTE: Any web browser that is based on the Chromium Open-Source codebase, like Google Chrome and Microsoft Edge, might be affected by this issue. HOW TO PREVENT JAVASCRIPT THROTTLING FROM ACTIVATING IN THE VICIDIAL AGENT SCREEN: Below are the ways you can prevent Chrome's Intensive Javascript Throttling from activating on your VICIdial Agent Screens, with more in-depth explanations of each method following below that. Any of these methods will work by themselves. 1. Switch to Firefox 2. Manually disable the Chrome throttling flag, or registry entry, on each of your agent's web browsers 3. Use a WebRTC phone for your agent phone connection(like VICIphone) 4. Enable the VICIdial System Settings for "Agent Hidden Browser Sound" 5. Switch the VICIdial System Setting for "Agent Screen Timer" to 'EventSource' 6. Switch the VICIdial System Setting for "Agent Screen Timer" to 'setTimeoutAudioLoop' More information on each of the above... 1. SWITCH YOUR AGENTS TO THE FIREFOX WEB BROWSER While this may not be the best long-term solution, Firefox has not yet enabled the same kind of Intensive throttling that is now in the Chrome web browser by default, so simply switching to a Firefox web browser will remove the chance that your hidden agent screens will go paused because of this new "feature" in Chrome. You can download the Firefox web browser here: https://www.mozilla.org/en-US/firefox/new/ 2. MANUALLY DISABLE THE CHROME THROTTLING FLAG, OR REGISTRY ENTRY, ON EACH OF YOUR AGENT'S WEB BROWSERS NOTE: The following steps must be done on every computer that you want to disable the Chrome browser Intensive Javascript Throttling on: NOTE: There are different instructions for this depending on the version of Chrome web browser you are using. AFTER CHROME 90 INSTRUCTIONS(after April 26th, 2021 builds): You will first need to enable enable "temporary-unexpire-flags-m88" or "temporary-unexpire-flags-m89", relaunch your Chrome browser, then follow the instructions for "BEFORE CHROME 90" below. - Open your Chrome Web Browser - in the Address bar at the top, put the following(without quotes), then press the "Enter" key: "chrome://flags/#temporary-unexpire-flags-m88" - You will see "Temporarily unexpire M89 flags" highlighted with a pull-down menu on the right side of the screen - Select the "Enabled" option from the pull-down menu - You will see a message at the bottom of your screen: "Your changes will take effect the next time you relaunch Google Chrome." with a button to "Relaunch" - Click on the "Relaunch" button and the old flags will now be visible in Chrome on this computer OR, an alternative option which will require Administrative rights on the computer, is to disable the "IntensiveWakeUpThrottlingEnabled" policy on your computer, https://chromeenterprise.google/policies/#IntensiveWakeUpThrottlingEnabled For Windows workstations, this means adding a new DWORD Registry entry: - Open RegEdit(Registry Editor) on your Windows computer - Go to "HKEY_LOCAL_MACHINE/SOFTWARE/Policies/Google/Chrome" NOTE: You may need to create the "Google" and then "Chrome" Keys yourself - Create a new DWORD entry from the highlighted "Chrome" Key, with a Name of "IntensiveWakeUpThrottlingEnabled" NOTE: this new DWORD should automatically be set with a value of '0' (disabled) after you create it - Close out all Chrome web browser windows and then open Chrome again and test that it is working BEFORE CHROME 90 INSTRUCTIONS: - Open your Chrome Web Browser - in the Address bar at the top, put the following(without quotes), then press the "Enter" key: "chrome://flags/#intensive-wake-up-throttling" - You will see "Throttle Javascript timers in background" highlighted with a pull-down menu on the right side of the screen - Select the "Disabled" option from the pull-down menu - You will see a message at the bottom of your screen: "Your changes will take effect the next time you relaunch Google Chrome." with a button to "Relaunch" - Click on the "Relaunch" button and the Throttling feature will now be disabled in Chrome on this computer NOTE: An alternate option for this method would be to create a new shortcut for the chrome browser using the --disable-background-timer-throttling flag, for example here is what it would look like in Windows: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-timer-throttling 3. USE A WEBRTC PHONE FOR YOUR AGENT PHONE CONNECTION(LIKE VICIPHONE) Having a WebRTC connection active on a Chrome tab will automatically disable Intensive Javascript Throttling. If you already use it for your agent phone connections, then your're set! If not, then I would suggest taking a look at our VICIphone website(it's also free and open-source, just like VICIdial is): https://viciphone.com/ 4. ENABLE THE VICIDIAL SYSTEM SETTINGS FOR "AGENT HIDDEN BROWSER SOUND" Since we wanted to create an option for clients that did not want to have to manually disable throttling on all of their agent workstations(made especially difficult for at-home agents), we added a new feature to VICIdial that you can use if you are running the svn/trunk revision 3399 or higher(that's vicidial.php version '2.14-629c', build '210322-1301' or higher). This new feature will play a barely-audible sound through the agent screen every X seconds(must be less than 30 and more than 0) only when the agent screen is hidden from view, that will prevent Intensive Javascript Throttling in Chrome 88 from activating. The new feature is activated in System Settings, using the "Agent Hidden Browser Sound/volume" and "Agent Hidden Browser Sound Seconds" settings. We have tested the following settings and found them to be effective on all client systems we have used them on: - Set "Agent Hidden Browser Sound" to 'click_quiet' - Set "volume" to '25' - Set "Agent Hidden Browser Sound Seconds" to '20' (for Chrome builds 110+ may need to set this to '10' or even '5') Another option for using this setting without any click sound at all is to use the "20Hz_tone" sound(added in svn/trunk rev. 3693). This audio is inaudible to most people and the file is 5 seconds long, so if you use a 5 second delay it will be constantly playing in the background. This constantly-playing method also allows you to lower the Hidden Browser Sound "volume" to '1' and still be effective. Adding this new feature also required us to add Agent Screen Visibility Logging to VICIdial, so you can now also view statistics of how long your agents' screens were visible to them in the Agent Time Detail report and the User Stats report. NOTE: In Chrome build 110 and higher, you may need to reduce the "Agent Hidden Browser Sound Seconds" setting to 10 or even 5 to get it to work 100% of the time due to new changes in how Javascript Throttling works. 5. SWITCH THE VICIDIAL SYSTEM SETTING FOR "AGENT SCREEN TIMER" TO 'EventSource' Thanks to 'fperdomo' on the VICIdial Forums for posting a simple method using SSE to work-around the Chrome JavasScript Throttling issue by replacing the JavaScript "setTimeout()" with an "EventSource()" that runs once a second. After some fine-tuning and testing in different web browsers, we committed this as an optional System Setting called "Agent Screen Timer" to the VICIdial codebase in svn/trunk revision 3407. Since EventSource SSE uses open connection streaming over HTTP, some older networks and proxy servers may have problems handling the open connections, so be sure to test on your network before enabling during production times. 6. SWITCH THE VICIDIAL SYSTEM SETTING FOR "AGENT SCREEN TIMER" TO 'setTimeoutAudioLoop' Thanks to 'martinch' on the VICIdial Issue Tracker for posting a simple method using an HTML audio tag with the 'loop' option to work-around the Chrome JavasScript Throttling issue by playing of a loop of inaudible 20Hz audio while the agent is logged in. After some fine-tuning and testing in different web browsers, we committed this as another option to the System Setting "Agent Screen Timer" feature in the VICIdial codebase in svn/trunk revision 3694. Since this method will currently disable any other HTML audio sounds playing in the same window, it will break "Agent Browser Call Alerts" if they are enabled on your system. THE FUTURE It looks like the maintainers of Chrome have every intention of increasing Javascript Throttling and "inactive" tab resource reduction in the future, even removing the flag they created to disable Javascript Throttling just 4 months after creating it, but hopefully they will leave at least one of the above methods for exemptions tabs from these features in place. Why not switch the VICIdial Agent Screen from AJAX(Polling) to using streaming server connections (SSE, Server-Sent-Events) like EventSource or WebSockets? First of all, switching to SSE would take a tremendous amount of development and testing time since none of the code is set to work like that currently. Second, this would require moving some of the data processing to the server, and it would require presistent connections to web services, which could greatly reduce webserver capacity. Third, some older networks and proxy servers do not support perpetual connections like SSE uses, which will cause the network to fail to transmit all data to the client workstation, so it is not a one-size-fits-all solution like AJAX has been for the last 16 years. Fourth, there is no guarantee that the Chrome developers won't just target SSE for optimization next. As they continue to tighten resource optimizations in non-visible browser tabs, they will widen the functions that are affected, as we are now seeing with the reduced time to throttling and the new Memory/Energy Saver features introduced in Chrome build 110. FOR MORE INFORMATION Here is the Chrome maintainers post on how Javascript Throttling works, starting in Chrome 88: https://developer.chrome.com/blog/timer-throttling-in-chrome-88/ Here are details on the default changes to Javascript THrottling in Chrome build 110: https://chromestatus.com/feature/5580139453743104 Here are the Chrome maintainers posts on how the "Memory Saver" and "Energy Saver" features work and how to deactivate them, starting in Chrome build 110: https://developer.chrome.com/blog/memory-and-energy-saver-mode/ https://support.google.com/chrome/answer/12929150