$digest() iterations reached. Aborting! with apply every second

357 views
Skip to first unread message

Steve Wagner

unread,
Apr 9, 2014, 7:09:28 AM4/9/14
to ang...@googlegroups.com
Hi, we have develop an application which gets and displays a lot sensor data (100-500 events per second).

Since it make no sens to update the UI on every event, we decided to call apply instead every second on a daily base. This worked very well until we started using a filter. The filter dose nothing special, it only gets a timestamp as input and outputs it in a human readable string. Since we add it, we getting a lot of
"[$rootScope:infdig] 10 $digest() iterations reached. Aborting!" errors. But the filter works.

So how to prevent the "10 $digest() iterations reached" errors in our case? And whats exactly the problem (read the docs, but dosen't got yet what happens there).

Ziobudda

unread,
Apr 9, 2014, 8:26:24 AM4/9/14
to ang...@googlegroups.com
Hi, in this case why do you not use ng-show/ng-hide ? 

Read this: 


M.

--
Davide Morelli




Steve Wagner

unread,
Apr 9, 2014, 10:16:26 AM4/9/14
to ang...@googlegroups.com
Hi, i am not sure where that can help? The filter dosent display partial content and dose not have a parameter. It converters a timestamp via sugarjs relative http://sugarjs.com/api/Date/relative into a readable date string "90 seconds ago". 

-Steve


--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/Mtjt_dIughs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Sander Elias

unread,
Apr 9, 2014, 10:39:02 AM4/9/14
to ang...@googlegroups.com
Hi Steve,

How many data points are we talking about? The filter makes sure every one of those is updated every digest loop. 1 second might be just a little too short. I think sugarJs might eat up more time than you anticipate! did you try with for example 1500ms?

Regards
Sander

Steve Wagner

unread,
Apr 12, 2014, 3:49:17 AM4/12/14
to ang...@googlegroups.com
Hi Elias,

its one screen page with around 100 different datapoints. The interesting point is that the filter is only used for displaying the age of the last incoming event at the page top, nothing more, only one place. I dont tried other update times yet because one second works very well from viewers perspective. At the most time the filter outputs the value "1 second ago". And the error seems only to happen if the value is higher then 1 second.

I currently do the 1000ms update via:

$interval(function() { /*automatically calls apply*/ }, 1000);

-Steve


--

Lars Christian Jensen

unread,
Apr 12, 2014, 11:09:36 AM4/12/14
to ang...@googlegroups.com
It is essential that a filter returns the same result for the same input every time. Since you said it returns "1 second ago" it seems like you may have a filter that depends on real time (for example if it does new Date()). If that's the case you should probably change your code to:

$interval(function() { var now = new Date(); .... }, 1000);

and use now for all time calculations. Of course I'm only guessing since you don't give a lot of information. An actual code example in jsfiddle.net or similar would make it much easier.


thanks, Lars
Reply all
Reply to author
Forward
0 new messages