What is this console warning I keep getting - Deferred long-running timer task(s) to improve scrolling smoothness?

13,385

The warning is telling you that your timer wasn't fired on time because it is a long running callback (> 50ms) and the user was/is about to scroll. While your callback is running, Chrome can't start scrolling the page so this results in "jank", user input not being handled in a timely manner. To make the experience better for the user, Chrome decided to postpone firing that callback until a time where running it won't negatively affect the user.

I don't know the details of what you're trying to do, but the correct way to do things would be to chunk up your one big callback into smaller batches and spread them out so that any one call will not noticeably delay user actions. You could additionally look at using requestIdleCallback which will call your function only when Chrome is idle and is ideally suited for non-time critical tasks. (However, requestIdleCallback is supported only on Chrome as of now).

Share:
13,385
tyler_mitchell
Author by

tyler_mitchell

Software Developer - Mobile Applications Architect

Updated on July 24, 2022

Comments

  • tyler_mitchell
    tyler_mitchell almost 2 years

    My Application is a Cordova App. This week I've seen a lot of warnings in my console:

    Deferred long-running timer task(s) to improve scrolling smoothness. See crbug.com/574343.
    

    Never seen it before this week. I do use alot of settimeouts as some of the processes are quite large and therfore aren't rendering to the user that its processing.

    // GETS MEDICINES VIA MYCLOUD
    function getMedicinesFromServer() {
        // Start Process
        myProcess("Syncing Medicines", true);
        setTimeout(function () {
                var data = getAllModifiedMedicines(viewModel.MedicineCupboard());
                sendAllMedicines(data);
        }, 300);
    }
    

    Is this a false positive or is there a better way.

    Full Reason for these silly timeouts is to ensure the user knows when they click a button to push data up they are made aware.

    Old way:

    myProcess("Syncing Medicines", true);
    var data = getAllModifiedMedicines(viewModel.MedicineCupboard());
    sendAllMedicines(data);
    

    Didn't guarantee rendering to user the process.