cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

$rootScope:inprog Action Already In Progress

SOLVED
Highlighted
Pearl

$rootScope:inprog Action Already In Progress

Hi,

 

I'm trying to call function inside another function, whenever function called it throwing below error

 

ionic.bundle.min.js:150 Error: [$rootScope:inprog] http://errors.angularjs.org/1.5.3/$rootScope/inprog?p0=%24digest
    at ionic.bundle.min.js:40
    at n (ionic.bundle.min.js:169)
    at m.$apply (ionic.bundle.min.js:177)
    at m.$scope.highlightModel (app.js?v1602582296794:903)
    at m.$scope.getPositions (app.js?v1602582296794:777)
    at app.js?v1602582296794:817
    at n (ionic.bundle.min.js:139)
    at m.$eval (ionic.bundle.min.js:176)
    at m.$digest (ionic.bundle.min.js:174)
    at m.$apply (ionic.bundle.min.js:177)
(anonymous) @ ionic.bundle.min.js:150
(anonymous) @ ionic.bundle.min.js:123
$apply @ ionic.bundle.min.js:177
$scope.highlightModel @ app.js?v1602582296794:903
$scope.getPositions @ app.js?v1602582296794:777
(anonymous) @ app.js?v1602582296794:817
n @ ionic.bundle.min.js:139
$eval @ ionic.bundle.min.js:176
$digest @ ionic.bundle.min.js:174
$apply @ ionic.bundle.min.js:177
(anonymous) @ ionic.bundle.min.js:139
ionic.bundle.min.js:150 Error: [$rootScope:inprog] http://errors.angularjs.org/1.5.3/$rootScope/inprog?p0=%24digest
    at ionic.bundle.min.js:40
    at n (ionic.bundle.min.js:169)
    at m.$digest (ionic.bundle.min.js:173)
    at m.$apply (ionic.bundle.min.js:177)
    at m.$scope.highlightModel (app.js?v1602582296794:903)
    at m.$scope.getPositions (app.js?v1602582296794:777)
    at app.js?v1602582296794:817
    at n (ionic.bundle.min.js:139)
    at m.$eval (ionic.bundle.min.js:176)
    at m.$digest (ionic.bundle.min.js:174)

 

Function 1 : 

 

  var data = $scope.modelData[target + '-anchors'];
  //console.log(data);
  if (data != undefined && edata != "") {
    // if we have previously colored an object, undo it
    if ($scope.currentSelection != undefined) {
    }
    else {
      // first time!  unhide the pointer/labels
      tml3dRenderer.setProperties('pinger', {
        shader: "pinger;rings f 5;r f 1;g f 1;b f 0;rate f 3;direction f -1",
        hidden: false
      }
                                 );
    }
    // we should get the ID of the item that was clicked - this is an occurence path id
    var pathid = JSON.parse(edata).occurrence;
    // find the selected item from the data that we loaded from the file ...
    $scope.currentSelection = target + "-" + pathid;
    // ... and get the location of the center center center of the bbox
    var v = data[pathid].anchors["ccc"];
    // move the pointer and label to the "ctc" (center top center) for the selected item
    // note using lower-level TML api to move the node. Note that we also need to position
    // RELATIVE to the actual model
    tml3dRenderer.setTranslation('pinger', $scope.view.wdg['model-1'].x + v[0],
                                 $scope.view.wdg['model-1'].y + v[1],
                                 $scope.view.wdg['model-1'].z + v[2]);
  }
  data = $scope.modelData[target + '-all'];
  if (data != undefined && edata != "") {
    // we should get the ID of the item that was clicked - this is an occurence path id
    //console.log(edata);
    var pathid = JSON.parse(edata).occurrence;
    if ($scope.app.params['mode'] == "Isolate") {
      //console.log(target + ' ----  ' + pathid)
      $scope.isolate(target, pathid);
    }
    else {
      var partNumber = data.components[data.idmap[pathid].cid].properties['item_number'];
      var partName = data.components[data.idmap[pathid].cid].properties['item_1'].toUpperCase();
      var name = data.components[data.idmap[pathid].cid].properties['name'];
      var template = '<ion-popover-view><ion-content>&nbsp;<small style="color:black;">Part Number</br></small> ' + partNumber +
          '&nbsp;</br>&nbsp;<small style="color:black;">Part Description</br></small> ' + partName +
          '&nbsp;</br>&nbsp;<small style="color:black;">Part Name</br></small> ' + name + '&nbsp;</ion-content></ion-popover-view>';
      var popover = $ionicPopover.fromTemplate(template, {
        scope: $scope
      }
                                              );
      var customEvent = {
        target: {
          getBoundingClientRect: function () {
            return {
              'left': $scope.isHost ? $scope.lastClick.x : pagex,
              'top': $scope.isHost ? $scope.lastClick.y : pagey,
              'width': 1,
              'height': 1,
              'background-color': 'rgba(255,255,255,1)'
            };
          }
        }
      };
      // show the popup at the specifed location
      popover.show(customEvent);
      // define what to do when the popover is dismissed (manual or timer)
      var dismissF = function (modelItem, popover) {
        var modelItemId = modelItem;
        var thePopover = popover;
        return function () {
          $scope.shade(modelItemId, false);
          thePopover.remove();
        }
      }
      // auto-close the popover after 3 seconds
      $scope.shade(target + "-" + pathid, true);
      var timeoutValue = 3000;
      if($scope.app.params.mode == 'DrillDown'){
        timeoutValue = 1000}
      $timeout(dismissF(target + "-" + pathid, popover), timeoutValue);
      $scope.$apply();
    }
  }

 

 

Function 2: 

 

