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

Android: Calling Ti.UI.Android.ProgressIndicator.hide() twice crashes app on next show()

    Details

    • Story Points:
      5
    • Sprint:
      2019 Sprint 8, 2019 Sprint 9, 2019 Sprint 10

      Description

      If you call hide() twice on a ProgressIndicator positioned in the status bar the next time you call show() it will crash. Why I call hide() twice? Because multiple independent processes share a single (indeterminant) ProgressIndicator and call hide() not (needing) knowing what the others did before him.

      Steps to reproduce

      1. Create an app: titanium create -p android -n testProgress --id test.progress
      2. Use the following code for app.js:

            Ti.UI.backgroundColor = 'white';
         
            var win = Ti.UI.createWindow({
              backgroundColor: 'blue'
            });
         
            var button = Ti.UI.createButton({
              title: 'Show Progress Dialog'
            });
         
            var progressIndicator = Ti.UI.Android.createProgressIndicator({
              message: 'Loading...',
              location: Ti.UI.Android.PROGRESS_INDICATOR_STATUS_BAR,
              type: Ti.UI.Android.PROGRESS_INDICATOR_DETERMINANT,
              cancelable: true,
              min: 0,
              max: 10
            });
         
            button.addEventListener('click', function (e) {
              progressIndicator.show();
              var value = 0;
              setInterval(function(){
                if (value > 10) {
                    return;
                }
                progressIndicator.value = value;
                value ++;
              }, 200);
              // do some work that takes 3 seconds
              // ie. replace the following setTimeout block with your code
              setTimeout(function(){
                progressIndicator.hide();
                progressIndicator.hide();
              }, 3000);
            });
         
            win.add(button);
            win.open();
            

      3. Build it to a device: titanium build -p android -T device
      4. Press the button and wait for the progress indicator to finish
      5. Press the button again and watch the app crash and spit out the following log:

        09-10 20:50:13.027: E/TiApplication(5497): (main) [10239,10239] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 3.1.3,2013/09/08 09:51,b8f209a
            09-10 20:50:13.027: E/TiApplication(5497): java.lang.NullPointerException
            09-10 20:50:13.027: E/TiApplication(5497):  at ti.modules.titanium.ui.widget.TiUIProgressIndicator.handleShow(TiUIProgressIndicator.java:187)
            09-10 20:50:13.027: E/TiApplication(5497):  at ti.modules.titanium.ui.widget.TiUIProgressIndicator.show(TiUIProgressIndicator.java:144)
            09-10 20:50:13.027: E/TiApplication(5497):  at ti.modules.titanium.ui.android.ProgressIndicatorProxy.handleShow(ProgressIndicatorProxy.java:62)
            09-10 20:50:13.027: E/TiApplication(5497):  at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:233)
            09-10 20:50:13.027: E/TiApplication(5497):  at android.os.Handler.dispatchMessage(Handler.java:95)
            09-10 20:50:13.027: E/TiApplication(5497):  at android.os.Looper.loop(Looper.java:137)
            09-10 20:50:13.027: E/TiApplication(5497):  at android.app.ActivityThread.main(ActivityThread.java:4921)
            09-10 20:50:13.027: E/TiApplication(5497):  at java.lang.reflect.Method.invokeNative(Native Method)
            09-10 20:50:13.027: E/TiApplication(5497):  at java.lang.reflect.Method.invoke(Method.java:511)
            09-10 20:50:13.027: E/TiApplication(5497):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
            09-10 20:50:13.027: E/TiApplication(5497):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
            09-10 20:50:13.027: E/TiApplication(5497):  at dalvik.system.NativeStart.main(Native Method)
            09-10 20:50:13.082: E/AndroidRuntime(5497): FATAL EXCEPTION: main
            09-10 20:50:13.082: E/AndroidRuntime(5497): java.lang.NullPointerException
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at ti.modules.titanium.ui.widget.TiUIProgressIndicator.handleShow(TiUIProgressIndicator.java:187)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at ti.modules.titanium.ui.widget.TiUIProgressIndicator.show(TiUIProgressIndicator.java:144)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at ti.modules.titanium.ui.android.ProgressIndicatorProxy.handleShow(ProgressIndicatorProxy.java:62)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:233)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at android.os.Handler.dispatchMessage(Handler.java:95)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at android.os.Looper.loop(Looper.java:137)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at android.app.ActivityThread.main(ActivityThread.java:4921)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at java.lang.reflect.Method.invokeNative(Native Method)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at java.lang.reflect.Method.invoke(Method.java:511)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1027)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:794)
            09-10 20:50:13.082: E/AndroidRuntime(5497):     at dalvik.system.NativeStart.main(Native Method)
            

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              fokkezb Fokke Zandbergen
              Reviewer:
              Gary Mathews
              Tester:
              Lokesh Choudhary
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Integration