Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-20206

Android : TiCompositeLayout's viewSorter does not abide by Comparator's contract

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 6.0.2
    • Component/s: Android
    • Labels:
      None
    • Story Points:
      5
    • Sprint:
      2016 Sprint 18 SDK

      Description

      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<K,V> 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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msamah Ashraf Abu (Inactive)
                Reporter:
                kamath.narayan@gmail.com Narayan K
                Reviewer:
                Christopher Williams
                Tester:
                Andy Waldman
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-20830
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code