ionic-team / ionic-v1

The repo for Ionic 1.x. For the latest version of Ionic, please see https://github.com/ionic-team/ionic
Other
193 stars 187 forks source link

Switching tabs quickly causes digest error iOS 10 #58

Open jgw96 opened 7 years ago

jgw96 commented 7 years ago

From @paulpatarinski on December 5, 2016 23:37

Ionic version: (check one with "x") [ x] 1.x [ ] 2.x

I'm submitting a ... (check one with "x") [ x] bug report [ ] feature request [ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

Switching tabs quickly causes "digest already in progress" error

Expected behavior:

Switching tabs quickly DOES NOT cause a digest error

Steps to reproduce:

Repro steps :

  1. Create a tab page, make sure each tab is triggering a digest (make http call).
  2. Install the app on an iOS 10 device
  3. Switch the tabs rapidly back & forth

Related code: I have narrowed the issue down to a $scope.$apply in the ionTabNav

 if (!$attrs.ngClick) { 
        $element.on('click', function(event) {
           $scope.$apply(function() {
            $scope.selectTab(event); 
          });
        });
      }

Using $timeout instead of $scope.$apply seems to fix the issue. Is there a specific reason $scope.$apply was used?

Other information:

Stack trace

Error: [$rootScope:inprog] $digest already in progress http://errors.angularjs.org/1.4.3/$rootScope/inprog?p0=NaNigest file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:13380:32 beginPhase@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:29512:31 $apply@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:29256:21 file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:63989:25 dispatch@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/kendo/jquery.min.js:3:28458 handle@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/kendo/jquery.min.js:3:25163 _wrapped@https://d37gvrvc0wt4s1.cloudfront.net/js/v1.9/rollbar.min.js:1:13833 invokeTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:379:46 runTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:279:61 invoke@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:447:44 dispatchEvent@[native code] triggerMouseEvent@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:2948:20 tapClick@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:2937:20 tapTouchEnd@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:3064:13 send@[native code] scheduleTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:108:34 scheduleTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:359:40 scheduleMacroTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:296:59 send file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:23826:15 sendReq@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:23645:21 serverRequest@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:23357:23 processQueue@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:27879:30 file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:27895:39 $digest@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:28969:36 $digest@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:1917:32 $apply@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:29263:31 file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:31030:42 completeOutstandingRequest@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:18706:15 file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/bower-ionic/ionic.bundle.js:18978:33 invokeTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:379:46 runTask@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:279:61 invoke@file:///var/mobile/Containers/Data/Application/B30CEF17-7257-49A7-B639-B23BA1E910FA/Library/Application%6Support/LiveSync/js/libs/opbeat-angular/opbeat-angular.js:447:44

Copied from original issue: driftyco/ionic#9504

jgw96 commented 7 years ago

From @revie on December 8, 2016 19:27

If it helps any, I started experiencing the exact same problems with iOS 10 and the latest release of Ionic (1.3.2). I have reports of it starting with iOS 10.0.1, but wasn't able to reproduce until after iOS 10.1.1 was released.

@paulpatarinski, thanks for the code patch. Looks like it works perfectly!

pegasci commented 7 years ago

@jgw96 did this patch ever make it into master? I don't see it there, so my assumption is that on further review, the patch wasn't quite right for the problem?