{ "id": "62459", "key": "TIMOB-1827", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11236", "name": "Release 1.6.0 M03", "archived": true, "released": true, "releaseDate": "2011-01-03" }, { "id": "12094", "description": "", "name": "Sprint 2012-02", "archived": true, "released": true, "releaseDate": "2012-01-29" }, { "id": "12593", "name": "Release 2.0.0", "archived": false, "released": true, "releaseDate": "2012-03-30" }, { "id": "12677", "description": "Release 1.8 Service Pack 1", "name": "Release 1.8.1", "archived": true, "released": true, "releaseDate": "2012-01-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2012-03-11T22:20:25.000+0000", "created": "2011-04-15T03:03:15.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "parity", "qe-testadded", "release-1.6.0" ], "versions": [], "issuelinks": [ { "id": "14563", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "84912", "key": "TIMOB-7201", "fields": { "summary": "Android: UI.window - open and focus events fire more than once", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-12-10T06:18:54.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

In this simple example, if you click the close button in the\r\nsecond window the close event listener runs FOUR times:

\r\n
\r\n\r\n/*global Ti, Titanium, alert */\r\nTitanium.UI.setBackgroundColor('#000');\r\nvar win1 = Titanium.UI.createWindow({  title:'Test', backgroundColor:'#fff', fullscreen: true, exitOnClose: true });\r\n\r\nvar win2 = Ti.UI.createWindow({title:'window 2', fullscreen:true, backgroundColor: 'green'});\r\nwin2.addEventListener('close',function(){Ti.API.info('CLOSE');});\r\n\r\nvar open = Ti.UI.createButton({title: 'open'});\r\nopen.addEventListener('click', function(){win2.open();});\r\nwin1.add(open);\r\n\r\nvar close = Ti.UI.createButton({title: 'close'});\r\nclose.addEventListener('click', function(){win2.close();});\r\nwin2.add(close);\r\n\r\nwin1.open();\r\n
\r\n

Note: if you click the back button instead of clicking the close\r\nbutton, it fires only once.

{html}", "attachment": [ { "id": "18064", "filename": "closetest.zip", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:03:15.000+0000", "size": 772036, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: window close event firing multiple times", "creator": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "126759", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

After this is fixed see if it helps at all with the OOM\nexperienced by Friedrich Seydel in \nthis comment from ticket 1827.

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:03:16.000+0000", "updated": "2011-04-15T03:03:16.000+0000" }, { "id": "126760", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

Assign to Don for milestone/priority. (Feel free to assign back!\n:) )

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:03:16.000+0000", "updated": "2011-04-15T03:03:16.000+0000" }, { "id": "126761", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

cf #1489 re the backgroundImage and OOM

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:03:16.000+0000", "updated": "2011-04-15T03:03:16.000+0000" }, { "id": "126762", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Related to Activity refactor. There are multiple close paths\nthrough the different exit methods that can fire 1 to n events.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:16.000+0000", "updated": "2011-04-15T03:03:16.000+0000" }, { "id": "126763", "author": { "name": "jeff", "key": "jeff", "displayName": "Jeff", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Please change that back to 1.5 and make sure this issue is\nresolved in the Q4 release. This is a critical issue and we've had\nto work around this for 2 major projects and over 9 months.

\n

If Android is not going to receive the attention it needs to be\nstable, we will be canceling our account and moving to another\ncross-platform development suite at the first of the year.

{html}", "updateAuthor": { "name": "jeff", "key": "jeff", "displayName": "Jeff", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:17.000+0000", "updated": "2011-04-15T03:03:17.000+0000" }, { "id": "126764", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Unfortunately 1.5.0 is fully planned and we're working to get it\nshipped in December. I've created a new 1.5.1 M01 milestone and I'm\nmoving this ticket there so we can start working on it as soon as\n1.5.0 is out the door. It will then be available from the CI\nbuild.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:17.000+0000", "updated": "2011-04-15T03:03:17.000+0000" }, { "id": "126765", "author": { "name": "scott", "key": "scott", "displayName": "Scott", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

This is a major problem for me as well. Is there any workaround\nany one can think of at the moment until this bug is fixed and any\nideas when a fix for this will be complete?

{html}", "updateAuthor": { "name": "scott", "key": "scott", "displayName": "Scott", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:17.000+0000", "updated": "2011-04-15T03:03:17.000+0000" }, { "id": "126766", "author": { "name": "jimwilliams", "key": "jimwilliams", "displayName": "jimwilliams", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I'm opening windows and showing them modally. Since javascript\nallows methods and properties to be added dynamically to an object,\nI can get around this problem with code like this (from the example\nabove):

\n
\nvar win2 = Ti.UI.createWindow({title:'window 2', fullscreen:true, backgroundColor: 'green'});\nwin2.CloseFired = false;\n\nwin2.addEventListener('close',\nfunction()\n{\n   if (this.CloseFired) return;\n \n   this.CloseFired = true;\n   // do what needs to be done \n   Ti.API.info('CLOSE');\n});\n
\n

It's not very sophisticated, but seems to do the trick.

{html}", "updateAuthor": { "name": "jimwilliams", "key": "jimwilliams", "displayName": "jimwilliams", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:18.000+0000", "updated": "2011-04-15T03:03:18.000+0000" }, { "id": "126767", "author": { "name": "jimwilliams", "key": "jimwilliams", "displayName": "jimwilliams", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Quick follow-up; the technique I used above works ok for\nAndroid, but not for iPhone which seems to somehow reuse the\nwindows/listeners. I've made the fix conditional for Android only\nin my code and both seem to now work as expected.

{html}", "updateAuthor": { "name": "jimwilliams", "key": "jimwilliams", "displayName": "jimwilliams", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:18.000+0000", "updated": "2011-04-15T03:03:18.000+0000" }, { "id": "126768", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

To QA:

\n

To test this, use attached CloseTest.zip (import the project\ntherein). When you run it, you should see only one\nclose event (in the console / logcat) when you close the windows\nthat are opened with the \"no url\" buttons -- in fact, with the\nfailing version of the SDK, you'll see 3 per closure, which is a\nbug. For the \"own url\" windows, you should see two\n(one from an event listener created in the main window, one from an\nevent listener created inside the second window's own JS file), but\nyou'll see six.

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:03:19.000+0000", "updated": "2011-04-15T03:03:19.000+0000" }, { "id": "126769", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

(from [4ede763ab6c786a90f2e0397152d78b0a79781f5])\n[#1827 state:fixed-in-qa] Fix multiple window\nclose event firings by making sure that the multiple possible code\npaths from a window closure still only result in one close event\nbeing fired. \nhttps://github.com/appcelerator/titanium_mobile/commit/4ede763ab6c7...

{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:03:19.000+0000", "updated": "2011-04-15T03:03:19.000+0000" }, { "id": "126770", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

confirmed on a G2 running 2.2 and a g1 running 1.6. [INFO] Titanium SDK version: 1.6.0 (12/28/10\n10:46 4ede763). results as Bill describes.

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:19.000+0000", "updated": "2011-04-15T03:03:19.000+0000" }, { "id": "178814", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Reopening bug. Both test cases attached to this bug fails in the following environment:\r\n\r\nSDK build: 1.8.0.1\r\nRuntime: V8, Rhino\r\nTitanium Studio, build: 1.0.8.201201091758\r\nDevice: Nexus S (2.3.6)\r\n\r\nNote: For both test cases, the bug does not appear in sdk build *1.7.5*", "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-01-10T18:08:40.000+0000", "updated": "2012-01-10T18:08:40.000+0000" }, { "id": "179354", "author": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "body": "I get the close event twice on a heavyweight url-based window. SDK 1.8.0.1 and 1.9.0.v20120111233134.", "updateAuthor": { "name": "bitshftr", "key": "bitshftr", "displayName": "Shawn Lipscomb", "active": true, "timeZone": "America/New_York" }, "created": "2012-01-16T07:46:38.000+0000", "updated": "2012-01-16T07:46:38.000+0000" }, { "id": "179523", "author": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "body": "This issue still exists for Continuous Build Titanium 1.9.0 (2012/01/16 11:16 366b32d) and v8 runtime (rhino not tested)", "updateAuthor": { "name": "pdowsett", "key": "pdowsett", "displayName": "Paul Dowsett", "active": true, "timeZone": "Europe/London" }, "created": "2012-01-16T17:45:09.000+0000", "updated": "2012-01-16T17:45:09.000+0000" }, { "id": "180553", "author": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening issue\r\n\r\nTested with Ti Studio build 1.0.8.201201210622\r\nTi Mob SDK 1.8.1.v20120124200134\r\nOSX Lion\r\n\r\nAndroid Emulator 2.2\r\n\r\nBoth test cases failed (fail case in description and Bill's test app) by producing two close events", "updateAuthor": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-25T11:04:13.000+0000", "updated": "2012-01-25T11:04:13.000+0000" }, { "id": "180563", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "fixed in 1.9 master.", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2012-01-25T11:34:56.000+0000", "updated": "2012-01-25T11:34:56.000+0000" }, { "id": "181005", "author": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing issue\r\n\r\nTested with Ti Studio build 1.0.8.201201262211\r\nTi Mob SDK 1.8.1.v20120127173134\r\nOSX Lion\r\nNexus S OS 2.2.2\r\n\r\nVerified that only one window close event is fired", "updateAuthor": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-28T13:15:49.000+0000", "updated": "2012-01-28T13:15:49.000+0000" }, { "id": "181120", "author": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening/closing to add/remove labels", "updateAuthor": { "name": "mpettiford", "key": "mpettiford", "displayName": "Michael Pettiford", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-30T14:49:35.000+0000", "updated": "2012-01-30T14:49:35.000+0000" }, { "id": "283500", "author": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Anvil testcase PR https://github.com/appcelerator/titanium_mobile/pull/4967\n", "updateAuthor": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-12-10T06:18:54.000+0000", "updated": "2013-12-10T06:18:54.000+0000" } ], "maxResults": 20, "total": 20, "startAt": 0 } } }