Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14916] Android: Endless "Window is closed normally" appear in the logcat.

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2013-08-21T23:01:31.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 18, 2013 Sprint 18 API, Release 3.1.3, Release 3.2.0
ComponentsAndroid
Labelsqe-testadded
Reporterpantherqin
AssigneePing Wang
Created2013-08-16T08:40:54.000+0000
Updated2013-09-03T08:57:48.000+0000

Description

I just installed and switched my project from using 3.1.1GA to 3.1.2GA. And on Android device it appears everything works fine. However in the logcat window, I can see ENGLESSLY "Window is closed normally". I am sure I did not create a dead loop and create>open>close windows at the background. So may I ask where could possibility be the reason causing such weird logs? Back in the titanium mobile source code, it appear to be from the window file.
var _open = Window.prototype.open;
	Window.prototype.open = function(options) {
		// Retain the window until it has closed.
		var handle = new PersistentHandle(this);

		var self = this;
		this.on("close", function(e) {
			if (e._closeFromActivityForcedToDestroy) {
				if (kroll.DBG) {
					kroll.log(TAG, "Window is closed because the activity is forced to destroy by Android OS.");
				}
				return;
			}

			// Dispose the URL context if the window's activity is destroyed.
			if (self._urlContext) {
				Script.disposeContext(self._urlContext);
				self._urlContext = null;
			}
			handle.dispose();

			if (kroll.DBG) {
				kroll.log(TAG, "Window is closed normally.");
			}
		});

		_open.call(this, options);
	}

Comments

  1. pantherqin 2013-08-16

    sample code to simulate the issue: var win = Titanium.UI.createWindow({ width : '100%', height : '100%', backgroundColor : '#FF00FF', }); win.addEventListener("blur", function(e) { win.close(); }); win.open(); setTimeout(function() { win.close(); }, 2000); Obviously after win.close(), event "blur" is triggered. And it tried to close the window(which is already closed) again. Thus a dead loop is formed. This error never happened in 3.1.1 or 3.0.0.
  2. Ping Wang 2013-08-20

    PR: https://github.com/appcelerator/titanium_mobile/pull/4587 Test case is in the last comment. Please add
    <property name="ti.android.useLegacyWindow" type="bool">true</property>
    to the tiapp.xml to reproduce the fail case.
  3. pantherqin 2013-08-21

    Does it mean if I set this value to "false" in tiapp.xml, the issue will go away? I am using 3.1.2GA. I mean just as a temporary fix.
  4. Ping Wang 2013-08-21

    [~pantherqin], don't worry about that if you use 3.1.x. The "ti.android.useLegacyWindow" property will be introduced in 3.2.0. My last comment is just for the tester since the issue is only for LW windows and my PR is against the master branch. BTW, this fix will be also in 3.1.3.
  5. pantherqin 2013-08-21

    Alright. Got it. Thanks :-)
  6. Hieu Pham 2013-08-21

    master PR: https://github.com/appcelerator/titanium_mobile/pull/4587
  7. Ping Wang 2013-08-22

    3_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/4596
  8. Dhirendra Jha 2013-08-23

    Used the below environment to verify this issue - Appcelerator Studio: 3.1.3.201308201707 Titanium SDK: 3.1.3.v20130822140128 acs: 1.0.6 alloy: 1.2.1-cr npm: 1.3.2 titanium: 3.1.2 titanium-code-processor: 1.0.2 Devices: Nexus 7 (v4.3, v4.2.1), Nexus 4 (v4.0.4), Galaxy Note (v2.3.6) Tested Below - 1) Reproduced this issues using the code mentioned with 3.1.2.GA build. 2) Used the same code with build 3.1.3.v20130822140128. Message "Window is closed normally" appears only one time in logcat. Its working fine in this build. So this issue is no more reproducible using the 3.1.3.v20130822140128 build. Hence closing this issue.

JSON Source