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

Android: ScrollableView with border crashes as of 6.1.0

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 6.1.0
    • Fix Version/s: Release 7.3.0
    • Component/s: Android
    • Environment:
    • Sprint:
      2018 Sprint 05 SDK, 2018 Sprint 04 SDK

      Description

      Summary:
      Applying a border to a ScrollableView will cause a crash in Titanium 6.1.0 and newer versions. Works fine in older Titanium versions.

      Steps to Reproduce:

      1. Build the below code using Titanium 6.1.0 or higher.
      2. Run on an Android device.

      var window = Ti.UI.createWindow();
      var scrollableView = Ti.UI.createScrollableView(
      {
      	views:
      	[
      		Ti.UI.createView({ backgroundColor: "green" }),
      		Ti.UI.createView({ backgroundColor: "yellow" }),
      	],
      	showPagingControl: true,
      	borderColor: "blue",
      	borderWidth: "1dp",
      });
      window.add(scrollableView);
      window.open();
      

      Result:
      Crashes on startup with the following logged stack-trace...

      [ERROR] :  TiApplication: (main) [235,235] Sending event: exception on thread: main msg:java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to org.appcelerator.titanium.view.TiCompositeLayout$LayoutParams; Titanium 6.3.0,2017/10/31 18:13,undefined
      [ERROR] :  TiApplication: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to org.appcelerator.titanium.view.TiCompositeLayout$LayoutParams
      [ERROR] :  TiApplication: 	at ti.modules.titanium.ui.widget.TiUIScrollableView$1.onMeasure(TiUIScrollableView.java:99)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:654)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:486)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:654)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:486)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:654)
      [ERROR] :  TiApplication: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:486)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  TiApplication: 	at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
      [ERROR] :  TiApplication: 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  TiApplication: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  TiApplication: 	at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2728)
      [ERROR] :  TiApplication: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2077)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1201)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1412)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1089)
      [ERROR] :  TiApplication: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6027)
      [ERROR] :  TiApplication: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:804)
      [ERROR] :  TiApplication: 	at android.view.Choreographer.doCallbacks(Choreographer.java:617)
      [ERROR] :  TiApplication: 	at android.view.Choreographer.doFrame(Choreographer.java:587)
      [ERROR] :  TiApplication: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:790)
      [ERROR] :  TiApplication: 	at android.os.Handler.handleCallback(Handler.java:739)
      [ERROR] :  TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:95)
      [ERROR] :  TiApplication: 	at android.os.Looper.loop(Looper.java:135)
      [ERROR] :  TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5401)
      [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
      [ERROR] :  TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:372)
      [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:919)
      [ERROR] :  TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:714)
      [ERROR] :  AndroidRuntime: FATAL EXCEPTION: main
      [ERROR] :  AndroidRuntime: Process: com.vmware.customer360, PID: 18218
      [ERROR] :  AndroidRuntime: java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to org.appcelerator.titanium.view.TiCompositeLayout$LayoutParams
      [ERROR] :  AndroidRuntime: 	at ti.modules.titanium.ui.widget.TiUIScrollableView$1.onMeasure(TiUIScrollableView.java:99)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:654)
      [ERROR] :  AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:486)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  AndroidRuntime: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:654)
      [ERROR] :  AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:486)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.constrainChild(TiCompositeLayout.java:654)
      [ERROR] :  AndroidRuntime: 	at org.appcelerator.titanium.view.TiCompositeLayout.onMeasure(TiCompositeLayout.java:486)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  AndroidRuntime: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  AndroidRuntime: 	at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  AndroidRuntime: 	at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
      [ERROR] :  AndroidRuntime: 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
      [ERROR] :  AndroidRuntime: 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  AndroidRuntime: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.widget.LinearLayout.measureVertical(LinearLayout.java:875)
      [ERROR] :  AndroidRuntime: 	at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5690)
      [ERROR] :  AndroidRuntime: 	at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
      [ERROR] :  AndroidRuntime: 	at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2728)
      [ERROR] :  AndroidRuntime: 	at android.view.View.measure(View.java:17604)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2077)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1201)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1412)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1089)
      [ERROR] :  AndroidRuntime: 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6027)
      [ERROR] :  AndroidRuntime: 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:804)
      [ERROR] :  AndroidRuntime: 	at android.view.Choreographer.doCallbacks(Choreographer.java:617)
      [ERROR] :  AndroidRuntime: 	at android.view.Choreographer.doFrame(Choreographer.java:587)
      [ERROR] :  AndroidRuntime: 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:790)
      [ERROR] :  AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:739)
      [ERROR] :  AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:95)
      [ERROR] :  AndroidRuntime: 	at android.os.Looper.loop(Looper.java:135)
      [ERROR] :  AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:5401)
      [ERROR] :  AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
      [ERROR] :  AndroidRuntime: 	at java.lang.reflect.Method.invoke(Method.java:372)
      [ERROR] :  AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:919)
      [ERROR] :  AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:714)
      

      Expected Result:
      Should not crash. Border should be displayed around ScrollableView container like how it worked before Titanium 6.1.0.

      Work-Around:
      Do not apply a border to the ScrollableView (ie: don't set properties "borderWidth" and "borderSize"). If a border is needed, then wrap the ScrollableView with another view and apply a border the wrapper view.

      Cause:
      The fix for TIMOB-25539 caused the crash because the ScrollableView's LayoutParams are no longer an instance of "TiCompositeLayout.LayoutParams" when a border view is applied. The TiCompositeLayout params are instead copied to the parent border view and the ScrollableView uses a simple ViewGroup layout params instead.

      Recommended Solution:
      We should change onMeasure() code to handle Ti.UI.SIZE (aka: WRAP_CONTENT) to measure child view(s) using Android's standard view APIs so that it's handled in a more generic fashion. This way it can handle any child view layout. Should be coded similar to this PR...
      https://github.com/appcelerator/titanium_mobile/pull/9421

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                bpawar Bhushankumar pawar
                Reviewer:
                Gary Mathews
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Source Code