var data = twx.app.mdl['Thing'].svc['Service'].data;
  //all data from service.
  for (var i = 0; i < data.length; i++) {
    var row = data[i];
    try {
	  var arrayIndexValue = $scope.collaboration.nav_objects.findIndex(function(item,i){return item.id === row.UserName.substring(0,row.UserName.indexOf('@'));});
      var nvo = $scope.collaboration.nav_objects[arrayIndexValue];
      nvo.id        = row.UserName.substring(0,row.UserName.indexOf('@'));
      nvo.pos       = new Vector4().FromString(row.Position);
      nvo.gaze      = new Vector4().FromString(row.Gaze);
      var up        = new Vector4().FromString(row.Up);
      nvo.lpos      = nvo.pos.Add(up.Scale(0.12));
      // put the label approx 12cm up on top of the head
      nvo.allocated = row.SeatAllocated;
      if(row.EndMeeting)
      {
   
      }
      else if (!row.SeatAllocated && row.UserName === $scope.app.params.currentUsername)
      {
        
      }
      if(row.UserName === $scope.HostName && !$scope.isHost)
      {
        $scope.app.params['mode'] = row.Mode;
        $scope.app.view['Home'].wdg['textInput-2'].text = row.SearchItem;
        if ($scope.localSearchItem != row.SearchItem)
        {
          
          $scope.localSearchItem = row.SearchItem;
        }
        if(row.EventOccured){
          $scope.highlightModel(row.Target,row.edata,row.PageX,row.PageY);
        }
        if(row.ResetRequested)
        {
          $scope.onreset();
        }
      }
    }
    catch(err)
    {
      $scope.collaboration.nav_objects.push({
        name : "obj" + row.UserName.substring(0,row.UserName.indexOf('@')),
        allocated : row.SeatAllocated,
        pos : new Vector4().Set3(i/10,0,0), 
        lpos : new Vector4().Set3(i/10,0.12,0),
        id : row.UserName.substring(0,row.UserName.indexOf('@'))
      }
                                           );
    }

 

 

Could any one help me fix this issue 

 

/VR

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

@Re: $rootScope:inprog Action Already In Progress

Hi @Velkumar ,

your mentioned 2 functions but unfortunately from the code is not clear what is  the relation between the 2 functions.

Also, the error in the debugging console need to checked more detailed - e.g. the next thing of a line code where the issue could be caused ...

for example here the  line 777 is a good candidate to be checked (this number is only in the context of debugging mode - source tab)

One thing I will suggest - maybe you can replace the 

 

 

$scope.$apply();

 

by

 

$scope.applyAsync();

 

 

asynchronous apply is always saver to be called in the context of studio angular js environment.

Otherwise it is difficult to find directly the reason for the error in the provided code (if it is not in this case the apply() ). So, here is needed to simplified only the problem code or the project for debugging – to be able to identify the error more detailed.

So, about the error we can find general info  - you can check :

Error: $rootScope:inprog   Action Already In Progress
https://docs.angularjs.org/error/$rootScope/inprog

 

angularjs $scope.$apply() gives this error: Error: [$rootScope:inprog]

https://stackoverflow.com/questions/23128220/angularjs-scope-apply-gives-this-error-error-rootscopei...

 

 

View solution in original post

2 REPLIES 2
Highlighted

Re: $rootScope:inprog Action Already In Progress

Hello, 

 

I made a sample test example where a first javascript function calls a second one.

It is not a problem to do that.

Please see the attached example/

 

Here, the issue seems to be due to your code inside both functions.

 

If we look the call stack, we can see that the issue occurs around :

$scope.highlightModel @ app.js?v1602582296794:903
$scope.getPositions @ app.js?v1602582296794:777

 

Other methods are internal to ionic framework.

So, it is not easy to check inside the framework and it is always better to check in your code at first!


We can see in your second functions, a call around this function :

        if(row.EventOccured){
          $scope.highlightModel(row.Target,row.edata,row.PageX,row.PageY);
        }

 

So, I would suggest to comment, the most lines as possible and to add verbose with console.log to track the issue.

 

Here, without the Project to run it and without taking time to be more accurate to find on which line the issue occurs exactly. it is impossible to work on it.

 

By the way, it might be possible also, in Preview to use debug tools and to put a break point in first line in first function. 

When running it, we can go step by step until the exception will be thrown.

It will help to find and to confirm where the exception occurs.

 

It is a good start for a developer to investigate a such issue.

This approach is not specific to javascript, it is common in various programming languages.

 

Best regards,

Samuel

Highlighted

@Re: $rootScope:inprog Action Already In Progress

Hi @Velkumar ,

your mentioned 2 functions but unfortunately from the code is not clear what is  the relation between the 2 functions.

Also, the error in the debugging console need to checked more detailed - e.g. the next thing of a line code where the issue could be caused ...

for example here the  line 777 is a good candidate to be checked (this number is only in the context of debugging mode - source tab)

One thing I will suggest - maybe you can replace the 

 

 

$scope.$apply();

 

by

 

$scope.applyAsync();

 

 

asynchronous apply is always saver to be called in the context of studio angular js environment.

Otherwise it is difficult to find directly the reason for the error in the provided code (if it is not in this case the apply() ). So, here is needed to simplified only the problem code or the project for debugging – to be able to identify the error more detailed.

So, about the error we can find general info  - you can check :

Error: $rootScope:inprog   Action Already In Progress
https://docs.angularjs.org/error/$rootScope/inprog

 

angularjs $scope.$apply() gives this error: Error: [$rootScope:inprog]

https://stackoverflow.com/questions/23128220/angularjs-scope-apply-gives-this-error-error-rootscopei...

 

 

View solution in original post

Announcements
Join an
AR Working Group!

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection