(iOS 8 GM iPhone5C) TypeError: Attempted to assign to readonly property
I am using on iOS 8 GM(iPhone5C). With this device, I am getting this error in this line(https://github.com/angular/angular.js/blob/master/src/ng/rootScope.js#L216) But on iOS 8 GM(iPhone5S) and iOS 7.x (iPhone5C, iPhone5S), this error does not occur.
To resolve this error, I rewrote the code as follows:
$new: function(isolate) {
var child;
if (isolate) {
child = new Scope();
child.$root = this.$root;
// ensure that there is just one async queue per $rootScope and its children
child.$$asyncQueue = this.$$asyncQueue;
child.$$postDigestQueue = this.$$postDigestQueue;
} else {
// Only create a child scope class if somebody asks for one,
// but cache it to allow the VM to optimize lookups.
if (!this.$$ChildScope) {
this.$$ChildScope = function ChildScope() {
this['$$watchers'] = this['$$nextSibling'] =
this['$$childHead'] = this['$$childTail'] = null;
this['$$listeners'] = {};
this['$$listenerCount'] = {};
this['$id'] = nextUid();
this['$$ChildScope'] = null;
};
this.$$ChildScope.prototype = this;
}
child = new this.$$ChildScope();
}
child['this'] = child;
child['$parent'] = this;
child['$$prevSibling'] = this.$$childTail;
if (this.$$childHead) {
this.$$childTail.$$nextSibling = child;
this.$$childTail = child;
} else {
this.$$childHead = this.$$childTail = child;
}
return child;
},
The situation has improved, but I do not understand the reason...
@shershen08 https://www.npmjs.com/package/webkit-assign
Note, while reports are that it only affects IOS8, I now have a case of it occurring on IOS9.2 (despite using webkit-assign fix). Any ideas?
TypeError: Attempted to assign to readonly property. Mozilla/5.0 (iPhone; CPU iPhone OS 9_2 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13C75 Safari/601.1
Will try removing 'use strict's once I have a device I can regularly test on.
@code-tree If you've run all JavaScript code on your site through webkit-assign and can still consistently reproduce that error, you should file a bug on our repository.
+1, angular 1.3.6 & 1.4.8, ios 8.2
@jacksonrayhamilton Retrying on a different friend's device running iOS 9.2 worked fine, so I can't reproduce it, but it did still occur on the device mentioned earlier (which I no longer have access to). So I guess I'll wait and see if anyone else reports anything.
Hello everyone,
I have also, unfortunately, ran into this issue. I'm still a bit dazzled because of the behaviour:
- I do not get it on every page in my application
- I do not get it all the time on that specific page, only about 50% of the time
Does anyone noticed that it only happens with specific code or with loading issues?
I will look into the solution @jacksonrayhamilton provided, allthough I'm not sure if this will be usable for my final build.
Kind regards,
Yes, it first occurred for me after testing on a device for 30 minutes without any issues. All of a sudden it kept occurring on the index page, without anything being (noticeably) different to the previous 30 minutes...
Hello everyone, I have noticed that it, for some reason, in my case seems to be related to the usage of ng-if's. I use ng-if's to hide my pages until I have all my back-end calls done in order to make sure that all the data used by the directives is available before loading them. Removing these ng-if's, it seems that I no longer get the readOnly errors (tested about 20 times). Did anyone else noticed this?
Are there any negative side-effects for using @jacksonrayhamilton his solution? I am currently using angular 1.4.7.
@JeroenNelen While it's possible ngIf could be a culprit, I think it's more likely that the ngIf prevented or triggered some other code that was a culprit. As for the efficacy of the solution, we use an AST to transform and fix the code, so it should be pretty precise. We haven't had any problems using it in our production build and we have no open issues currently.
@jacksonrayhamilton Thanks for your reply. I will test to see if the issue still occurs after these changes, if it indeed occurs, I think the only solution will be to use your package (nice job on it by the way) :). The weird thing is that I cannot get the error to occur on any other page, only on these specific pages, therefor I was meddling with the code on those pages to see if I could prevent the error locally (rather than adjusting anguluar.js).
@jacksonrayhamilton Hi, is there a way to use your tool with Grunt?
var webkitAssign = require('webkit-assign');
module.exports = function(grunt) {
grunt.registerTask('webkitAssign', function() {
var file = 'build/scripts.js';
var code = grunt.file.read(file);
var transformed = webkitAssign(code);
grunt.file.write(file, transformed);
});
};
Or for better integration, maybe you'd like to submit a plugin to our repository? :-)
We found a bug with angular-translate and ng-show on iOS8. removing ng-show in favour of ng-if fixes the issue. Also issue if parent has ng-show. ng-hide no doubt has an issue too!
@jacksonrayhamilton Thank you! Utility worked flawlessly. Problem is no longer persisting in iOS 8.3 / iPhone 5, AngularJS 1.4.9. Hours of headache later, you have made my day.
@spenoir I think you're talking about a different bug regarding ng-show / ng-hide:
https://github.com/angular/angular.js/issues/13380#issuecomment-181309484
I just encountered the same issue. Will try the webkit-assign fix and report back.
Since this is a bug in WebKit, which has been fixed, there is a work-around and we don't have a clear reproduction to investigate further, this is not actionable on our part. Closing...
@code-tree i ran into the same issue with the same description (iOS 9, appearing after long usage time). How do you fix your app?
@celle886 No idea, sorry :)
It seems like webkit-assign helps, but I couldn't reliably reproduce the problem.
Just came across this issue in our web app with Angular 1.4.8 when using iPod/iPhone 8.4.1 on Safari 8.0. Thanks for whoever was first to suggest webkit-assign. We used webkit-assign/gulp and that solved a problem that has been ghosting/plaguing us for 6+ months.