Unpredictable Chrome Performance Optimization Implications

    Hello! In the latest release, Chrome detected a very unusual browser behavior. This behavior caused new unusual errors in my web script. And I decided to share how they optimize the performance of Chrome, and about what unusual consequences you may encounter.



    Go.


    The anomaly we encountered looks like this: 


    1. The user uses the web application.
    2. Then the user clicks a button in the application. This button saves information on the page and opens a new tab (with saved information).
    3. In reality, information is not saved in a new tab. 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 in a new tab (after updating the page).

    Reason for 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 to reduce the resources allocated for 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 operation of the javascript, but also other APIs. For example, in our case, operations on IndexedDB in a browser began to work fantastically slowly. 


    How to fix


    To get around such “behavior features”, we had to call our own asynchronous callbacks synchronously, and reduce the dependence on system asynchronous APIs.


    Also popular now: