Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25539] Android: ScrollableView with border crashes as of 6.1.0

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-05-09T21:29:40.000+0000
Affected Version/sRelease 6.1.0
Fix Version/sRelease 7.3.0
ComponentsAndroid
Labelsandroid, scrollableView
ReporterBhushankumar pawar
AssigneeJoshua Quick
Created2017-11-20T11:49:12.000+0000
Updated2018-06-12T18:12:52.000+0000

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:*

Build the below code using Titanium 6.1.0 or higher.

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

Comments

  1. Hans Knöchel 2017-11-20

    Looks like a crash related to the Ti.UI.ScrollableView, assigning to [~jquick].
  2. Bhushankumar pawar 2017-11-22

    While debugging the the issue i found out that Above crash occurs when you apply any border related property to ScrollableView (eg. borderRadius, borderWidth, borderColor) see following code. var scrollView = Ti.UI.createScrollableView({height : "90%", width : "90%", borderColor : "1dp", backgroundColor : "#f5f5f5"}); $.mainWin.add(scrollView);
  3. Joshua Quick 2017-12-23

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/9696
  4. Lokesh Choudhary 2018-05-05

    FR Passed. Waiting for merger to be enabled.
  5. Lokesh Choudhary 2018-05-09

    PR Merged.
  6. Samir Mohammed 2018-06-12

    Closing ticket. Fix can be seen in SDK Version: 7.3.0.v20180607210411 Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/9696

JSON Source