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

Android: Simple animation causes application crash

    Details

      Description

      When running the following code, the animation occurs correctly the first time I click on the view--the green box spins around once, then stops. (If run in a lightweight window, at the finish of the animation, there's a visual anomaly where part of the underlying window shows through. But this is not the bug in question.)

      The second time I click on the view, the app crashes immediately. Stack trace included below code.

       
      var win1 = Ti.UI.createWindow({
      	backgroundColor : "white"
      });
      var view = Ti.UI.createView({
      	height : 100,
      	width : 100,
      	backgroundColor : "green"
      });
      win1.add(view);
      win1.open();
       
      var matrix = Ti.UI.create2DMatrix();
      var matrix1 = matrix.rotate(120);
      var matrix2 = matrix.rotate(240);
      var transforms = [matrix, matrix1, matrix2];
      // We start at 0, so the first rotation is to 120 degrees
      var nextTransform = 1;
      animation = Ti.UI.createAnimation({
      	transform : transforms[nextTransform],
      	duration : 500,
      });
      // On iOS, override the default easing to avoid 
      // jerky transitions between animations.
      if (Ti.Platform.name === 'iPhone OS') {
      	animation.curve = Ti.UI.iOS.ANIMATION_CURVE_LINEAR;
      }
       
      animation.addEventListener('complete', function(e) {
      	// view.transform = transforms[nextTransform];
      	if(nextTransform == 0) {
      		// Rotation complete, reset for next time
      		nextTransform = 1;
      		animation.transform = transforms[nextTransform];
      	} else {
      		// Rotate to the next position
      		nextTransform = (nextTransform + 1) % 3;
      		animation.transform = transforms[nextTransform];
      		view.animate(animation);
      	}
      });
       
      view.addEventListener('click', function(e) {
      	view.animate(animation);
      });
      

      Stack trace:

      E/AndroidRuntime(  421): FATAL EXCEPTION: main
      E/AndroidRuntime(  421): java.lang.NullPointerException
      E/AndroidRuntime(  421): 	at org.appcelerator.titanium.view.Ti2DMatrix.interpolate(Ti2DMatrix.java:187)
      E/AndroidRuntime(  421): 	at org.appcelerator.titanium.util.TiAnimationBuilder$TiMatrixAnimation.applyTransformation(TiAnimationBuilder.java:416)
      E/AndroidRuntime(  421): 	at android.view.animation.AnimationSet.initializeInvalidateRegion(AnimationSet.java:286)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.drawChild(ViewGroup.java:1498)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
      E/AndroidRuntime(  421): 	at android.view.View.draw(View.java:6743)
      E/AndroidRuntime(  421): 	at android.widget.FrameLayout.draw(FrameLayout.java:352)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.drawChild(ViewGroup.java:1638)
      E/AndroidRuntime(  421): 	at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
      E/AndroidRuntime(  421): 	at android.view.View.draw(View.java:6743)
      E/AndroidRuntime(  421): 	at android.widget.FrameLayout.draw(FrameLayout.java:352)
      E/AndroidRuntime(  421): 	at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1842)
      E/AndroidRuntime(  421): 	at android.view.ViewRoot.draw(ViewRoot.java:1407)
      E/AndroidRuntime(  421): 	at android.view.ViewRoot.performTraversals(ViewRoot.java:1163)
      E/AndroidRuntime(  421): 	at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
      E/AndroidRuntime(  421): 	at android.os.Handler.dispatchMessage(Handler.java:99)
      E/AndroidRuntime(  421): 	at android.os.Looper.loop(Looper.java:123)
      E/AndroidRuntime(  421): 	at android.app.ActivityThread.main(ActivityThread.java:4627)
      E/AndroidRuntime(  421): 	at java.lang.reflect.Method.invokeNative(Native Method)
      E/AndroidRuntime(  421): 	at java.lang.reflect.Method.invoke(Method.java:521)
      E/AndroidRuntime(  421): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
      E/AndroidRuntime(  421): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
      E/AndroidRuntime(  421): 	at dalvik.system.NativeStart.main(Native Method)
      

      I tried to simplify the test case by removing the complete handler, so there's only a single animation: however, for some reason I can't get the animation to run at all in that case.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pwang Ping Wang
                Reporter:
                aevans Arthur Evans
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

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

                    Git Integration