angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Kindle Fire infinite loop route/http/onload issue

Open butchpeters opened this issue 13 years ago • 3 comments

I discovered this issue while testing an Angular app on a Kindle Fire (first gen). I have created a plnkr that simplifies things to the bare minimum to reproduce the problem:

http://plnkr.co/edit/zXkP0J

(Note: the scary alert when the page loads is jsconsole.com 's way of telling you to not push their script to production.)

I set the plunk up to log to jsconsole.com (:listen 3CFD3A56-3905-467B-AC96-7723BEA9AA04). If you were to load the plunk preview on a Kindle Fire, the browser would sit and spin until it dies without ever loading the page. If you look at the output in jsconsole.com, you'll see "Invoking HomeCtrl" over and over again, meaning it just keeps firing more and more $http connections at the server.

The issue only seems to happen when: a) Your $routeProvider forwards to controller A on page load b) Controller A then makes a call to $http.get to load data from the server

If I were to change the route to a different name (like '/home') so it doesn't load on page load, and then type #/home after the URL after the page is done loading, it works fine so it has something to do with this happening while the page is loading.

Also, if I were to take out the $http.get call, it works fine as well, so there's something about the get() that is causing the issue.

I am stumped, but I think it's clear from the plnkr that this is an edge case on the Kindle that Angular doesn't handle.

butchpeters avatar Feb 19 '13 14:02 butchpeters

FYI, in case anyone else needs to workaround this issue, this is what I ended up doing. Instead of loading the data in the controller, I am utilizing the 'resolve' functionality in $routeProvider.when(). So, the resolve function I define takes care of fetching the data, and the route change won't actually fire until the data fetch promise is resolved. This way, I don't have to load the data as a result of a successful route change and the Kindle Fire problem doesn't manifest itself.

butchpeters avatar Feb 21 '13 16:02 butchpeters

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

Thanks!

btford avatar Aug 24 '13 00:08 btford

I just want to mention that I'm running into a similar issue with Kindle Fire (using AngularJS 1.2.15). There seem to be some JavaScript anomalies on Kindle Fire because I'm having JavaScript-related issues on another project as well (not AngularJS) which also works fine on other devices.

ghost avatar Mar 27 '14 19:03 ghost