Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix(jqLite): Check "length" in obj in isArrayLike for iOS JIT bug #11508

Closed
wants to merge 1 commit into from
Closed

fix(jqLite): Check "length" in obj in isArrayLike for iOS JIT bug #11508

wants to merge 1 commit into from

Conversation

snapwich
Copy link
Contributor

@snapwich snapwich commented Apr 3, 2015

to prevent iOS8 JIT bug (https://bugs.webkit.org/show_bug.cgi?id=142792) from surfacing

This is the fix implemented in underscore.js and most likely the fix that will be implemented in jQuery.

It's not a very easy to recreate bug, but I stumbled upon it myself in our production app and was able to narrow it down to isArrayLike after several hours of banging my head. This plunkr was the closest I got to consistently surfacing the bug in Angular: http://plnkr.co/edit/UQ5NhZnRuafNxWiJuuyN

That ng-repeat will fail, but only on iOS8 (and i've personally only had it fail on iPad) about 50% of the time after a few digests. If it doesn't fail quick reloading the plunkr a few times will usually get it to fail.

@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

@googlebot
Copy link

CLAs look good, thanks!

@googlebot googlebot added cla: yes and removed cla: no labels Apr 3, 2015
@snapwich
Copy link
Contributor Author

snapwich commented Apr 7, 2015

Updated pull request to follow updated isArrayLike solution in jQuery jquery/jquery#2185

Unfortunately no tests since this is iOS8 only and doesn't surface in iOS simulator.

@realityking
Copy link
Contributor

@snapwich Could you add a comment explaining why it's needed? Otherwise someone will probably try to remove it in a couple of months or years ;)

@snapwich
Copy link
Contributor Author

snapwich commented Apr 7, 2015

@realityking sure. I just added a comment similar to the jQuery commit.

@snapwich snapwich changed the title fix(jqLite): Added helper method to get length property in isArrayLike fix(jqLite): Check "length" in obj in isArrayLike for iOS JIT bug Apr 8, 2015
@snapwich
Copy link
Contributor Author

Any update on merging this? This fix has made its way into jQuery now and would be a quick fix for Angular.

@caitp
Copy link
Contributor

caitp commented Apr 27, 2015

LGTM

@jdalton
Copy link
Contributor

jdalton commented Apr 27, 2015

I believe jQuery found that based on their usage they didn't need the Object(...) use. Might be worth checking out here too.

@caitp
Copy link
Contributor

caitp commented Apr 27, 2015

@jdalton that works in jQuery's case because the caller knows that it's a non-null "object" already, I'm not sure the same assumptions fly here. It would be good to make those assumptions work but I won't consider that a blocker

@snapwich
Copy link
Contributor Author

@jdalton @caitp yeah jQuery and Angular make some different assumptions I think.

Removing the Object(...) causes these unit tests to fail that otherwise don't:

angular forEach should handle string values like arrays FAILED
angular forEach ES spec api compliance should follow the ES spec when called with string FAILED

@petebacondarwin
Copy link
Member

For reference jquery/jquery#2145

@petebacondarwin
Copy link
Member

@mzgol - you worked on this bug in JQuery - what is your recommendation here?

@mgol
Copy link
Member

mgol commented May 5, 2015

We should work around it; relevant jQuery commit: jquery/jquery@1541664

@mgol
Copy link
Member

mgol commented May 5, 2015

This looks good but in jQuery it turned out some people relied on undocumented behavior that jQuery.map worked on strings and not just arrays (this broke a popular DataTables jQuery plugin, they've already fixed it so we didn't touch the final implementation). Not sure if this is an issue here.

@petebacondarwin
Copy link
Member

OK, LGTM. Let's merge this.

petebacondarwin pushed a commit that referenced this pull request May 5, 2015
@snapwich snapwich deleted the isarraylike-webkit-phantom-length-fix branch May 5, 2015 19:42
netman92 pushed a commit to netman92/angular.js that referenced this pull request Aug 8, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants