You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Fetching template fails on Android 4.0/4.1 when using Appcache manifest. #1356
AngularJS can't fetch a template that is cached offline in Android stock browser on Ice Cream Sandwich and Jelly Bean (Gingbread works). The status code returned from XHR is zero comparable to the behaviour of XHR using the file protocol.
No comment on the fix, but I certainly ran into this bug today. If I have my partials appcached, navigate to a page that doesn't use Angular, then hit the back button, the partials do not get loaded. This was on Android 4.1. My solution was to not appcache the partials, which is unfortunate.
I ran into this issue with Angular 1.1.5. Also, I looked at the master branch of angular/angular.js, and the code there is:
status = (protocol == 'file' && status === 0) ? (response ? 200 : 404) : status;
which is different from 1.1.5 code, but it looks like it still doesn't fix the issue - it should probably be:
status = (protocol == 'file' || status === 0) ? (response ? 200 : 404) : status;
in order to address the appcache manifest scenario. (I've confirmed that this latter line fixes the issue, at least on Android 4.3 emulator). So I really think this issue should be reopened.
Start the Android 4.3 emulator. (I'm primarily using the Android SDK emulator but have also seen the issue in the Genymotion emulator; I am guessing this will repro on a real device as well, but I unfortunately have no way of testing this right now; I think this may also repro on older iOS, but I'm not 100% sure about this).
Open the app in the built-in Android browser.
After the app fully loads, close its tab (click the "tabs" icon on top right of status bar, then click "X" next to the app's tab). If this was the only tab open, the browser may close at this point, if so - reopen it.
Open the app again (do not clear the cache before doing this!). HTML templates will fail to load. If you open the debug console (by going to "about:debug" and clicking "Javascript console"), you will see messages such as: "Error: Failed to load template: templates/jqmButton.html"
I am using Angular 1.1.5. I can confirm that if I change the line to the current line in the master branch, "(protocol == 'file' && status === 0)", the bug still occurs, and if I change it to "(protocol == 'file' || status === 0)" the bug disappears.
I had the same issue like @eugeneos in Angular 1.2.6. Changing from "&&" to "||" helped me.
I think that issue should be reopened to figure out working patch.
Android stock browser on Android 4.1 sets protocol to "http" and status to "0"
Altering status 0 to 404 (commit 28fc80b) may seem like the right thing to do in some scenarios but it is not a good solution overall as 404 is a HTTP response code and indicates that the server did actually respond. Status 0 should, according to w3.org definition, be considered "some type of network error or fetch termination" (http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute) - i.e server did NOT respond, very different to the meaning of status 404 - "Not found"
I discovered this code change after upgrading to latest version of angularjs - my code which handles network/connection problems based on status code 0 stopped working since status 0 is now mapped to 404.
Activity
Trott commentedon Jun 13, 2013
No comment on the fix, but I certainly ran into this bug today. If I have my partials appcached, navigate to a page that doesn't use Angular, then hit the back button, the partials do not get loaded. This was on Android 4.1. My solution was to not appcache the partials, which is unfortunate.
btford commentedon Aug 24, 2013
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.8and1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.Thanks!
eugeneos commentedon Dec 10, 2013
I ran into this issue with Angular 1.1.5. Also, I looked at the master branch of angular/angular.js, and the code there is:
which is different from 1.1.5 code, but it looks like it still doesn't fix the issue - it should probably be:
in order to address the appcache manifest scenario. (I've confirmed that this latter line fixes the issue, at least on Android 4.3 emulator). So I really think this issue should be reopened.
caitp commentedon Dec 10, 2013
Mmm, that change was only made a few weeks ago, and from what I've heard it seems to work --- can you prove that it doesn't?
eugeneos commentedon Dec 10, 2013
When you say "it seems to work", has it specifically been tested with an app manifest on Android?
Here are my repro steps:
<html manifest="app.appcache">I am using Angular 1.1.5. I can confirm that if I change the line to the current line in the master branch, "(protocol == 'file' && status === 0)", the bug still occurs, and if I change it to "(protocol == 'file' || status === 0)" the bug disappears.
Android stock browser fix
rafallo commentedon Dec 27, 2013
I had the same issue like @eugeneos in Angular 1.2.6. Changing from "&&" to "||" helped me.
I think that issue should be reopened to figure out working patch.
Android stock browser on Android 4.1 sets protocol to "http" and status to "0"
fix($httpBackend): Allow status code 0 from any protocol
fix($httpBackend): Allow status code 0 from any protocol
fix($httpBackend): Allow status code 0 from any protocol
geirgp commentedon Feb 4, 2014
Altering status 0 to 404 (commit 28fc80b) may seem like the right thing to do in some scenarios but it is not a good solution overall as 404 is a HTTP response code and indicates that the server did actually respond. Status 0 should, according to w3.org definition, be considered "some type of network error or fetch termination" (http://www.w3.org/TR/XMLHttpRequest/#the-status-attribute) - i.e server did NOT respond, very different to the meaning of status 404 - "Not found"
I discovered this code change after upgrading to latest version of angularjs - my code which handles network/connection problems based on status code 0 stopped working since status 0 is now mapped to 404.