Project: titanium
Issue TIMOB-20206: Android : TiCompositeLayout's viewSorter does not abide by Comparator's contract
I'm writing in from the Android team. The "N" release of Android is moving over to using OpenJdk as its implementation for java.* libraries. One of the issues that came up in our testing a crash that looks like this : java.lang.IllegalStateException: Ambiguous Z-Order at org.appcelerator.titanium.view.TiCompositeLayout$1.compare(TiCompositeLayout.java:164) at org.appcelerator.titanium.view.TiCompositeLayout$1.compare(TiCompositeLayout.java:127) at java.util.TreeMap.compare(TreeMap.java:1190) at java.util.TreeMap.put(TreeMap.java:532) at java.util.TreeSet.add(TreeSet.java:255) at org.appcelerator.titanium.view.TiCompositeLayout.onLayout(TiCompositeLayout.java:491) at android.view.View.layout(View.java:16945) at android.view.ViewGroup.layout(ViewGroup.java:5516) The issue here is their Comparator expects that its arguments are never equal (i.e, none of its code paths return 0). That seems pretty brittle and contrary to the documented contract. It fails on OpenJdk because of this snippet of code in TreeMap#put : TreeMapEntry t = root; if (t == null) { compare(key, key); // type (and possibly null) check <--- [BUG HERE] we're deliberately comparing a view with itself for the side effects : null & type check ..... I will put in a workaround for the upcoming release, but It will be reverted in a future Android release.
Story points: 5