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

Android: ProgressIndicator logs "WindowLeaked" exception when hiding dialog and closing window at same time as of 8.0.2

    Details

    • Story Points:
      5
    • Sprint:
      2019 Sprint 17

      Description

      Summary:
      As of Titanium 8.0.2, hiding a Ti.UI.Android.ProgressIndicator and closing its parent window at the same time will log a "WindowLeaked" exception.

      This is not a crash. Nothing harmful occurs.
      This is merely an unsightly exception stack trace error that occurs in the log.

      Steps to reproduce:

      1. Build and run the below code on Android.
      2. Tap on the "Show Progress Dialog" button.
      3. Wait 2 seconds for the progress dialog and its window to close.
      4. Observe the log.

      var progressIndicator = Ti.UI.Android.createProgressIndicator({
      	message: "Progressing...",
      	location: Ti.UI.Android.PROGRESS_INDICATOR_DIALOG,
      	type: Ti.UI.Android.PROGRESS_INDICATOR_INDETERMINANT,
      	cancelable: false,
      	persistent: true,
      });
       
      var window = Ti.UI.createWindow();
      var button = Ti.UI.createButton({ title: "Show Progress Dialog" });
      button.addEventListener("click", function(e) {
      	var childWindow = Ti.UI.createWindow({ title: "Child Window" });
      	childWindow.addEventListener("open", function() {
      		progressIndicator.show();
      		setTimeout(function() {
      			progressIndicator.hide();
      			childWindow.close();
      // This works-around the problem.
      //			setTimeout(function() { childWindow.close(); }, 1);
      		}, 2000);
      	});
      	childWindow.open();
      });
      window.add(button);
      window.open();
      

      Result:
      The following gets logged when the progress dialog closes.

      [ERROR] WindowManager: android.view.WindowLeaked: Activity org.appcelerator.titanium.TiActivity has leaked window DecorView@e74eabe[TiActivity] that was originally added here
      [ERROR] WindowManager: 	at android.view.ViewRootImpl.<init>(ViewRootImpl.java:518)
      [ERROR] WindowManager: 	at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:346)
      [ERROR] WindowManager: 	at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:94)
      [ERROR] WindowManager: 	at android.app.Dialog.show(Dialog.java:329)
      [ERROR] WindowManager: 	at ti.modules.titanium.ui.widget.TiUIProgressIndicator.handleShow(TiUIProgressIndicator.java:236)
      [ERROR] WindowManager: 	at ti.modules.titanium.ui.widget.TiUIProgressIndicator.show(TiUIProgressIndicator.java:146)
      [ERROR] WindowManager: 	at ti.modules.titanium.ui.android.ProgressIndicatorProxy.handleShow(ProgressIndicatorProxy.java:59)
      [ERROR] WindowManager: 	at org.appcelerator.titanium.proxy.TiViewProxy.show(TiViewProxy.java:765)
      [ERROR] WindowManager: 	at ti.modules.titanium.ui.TiDialogProxy.access$001(TiDialogProxy.java:29)
      [ERROR] WindowManager: 	at ti.modules.titanium.ui.TiDialogProxy$1.onCurrentActivityReady(TiDialogProxy.java:47)
      [ERROR] WindowManager: 	at org.appcelerator.titanium.util.TiUIHelper.waitForCurrentActivity(TiUIHelper.java:195)
      [ERROR] WindowManager: 	at ti.modules.titanium.ui.TiDialogProxy.show(TiDialogProxy.java:42)
      [ERROR] WindowManager: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
      [ERROR] WindowManager: 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:63)
      [ERROR] WindowManager: 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:978)
      [ERROR] WindowManager: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1207)
      [ERROR] WindowManager: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:266)
      [ERROR] WindowManager: 	at android.os.Handler.dispatchMessage(Handler.java:102)
      [ERROR] WindowManager: 	at android.os.Looper.loop(Looper.java:193)
      [ERROR] WindowManager: 	at android.app.ActivityThread.main(ActivityThread.java:6694)
      [ERROR] WindowManager: 	at java.lang.reflect.Method.invoke(Native Method)
      [ERROR] WindowManager: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
      [ERROR] WindowManager: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
      

      Note:
      The error appears to be harmless. The exception is being caught and logged. The reason it is happening is because the dialog is being shown again in a destroyed activity window. Why the code is automatically calling its show() method again after hiding/closing is what we need to track down (this is the real bug; but our safety mechanisms are catching it).

      Comment from Hans Knöchel:
      We suspect it being related to showing our loader class that uses a Ti.UI.ActivityIndicator. This did not happen on earlier versions of the SDK.

      Work-around:
      Instead of hiding the dialog and closing its parent window back-to-back like this...

      progressIndicator.hide();
      childWindow.close();
      

      Delay closing the window after hiding the dialog like this...

      progressIndicator.hide();
      setTimeout(function() { childWindow.close(); }, 1);
      

        Attachments

          Activity

            People

            • Assignee:
              jquick Joshua Quick
              Reporter:
              hknoechel Hans Knöchel
              Reviewer:
              Gary Mathews
              Tester:
              Satyam Sekhri
            • Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Source Code