📜 ⬆️ ⬇️

Unpredictable effects of Chrome performance optimization

Hello! In the latest release, Chrome discovered a very unusual browser behavior. This behavior caused new unusual errors in my web script. And I decided to share how to optimize the performance of Chrome, and about what unusual consequences can be encountered.



Go.


The anomaly we are facing looks like this:


  1. The user is using the web application.
  2. Then the user presses the button in the application. This button saves information on the page and opens a new tab (with saved information).
  3. In reality, the new tab information is not saved. This is our bug.
  4. There is also an anomaly: if after that you switch to the first tab (for a second), and then again to a new tab, then the information becomes immediately available on the new tab (after refreshing the page).

Reason for the anomaly


It looks very strange. It seems that Chrome completely blocks the old tab when switching to a new one.
It turned out that recently (release 57, March 14, 2017) Chromium released a release with significant performance optimization. One of the optimizations is the reduction of resources allocated for the work of background tabs. Proof: https://blog.chromium.org/2017/03/reducing-power-consumption-for.html
This optimization blocks the background tab immediately (!) After opening a new one. Moreover, the decrease in performance concerns not only the work of javascript, but also other APIs. For example, in our case, operations on IndexedDB in the browser began to work fantastically slowly.


How to fix


To get around these “behavioral patterns”, we had to call our own asynchronous callbacks synchronously and reduce our dependence on system asynchronous APIs.


')

Source: https://habr.com/ru/post/324532/


All Articles