Angular.js app for mobile browser freezes on iOS 8 Safari

Our Angular.js web application sometimes freezes on iOS8 Safari. When this problem occurs, the ng-click callback does not start. If you replace ng-click with regular javascript onclick, this will work. This does not happen in Chrome on iOS8 devices.

Has anyone else noticed this problem in Safari iOS8 or fixed it?

This simple look sometimes freezes on iOS8 safari . Freezing usually occurs when you open a tab, switch to other tabs in the browser, or perhaps leave the browser and return later. In this example, when the view freezes when clicking on links, tapCount does not increase. The more complex the view, the easier it is to freeze. In this example, the browser will freeze for a few seconds when I quickly touch the links. Usually freezing takes longer on real complex performances.

var app = angular.module('myApp', []); app.controller('freezeCtrl', function($scope) { $scope['tapCount'] = 0; $scope['dummyItems'] = []; for(var i = 0; i < 15; i++) { var anItem = {'id': i}; ($scope['dummyItems']).push(anItem); } $scope['updateTapCount'] = function() { $scope.tapCount += 1; }; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> <div ng-app="myApp"> <div ng-controller="freezeCtrl"> <p>Tap Count = {{tapCount}}</p> <ul> <li ng-repeat="item in dummyItems" bindonce> <p>This is a dummy item #{{item.id}}</p> </li> </ul> <div> <button ng-click="updateTapCount()">Button 1</button> <button ng-click="updateTapCount()">Button 2</button> </div> </div> </div> 
+6
source share
1 answer

I found a solution and it seems to have found a solution correctly when someone else fixed a bug in Angular! It is fixed in Angular 1.3.x.

The bug "isArrayLike" in the angular.js code has been fixed. Sometimes when obj.length is undefined after assigning "var length = obj.length;" variable length gets the value "1". This will cause isArrayLike to return true for objects that are not arrayLike. This error, in particular, would break Angular forEach, and then JQLite "eventHandler". Thus, no event handlers would execute when this happened.

+2
source

Source: https://habr.com/ru/post/986384/


All Articles