43

Building an Ionic app and have suddenly come across an issue that I am finding really difficult to debug where the browser is 'deferring' long running timer tasks causing my views to execute the code in their controllers only once (even when the controller is explicitly reloaded).

Warning is:

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

What I'm after:

  • An understanding of the warning and why it occurs
  • Any guidance as to how to go about debugging such a warning.

Thanks in advance.

Update I felt it was important to note that while never receiving errors and only warnings as the cause for my problems, I have since rolled back to a working version.

This working version still has warnings appearing but does not affect the running of my application.

Vince
  • 691
  • 1
  • 8
  • 18
  • As it says in the warning, there is at least one task that is blocking this operation. What I would do is to find which task may cause 'heaviness'. If you have no luck on that, I would comment out chunk of the code and see where the warning starts to appear/disappear. – Taku Apr 20 '16 at 06:36
  • @user013948 I have tried with no success, main reason being that the error does not pop up until I have navigated away from the view, either backward or forward. – Vince Apr 20 '16 at 07:14
  • For me this is happening on a "startapp" (almost empty) project with only two states and minimum code on controllers on ionic 1.3.0 when navigating back in history. I only have two pages and when pressing on the second page it gives this error after navigating to the first page. Even then it does not always log this error. I have not noticed this with previous versions of ionic so this would indicate it's an ionic problem. – thepio May 04 '16 at 07:07
  • @thepio what is the error you are receiving? I feel it's important to note that if you are receiving an error and not a warning then perhaps you are in a different situation to me, my 'breaks' were a cause from warnings not errors. Maybe we can assist with your 'error'. – Vince May 04 '16 at 22:32
  • https://bugs.chromium.org/p/chromium/issues/detail?id=574343 – potatopeelings May 04 '16 at 22:58
  • That is the link google chrome console gives you with the warning. Meaning you aren't getting errors your getting the warnings. Just be careful with word choice when commenting as you said it was an error but is actually a warning. – Vince May 04 '16 at 23:01
  • @Vince Yep sorry, warnings* definately warnings – thepio May 05 '16 at 07:26

3 Answers3

6

well in case when you are doing tasks using $timeout , you have got to stop and destroy them else they would create the error you stated

for eg:

var timer = $timeout(
                        function() {
                            console.log( "Timeout executed", Date.now() );
                        },
                        2000
                    );

if you start a timeout as above then you got to destroy the timer as follows :

                    // When the DOM element is removed from the page,
                    // AngularJS will trigger the $destroy event on
                    // the scope. This gives us a chance to cancel any
                    // pending timer that we may have.
$scope.$on(
                        "$destroy",
                        function( event ) {
                            $timeout.cancel( timer );
                        }
                    );
Vishal Wadhawan
  • 1,085
  • 1
  • 9
  • 11
1

I faced this issue when function was called only first time the view was loaded. Noticed this warning in the console but not sure if this is related to function getting called only once. In the controller, I moved my function call inside "$ionicView.enter" and it gets called every time view is loaded.

$scope.$on('$ionicView.enter', function () {
            callMyFunction();
        });

Hope this helps.

  • While in theory that should work, and I had already implemented that, this is not the solution for me but may be one for others. Unfortunately even with this approach the 'enter' event only ever gets called once. – Vince May 04 '16 at 22:30
  • this isn't a solution for me too as I am already using **$ionicView.afterEnter** and still getting this error – Atula May 05 '16 at 11:04
  • @Atula, sorry but my answer was for getting the function executed on view load rather than getting rid of the error.. warning to be precise. I am still not sure if this warning is causing any issue as my app is working fine. – Amit Kumar Meena May 06 '16 at 05:23
  • Same here @Amit. My app working fine too. But can't get rid of this warning. – Atula May 06 '16 at 05:28
1

Sounds like you may have max number of connections in your browser. You may want to decrease your http requests to a single request that contains something which would be 10 requests vs 10 separate http requests.

The answer in regards to your question is something along the lines of maximum http request per browser.

"Max Number of default simultaneous persistent connections per server/proxy:"

Also answered here if I am correctly assuming - Max parallel http connections in a browser?

Community
  • 1
  • 1