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

$http requests don't always resolve their promise in IOS

Open john-banks opened this issue 12 years ago • 4 comments

I had a problem with ipads sometimes not loading ng-includes. I dug into it and found it was causing the http request but never resolved the promise and therefore ng-include never rendered the content.

It turns out that the xmlhttprequest never called onreadystatechange which is what causes the promises to resolve. By pure accident I found a solution which involves placing an empty setTimeout in createHttpBackend.

It looks something like this: setTimeout(function(){//Do nothing},1000);

This causes IOS to then call xmlhttprequest when it's ready. What I suspect is happening is IOS is garbage collecting some of the code because it doesn't think it's relevant anymore but by placing a setTimeout in there it forces to keep the rest of the code running.

So the solution to this bug is either to place setTimeout as I have done or work out why IOS thinks that createHttpBackend can be ignored.

This bug only seems to happen on pages that have a lot of content on them that are stressing the ipads memory, so if you need to test this bug I recommend a repeater that brings in a large amount of ng-includes.

This was on angular 1.2.9 and below. Not tried on the 1.3 branch.

john-banks avatar Apr 04 '14 16:04 john-banks

I would suggest referring to this issue on the webkit issue tracker, if it really is a problem with either their GC or XHR implementation

caitp avatar Apr 05 '14 14:04 caitp

How much is "a lot of content" ? I think it might be a good idea to try to minimize the amount of content "per page" for mobile apps

caitp avatar Apr 05 '14 14:04 caitp

caitp ,not actually a whole lot of html. The main content is one repeater that runs about 25 times.

The page runs fine on low powered devices such as the hudl but causes this problem on the ipad4 and under so I don't think the page is abhorrently large.

john-banks avatar Apr 07 '14 12:04 john-banks

Long time no activity in this issue. No repro either. 1.2 is also unsupported. Closing.

Narretz avatar Jan 26 '16 20:01 Narretz