{ "id": "83209", "key": "TIMOB-6372", "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": [], "resolution": { "id": "5", "description": "All attempts at reproducing this issue failed, or not enough information was available to reproduce the issue. Reading the code produces no clues as to why this behavior would occur. If more information appears later, please reopen the issue.", "name": "Cannot Reproduce" }, "resolutiondate": "2011-12-05T13:00:52.000+0000", "created": "2011-11-29T19:29:13.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "branch-v8", "dr-list" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "issuelinks": [], "assignee": { "name": "ayeung", "key": "ayeung", "displayName": "Allen Yeung", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2012-01-11T13:32:57.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": "Description:\r\nOn android app builds and runs correctly, but after the first click, the app ceases to respond to further clicks. This does not occur on Win 7 or Linux 10.04.\r\n\r\nSteps to reproduce:\r\n1) Create a new mobile project and replace contents of resources dir with contents of attached zip\r\n2) Launch in android emulator\r\n3) Click the button\r\n4) Click \"back\" hardware button \r\n5) Click the button again\r\n\r\nResult:\r\nApp does nothing with further clicks of the button\r\n\r\nExpected:\r\nEach button click opens the second window\r\n\r\nNote:\r\nIf you add an event listener like so:\r\n{code}\r\ndetailContainerWindow.addEventListener('android:back', function(e) {\r\n detailContainerWindow.close();\r\n});\r\n{code}\r\nThe code works as expected", "attachment": [ { "id": "24376", "filename": "Resources 2.zip", "author": { "name": "mapperson", "key": "mapperson", "displayName": "Matthew Apperson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-29T19:29:13.000+0000", "size": 739177, "mimeType": "application/zip" } ], "flagged": false, "summary": "Android: Back button not closing windows in CommonJS modules", "creator": { "name": "mapperson", "key": "mapperson", "displayName": "Matthew Apperson", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mapperson", "key": "mapperson", "displayName": "Matthew Apperson", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium SDK version: 1.8.0.1.v20111116185058\r\nPlatform & version: Android 2.2, Android 2.3.3\r\nDevice Details: Android emulator & Nexus One\r\nHost Operating System: OSX 7.2\r\nTitanium Studio version: 1.0.7.201111142048 & 1.1.0.201111181704", "comment": { "comments": [ { "id": "174893", "author": { "name": "mapperson", "key": "mapperson", "displayName": "Matthew Apperson", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue already resolved due to a fix in an unknown ticket", "updateAuthor": { "name": "mapperson", "key": "mapperson", "displayName": "Matthew Apperson", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-05T13:00:52.000+0000", "updated": "2011-12-05T13:00:52.000+0000" }, { "id": "175528", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Hello.\r\n\r\n\r\nIt seems that this issue still exists and is not directly connected to CommonJS.\r\n\r\n\r\nThe problem seem to exist when heavyweight window is created and \"android:back\" event listener is attached to it. Here is my test case:\r\n\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tfullscreen: true,\r\n\tbackgroundColor: '#f00'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n\ttitle: 'Click me!'\r\n});\r\n\r\nbutton.addEventListener('click', function() {\r\n\tvar newWin = Ti.UI.createWindow({\r\n\t\tmodal: true,\r\n\t\tbackgroundColor: '#0f0'\r\n\t});\r\n\t\r\n\tnewWin.addEventListener('android:back', function() {\r\n\t\tTi.API.debug(typeof newWin.close);\r\n\t\tTi.API.debug(typeof this.close);\r\n Ti.API.debug(this);\r\n\t});\r\n\t\r\n\tnewWin.open();\r\n});\r\n\r\nwin.add(button);\r\n\r\nwin.open();\r\n{code}\r\n\r\n\r\nEnvironment on which I'm testing on:\r\n\r\n* Titanium SDK version: 1.8.0.1 (12/08/11 23:42 00e9d8f...)\r\n* Android 3.1 (Thinkpad tablet)\r\n* Windows XP\r\n* Titanium Studio, build: 1.0.7.201112080131\r\n\r\n\r\n\r\nTo see the issue, you need to run this example, click on button and then press hardware back-button. You should see that green window didn't close. Furthermore, in DDMS output you should see:\r\n\r\nundefined\r\nfunction\r\n[object global]\r\n\r\nThat is second issue that I noticed, \"this\" inside window's event handler is wrongly set to global object instead of window object.\r\n\r\n\r\n\r\nHope this clears this issue. If you have questions, please let me know.\r\n\r\n\r\n\r\nCheers.", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-12-09T01:33:43.000+0000", "updated": "2011-12-09T01:33:43.000+0000" }, { "id": "175529", "author": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "body": "Further investigation has shown that there exists one more issue - window \"close\" event is being fired twice.\r\n\r\n\r\nModified test case looks like this:\r\n\r\n{code}\r\nvar win = Ti.UI.createWindow({\r\n\tfullscreen: true,\r\n\tbackgroundColor: '#f00'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n\ttitle: 'Click me!'\r\n});\r\n\r\nbutton.addEventListener('click', function() {\r\n\r\n\tvar newWin = Ti.UI.createWindow({\r\n\t\tmodal: true,\r\n\t\tbackgroundColor: '#0f0'\r\n\t});\r\n\t\r\n\tvar newButton = Ti.UI.createButton({\r\n\t\ttitle: 'Close me!'\r\n\t});\r\n\t\r\n\tnewButton.addEventListener('click', function() {\r\n\t\tnewWin.close();\r\n\t});\r\n\t\r\n\tnewWin.addEventListener('close', function() {\r\n\t\tTi.API.info('Close event');\r\n\t\tTi.API.debug(this);\r\n\t});\r\n\t\r\n\tnewWin.add(newButton);\r\n\t\r\n\tnewWin.open();\r\n});\r\n\r\nwin.add(button);\r\n\r\nwin.open();\r\n{code}\r\n\r\n\r\nThe output in DDMS:\r\n\r\nClose event\r\n[object global]\r\nClose event\r\n[object TiBaseWindow]\r\n\r\n\r\nSo, as you can see, \"close\" event is fired twice and in first case \"this\" is set to incorrect value.\r\n\r\n\r\nAlso, if following line is added to window's \"close\" event handler:\r\n\r\n{code}\r\nTi.API.debug(this.close);\r\n{code}\r\n\r\ninternal Titanium workings are revealed, which shouldn't be desirable.\r\n\r\n\r\n\r\nCheers.", "updateAuthor": { "name": "ivan.skugor", "key": "ivan.skugor", "displayName": "Ivan Skugor", "active": true, "timeZone": "Europe/Amsterdam" }, "created": "2011-12-09T02:03:19.000+0000", "updated": "2011-12-10T07:45:26.000+0000" }, { "id": "178811", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-01-10T17:50:17.000+0000", "updated": "2012-01-10T17:50:17.000+0000" }, { "id": "178918", "author": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "updateAuthor": { "name": "wluu", "key": "wluu", "displayName": "Wilson Luu", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2012-01-11T13:32:57.000+0000", "updated": "2012-01-11T13:32:57.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }