{ "id": "173636", "key": "TIMOB-27085", "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": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2019-05-20T09:03:19.000+0000", "created": "2019-05-17T11:36:58.000+0000", "priority": { "name": "None", "id": "6" }, "labels": [], "versions": [ { "id": "20238", "description": "", "name": "Release 7.5.0", "archived": false, "released": true, "releaseDate": "2018-11-15" }, { "id": "20432", "name": "Release 8.0.1", "archived": false, "released": true, "releaseDate": "2019-05-15" } ], "issuelinks": [], "assignee": null, "updated": "2019-05-20T09:03:19.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": [], "description": "When calling {{close()}} immediately after {{open()}} Android and iOS fire different events. I noticed this while working with our unit test suite where this happens frequently.\r\n\r\n*Steps to reproduce the behavior*\r\n\r\n# Run the following code in a classic app\r\n{code:javascript}\r\nconst win = Ti.UI.createWindow();\r\nwin.addEventListener('close', () => {\r\n console.log('close');\r\n});\r\nwin.addEventListener('open', () => {\r\n console.log('open');\r\n});\r\nwin.open();\r\nwin.close();\r\n{code}\r\n\r\n*Actual behavior*\r\nOn iOS both events are fired. On Android the behavior varies depending on the SDK version.\r\n\r\n* 8.0.0.GA and before: Only the {{open}} event will be fired\r\n* 8.0.1.GA+: No event will be fired at all\r\n\r\n*Expected behavior*\r\nNot sure what should be the right behavior here in terms of what events to fire, but iOS and Android should fire the same events.", "attachment": [], "flagged": false, "summary": "Android: Close event not fired when close() called immediately after open()", "creator": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "comment": { "comments": [ { "id": "448490", "author": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~jvennemann], this is technically the correct native behavior on Android. We can't directly open/create an Android {{Activity}}. We request the Android OS to do it for us via a call to the Java {{startActivity()}} method. This means it won't open immediately.\r\n\r\nWe used to have a bug where if you open and close a window back-to-back like you are doing, it wouldn't close. The window would stay open (you would see this issue in our mocha test suite as well). This issue was resolved in 8.0.1 via [TIMOB-26996].\r\n\r\nBut basically what this means is if you open/close a window like this, it'll never be natively opened and the events won't fire. I would say this is the correct behavior. Especially since the \"open\" event would be useless since there is no native activity window to work with and I know app devs like to manipulate the {{ActionBar}} via the \"open\" event (they can't in this case).", "updateAuthor": { "name": "jquick", "key": "jquick", "displayName": "Joshua Quick", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2019-05-17T21:15:24.000+0000", "updated": "2019-05-17T21:16:35.000+0000" }, { "id": "448515", "author": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "body": "Thanks for the clarification, Josh. I kinda was expecting that this is the correct behavior on Android so i didn't define the expected behavior in the ticket description.\r\n\r\nI'll close this ticket and will revisit our mocha test suite then. We have a lot of test cases where we just open the window at the end of a test and immediately close in the {{afterEach}} hook. Sometimes this will cause timeouts because {{close()}} will be called before the window has finished opening and no close event will be fired (which is used to finish the {{afterEach}} hook).", "updateAuthor": { "name": "jvennemann", "key": "jvennemann", "displayName": "Jan Vennemann", "active": true, "timeZone": "Europe/Berlin" }, "created": "2019-05-20T09:02:42.000+0000", "updated": "2019-05-20T09:02:42.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }