Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-13671] Android: animate crashes the app if view has a border

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-06-20T22:14:30.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 13 API, 2013 Sprint 13, Backlog, Release 3.2.0
ComponentsAndroid
Labelsmodule_animation, qe-testadded, triage
ReporterDavide Cassenti
AssigneeBiju pm
Created2013-04-25T11:43:23.000+0000
Updated2014-06-19T12:43:00.000+0000

Description

Description of the problem

Animating a view which has a border (set either borderRadius, borderWidth or borderColor) fails and the app crashes.

Steps to reproduce

Use the following code: clicking on a view, the animation does not run properly, and in the end it crashes. Note that you can comment out any of the border properties (one by one even) to see the error. Removing all of them works fine.
var win = Ti.UI.createWindow({
	backgroundColor: 'black'
});

var view = Ti.UI.createView({
	backgroundColor: 'red',
	borderRadius: 20,
	borderColor: 'white',
	borderWidth: 10,
	top: 10,
	width: 100,
	height: 100
});
view.addEventListener('click', function() {
	view.animate({
		top: 100,
		duration: 3000
	});
});
win.add(view);

win.open();

Log error

E/TiApplication( 3620): java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to org.appcelerator.titanium.view.TiCompositeLayout$LayoutParams
E/TiApplication( 3620): 	at org.appcelerator.titanium.util.TiAnimationBuilder$AnimationListener.onAnimationEnd(TiAnimationBuilder.java:618)
E/TiApplication( 3620): 	at android.view.animation.Animation.fireAnimationEnd(Animation.java:920)
E/TiApplication( 3620): 	at android.view.animation.Animation.getTransformation(Animation.java:878)
E/TiApplication( 3620): 	at android.view.animation.Animation.getTransformation(Animation.java:940)
E/TiApplication( 3620): 	at android.view.animation.AnimationSet.getTransformation(AnimationSet.java:384)
E/TiApplication( 3620): 	at android.view.animation.Animation.getTransformation(Animation.java:940)
E/TiApplication( 3620): 	at android.view.View.drawAnimation(View.java:13205)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13344)
E/TiApplication( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/TiApplication( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13715)
E/TiApplication( 3620): 	at android.widget.FrameLayout.draw(FrameLayout.java:467)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13596)
E/TiApplication( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/TiApplication( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/TiApplication( 3620): 	at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:688)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13715)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13596)
E/TiApplication( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/TiApplication( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/TiApplication( 3620): 	at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:688)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13594)
E/TiApplication( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/TiApplication( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13594)
E/TiApplication( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/TiApplication( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13594)
E/TiApplication( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/TiApplication( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/TiApplication( 3620): 	at android.view.View.draw(View.java:13715)
E/TiApplication( 3620): 	at android.widget.FrameLayout.draw(FrameLayout.java:467)
E/TiApplication( 3620): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2211)
E/TiApplication( 3620): 	at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2281)
E/TiApplication( 3620): 	at android.view.ViewRootImpl.draw(ViewRootImpl.java:2177)
E/TiApplication( 3620): 	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
E/TiApplication( 3620): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
E/TiApplication( 3620): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
E/TiApplication( 3620): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
E/TiApplication( 3620): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
E/TiApplication( 3620): 	at android.view.Choreographer.doCallbacks(Choreographer.java:562)
E/TiApplication( 3620): 	at android.view.Choreographer.doFrame(Choreographer.java:532)
E/TiApplication( 3620): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
E/TiApplication( 3620): 	at android.os.Handler.handleCallback(Handler.java:725)
E/TiApplication( 3620): 	at android.os.Handler.dispatchMessage(Handler.java:92)
E/TiApplication( 3620): 	at android.os.Looper.loop(Looper.java:137)
E/TiApplication( 3620): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/TiApplication( 3620): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication( 3620): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/TiApplication( 3620): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/TiApplication( 3620): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/TiApplication( 3620): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 3620): FATAL EXCEPTION: main
E/AndroidRuntime( 3620): java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to org.appcelerator.titanium.view.TiCompositeLayout$LayoutParams
E/AndroidRuntime( 3620): 	at org.appcelerator.titanium.util.TiAnimationBuilder$AnimationListener.onAnimationEnd(TiAnimationBuilder.java:618)
E/AndroidRuntime( 3620): 	at android.view.animation.Animation.fireAnimationEnd(Animation.java:920)
E/AndroidRuntime( 3620): 	at android.view.animation.Animation.getTransformation(Animation.java:878)
E/AndroidRuntime( 3620): 	at android.view.animation.Animation.getTransformation(Animation.java:940)
E/AndroidRuntime( 3620): 	at android.view.animation.AnimationSet.getTransformation(AnimationSet.java:384)
E/AndroidRuntime( 3620): 	at android.view.animation.Animation.getTransformation(Animation.java:940)
E/AndroidRuntime( 3620): 	at android.view.View.drawAnimation(View.java:13205)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13344)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13715)
E/AndroidRuntime( 3620): 	at android.widget.FrameLayout.draw(FrameLayout.java:467)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13596)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 3620): 	at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:688)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13715)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13596)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 3620): 	at org.appcelerator.titanium.view.TiCompositeLayout.dispatchDraw(TiCompositeLayout.java:688)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13594)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13594)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13594)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.drawChild(ViewGroup.java:2928)
E/AndroidRuntime( 3620): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2797)
E/AndroidRuntime( 3620): 	at android.view.View.draw(View.java:13715)
E/AndroidRuntime( 3620): 	at android.widget.FrameLayout.draw(FrameLayout.java:467)
E/AndroidRuntime( 3620): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2211)
E/AndroidRuntime( 3620): 	at android.view.ViewRootImpl.drawSoftware(ViewRootImpl.java:2281)
E/AndroidRuntime( 3620): 	at android.view.ViewRootImpl.draw(ViewRootImpl.java:2177)
E/AndroidRuntime( 3620): 	at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2045)
E/AndroidRuntime( 3620): 	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1854)
E/AndroidRuntime( 3620): 	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
E/AndroidRuntime( 3620): 	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
E/AndroidRuntime( 3620): 	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
E/AndroidRuntime( 3620): 	at android.view.Choreographer.doCallbacks(Choreographer.java:562)
E/AndroidRuntime( 3620): 	at android.view.Choreographer.doFrame(Choreographer.java:532)
E/AndroidRuntime( 3620): 	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
E/AndroidRuntime( 3620): 	at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime( 3620): 	at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 3620): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 3620): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 3620): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 3620): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 3620): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 3620): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 3620): 	at dalvik.system.NativeStart.main(Native Method)

Comments

  1. Quang Pham 2013-05-27

    same here with borderRadius
  2. Mauro Parra-Miranda 2013-05-28

    Related Q&A question: https://developer.appcelerator.com/question/152883/animate-view-with-borderradius
  3. Biju pm 2013-06-12

    fixed the cast exception. https://github.com/appcelerator/titanium_mobile/pull/4382
  4. Fokke Zandbergen 2013-08-22

    This is not fixed in 3.1.2.GA (Samsung Galaxy S2, Android 4.1.2)
       var w = Ti.UI.createWindow({backgroundColor: '#FFF'});
       var v = Ti.UI.createView({
           right: 100,
           width: 100,
           height: 100,
           
           borderWidth: 1,
           borderColor: "#000",
           
           backgroundColor: 'red'
       });
       v.addEventListener('click', function () {
           v.animate({
               right: 0
           });
       });
       w.add(v);
       w.open();
       
  5. Paras Mishra 2013-10-14

    App does not crash with view which as border. Verified the fix on: Device : Google Nexus 7, Android Version: 4.3 SDK: 3.2.0.v20131013140318 CLI version : 3.2.0 OS : MAC OSX 10.8.4 Alloy : 1.2.2 Appcelerator Studio, build: 3.2.0.201310112258 XCode : 5

JSON Source