(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...
In update to our stack, we've been running without "use strict" for a while, and have started to hit Safari lockups. In the worst cases, users have to power off and power on the device to get Safari responsive again.
I'm optimistic now that there's a consistent reproduction that a fix might be possible, but in the short term, has anyone found a viable workaround?
To contribute more to the discussion around common dependencies, we're now using:
{
...
"angular": "~1.3.15",
"angular-translate": "~2.6.1",
"ui-route": "0.2.13",
...
}
...but we saw this issue before introducing ui-router to our stack. This (plus the lines pointed to by the stack trace) make me think that there's something else happening here with how $scope is kept up-to-date that just happens to be exacerbated or made more frequent by how some of these libs interact with core Angular.
+1
I see the problem on non-64 bit devices running iOS 8. iPad 2/3/4, mini, etc. are affected. Devices NOT affected are iPad Air/Air 2, mini 2/3.
It is an Apple bug, but since other frameworks (Ember, Require, etc.) are putting in workarounds, it'd be nice to see Angular implement a workaround as well.
btw, does anyone know where to submit these kinds of bugs to Apple?
Also, I'll add that the removal of 'use strict' only goes so far. Like @spencerwi stated, we see Safari lock up completely and user has to force quit.
It only happens on Safari on iOS8 (non 64-bit) too... not Chrome. just fyi.
@HAKASHUN and @m3kka 's solution of changing from dot to array notation worked. Why 32-bit Safari is choking on dot notation on those lines, I don't know. That's a mystery Apple probably needs to solve.
Can the array notation be put into Angular proper to resolve this problem for everyone?
We (Amplify Education, http://amplify.com) are also encountering this issue. We tried removing 'use strict', various changes in our stack. Currently considering using this patch to work around it.
By the way, I've had success making @jhunken's decorator patch minification-safe by declaring the offending property names as string vars, then referencing them with bracket notation.
var $id = '$id',
$$childScopeClass = '$$childScopeClass',
...
And then:
...
this[$id] = nextUid();
this[$$childScopeClass] = null;
...
Full forked gist available here (modeled off Angular 1.2.23)
@zourtney thanks for publishing that, I added the decorator to our app which was producing quite many tracebacks related to this from iOS devices. It has been a life saver as our app was totally unusable, especially on iPads. We are currently using Angular 1.3.8.
EDIT I just checked that there are some differences in the $new method in the version in the decorator and 1.3.8, I am looking into updating the patch
Seems there are more places where there is this misbehaviour for iOS devices, we got new tracebacks in Sentry now pointing to this line:
https://github.com/angular/angular.js/blob/bab474aa8b146f6732857c3af1a8b3b010fda8b0/src/ng/compile.js#L1096
this.$attr[key] = attrName = snake_case(key, '-');
most likely this will work if written in same format as in your patch
var $attr = '$attr';
this[$attr][key] = attrName = snake_case(key, '-');
This is aligned with the comments in this thread around Dec 9 2014 https://github.com/angular/angular.js/issues/9128#issuecomment-66314752
Unfortunately I don't have time in the coming days to try setting up a reproducible environment for this. Some more info to create a reproducible environment: this is triggered in a "non interactive" call as the starting point of the traceback is here https://github.com/angular/angular.js/blob/v1.3.8/src/ng/browser.js#L49
I forked and adapted the gist decorator by @zourtney to work in Angular 1.3.8 here: https://gist.github.com/harrastia/4a963e62605f73bbfff2
To follow the webkit issue : https://bugs.webkit.org/show_bug.cgi?id=138038. Seems that a patch is on the way.
+1 Removing 'strict mode' from angular.js just kind of alleviate the problem but it still happens randomly.
bower.json:
"dependencies": {
"angular": "1.3.15",
"angular-route": "~1.3.5",
}
I just encountered this problem on my production site, and I noticed that the bug came from my Grunt's HTML minification task (really!), and specifically, from having the removeOptionalTags option enabled.
The second I disabled removeOptionalTags, everything started working again.
PS: If you used yeoman angular, you have this option setup.
I ran into this today as well for my website (Iphone 5 iOS 8).. I'm using Angular 1.2.28.
+1 on ios 8 emulator, ionic 1.0, angular 1.3.16
I am only experience this bug when having form elements wrapped in a directive template. With or without a transclude.
currently i have a contact form directive. template html is:
<div>
<container h-max="1">
<column align="left">
<ng-transclude></ng-transclude>
</column>
</container>
</div>
and in the index file i use it:
<contact-form css-prefix="contact-form">
<ng-input form-id="voornaam" class="form-control"></ng-input>
<ng-input form-id="achternaam" class="form-control"></ng-input>
<ng-input form-id="bedrijf" class="form-control"></ng-input>
<ng-input form-id="telefoon" class="form-control"></ng-input>
<ng-input form-id="email" class="form-control"></ng-input>
<ng-text-area form-id="vraag" class="form-control"></ng-text-area>
<button ng-click="sendContactForm()" class="btn btn-primary contact-form-button"><lang parent-id="contact_form" id="button"></lang></button>
</contact-form>
There is much more code in my project but i was wondering if it could be due to form elements causing this bug.
When will it be applied in the master branch? Any idea?
@dhyegofernando you should ask apple... the bug is fixed, but isn't deployed. see here: https://bugs.webkit.org/show_bug.cgi?id=138038#c19
We've been using @jhunken's decorator but ran into issues with scope id's when upgrading to Angular 1.4. We managed to work around it by wrapping the $new function in a try catch block, inspired by this thread: http://stackoverflow.com/questions/13147026/disabling-jit-in-safari-6-to-workaround-severe-javascript-jit-bugs
This updated monkey patch decorator works for us: https://gist.github.com/johgusta/46fb1ecd459dbc3bfdfc