Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26204] Android: TransformAfterLayout NullPointerException in Ti.Animation

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-08-24T01:25:57.000+0000
Affected Version/sRelease 7.2.0
Fix Version/sRelease 7.5.0
ComponentsAndroid
Labelsandroid
ReporterSergey Volkov
AssigneeGary Mathews
Created2018-07-11T15:21:30.000+0000
Updated2018-08-24T01:26:11.000+0000

Description

[ERROR] TiApplication: java.lang.NullPointerException: Attempt to invoke virtual method 'void org.appcelerator.titanium.proxy.TiViewProxy.handlePendingAnimation(boolean)' on a null object reference
[ERROR] TiApplication:  at org.appcelerator.titanium.view.TiUIView$1$1.callAsync(TiUIView.java:549)
[ERROR] TiApplication:  at org.appcelerator.titanium.util.TiAnimationBuilder$AnimatorListener.onAnimationEnd(TiAnimationBuilder.java:1371)
[ERROR] TiApplication:  at com.nineoldandroids.animation.AnimatorSet$AnimatorSetListener.onAnimationEnd(AnimatorSet.java:756)
[ERROR] TiApplication:  at com.nineoldandroids.animation.ValueAnimator.endAnimation(ValueAnimator.java:1034)
[ERROR] TiApplication:  at com.nineoldandroids.animation.ValueAnimator.access$11(ValueAnimator.java:1024)
[ERROR] TiApplication:  at com.nineoldandroids.animation.ValueAnimator$AnimationHandler.handleMessage(ValueAnimator.java:669)
[ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:135)
[ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:5221)
[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:899)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
https://github.com/appcelerator/titanium_mobile/blob/0a7dce77bb4fbdd21370512800a61542670e6006/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java#L549

Comments

  1. Sergey Volkov 2018-07-11

    Fix:
       --- a/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java
       +++ b/android/titanium/src/java/org/appcelerator/titanium/view/TiUIView.java
       @@ -546,7 +546,7 @@ public abstract class TiUIView
        					public void callAsync(KrollObject krollObject, HashMap args) {}
        					public void callAsync(KrollObject krollObject, Object[] args) {
        						bTransformPending.set(false);
       -						proxy.handlePendingAnimation(true);
       +						p.handlePendingAnimation(true);
        					}
        				});
        				animBuilder.start(p, v);
       
  2. Sharif AbuDarda 2018-07-12

    Hello [~s.volkov], Thanks for the ticket. Our engineering will look into it.
  3. Hans Knöchel 2018-07-12

    [~s.volkov] Can you let us know in which situations this error occurs? A minimal test case would be lit!
  4. Sergey Volkov 2018-07-12

    It happens after closing window with views on which were periodically applied transformation like this
       $.indicator.transform = Ti.UI.create2DMatrix().rotate(angle)
       
    I think it will be hard to intentionally reproduce this, crash is happening in callback, by the time view was already released and proxy became null.
  5. Sergey Volkov 2018-07-13

       var matrix = Ti.UI.create2DMatrix();
       
       function open() {
         var closed = false;
         function rotate(view, angle) {
           if (closed) {
             return;
           }
           console.log('Rotate');
           angle += 45;
           if (angle >= 360) {
             angle -= 360;
           }
           view.transform = matrix.rotate(angle);
           setTimeout(function() {
             rotate(view, angle)
           }, 150)
         }
       
         var window = Ti.UI.createWindow({
           width: Ti.UI.FILL,
           height: Ti.UI.FILL,
           backgroundColor: 'white',
           layout: 'horizontal'
         });
       
         var view = Ti.UI.createImageView({
           width: 50,
           height: 50,
           image: 'assets/images/tab2.png'
         });
       
         rotate(view, 0);
       
         window.addEventListener('close', function onClose() {
           window.removeEventListener('close', onClose);
           console.log('CLOSE');
           closed = true;
         });
         window.add(view);
         window.open();
       }
       
       var win = Ti.UI.createWindow({title: 'TIMOB-26204'});
       var btn = Ti.UI.createButton({title: 'Open window'});
       btn.addEventListener('click', open);
       win.add(btn);
       win.open();
       
    1. tap "Open window" button 2. wait for spinning image 3. press back button.
  6. Hans Knöchel 2018-07-24

    PR (community): https://github.com/appcelerator/titanium_mobile/pull/10202
  7. Samir Mohammed 2018-07-26

    *Closing ticket*, Verified fix in SDK Version: 7.4.0.v20180726102127 *FR Passed (Test Steps):*

    Created a titanium application with the test case mentioned above

    Ran the App

    Pressed the "Open window" button

    Waited for the spinning image

    pressed the back button

    Repeated the above steps various times to ensure no error was shown or the application did not crash like previously

    *Test Environment*
       APPC Studio: 5.0.0.201712081732
       APPC CLI: 7.0.4
       Nexus 6p Emulator (7.1)
       Operating System Name: Mac OS High Sierra
       Operating System Version: 10.13
       Node.js Version: 8.9.1
       Xcode 9.2
       

JSON Source