{ "id": "108545", "key": "AC-2610", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2013-01-25T23:37:12.000+0000", "created": "2013-01-25T09:14:52.000+0000", "labels": [ "core", "feature" ], "versions": [], "issuelinks": [], "assignee": { "name": "aleard", "key": "aleard", "displayName": "Alan Leard", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-03-08T07:41:41.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": "We have a simple code in which we create a Parent window(in ApplicationWindow.js file attached) and then create a child window. In child window we add a Webview and then add the child window to the parent window. We then register a setTimeout function that removes the child window from the parent.\r\n\r\nThe webview opens an html page which has a setInterval function that prints 'alive' continuously . So here lies the issue:\r\n\r\nRemoving the child window from the parent window and setting the child window object to null does not remove or destroy the child object. The child object still exist and the proof of it is the 'alive' statement being printed continuously. \r\n\r\nApart from the code snippet attached we have added the following code in the setTimeout function. Just to verify and confirm that the children are added and removed . Here was the code added to confirm the same\r\n~~~\r\n\t//this is the webView in FirstView\r\n\tparent.children.length; //Returns 1 The firstView is the child\r\n\t\t\t\t\r\n\t((parent.children[0]).children).length; // Returns 1 . The webview 'self' in FirstView.js is the child\r\n\t\t\t\t\r\n\t//Removing the WebView the making it null\r\n\t\t\t parent.children[0].remove(((parent.children[0]).children[0]));\r\n\t((parent.children[0]).children[0]) = null;\r\n\t\t\t\t\r\n\t\t\t\t\r\n ((parent.children[0]).children).length; // Returns 0 now as the child webview was removed. Ideally the 'alive' print should have stopped\r\n\t\t\t\t\r\n\t\t\t\t//Removing the child- FirstView from the parent \r\n parent.remove(parent.children[0]);\r\n\t\t\t\tparent.children = null;\r\n\t\t\t\t//Ideally the 'alive' print from webview should have stopped but it doesnt\r\n\t\t\t\t\r\n\t\t\t\t//child.close();\r\n\t\t\t\tparent.children.length; // Return 0\r\n\t\t\t\t\r\n\t\t\t\t//Parent Close called. But still doesnt kill the alive printed on console\r\n\t\t\t\tparent.close();\r\n\r\nWhy is this code not killing the child window?\r\nWithout changing the way we are adding and removing child window from parent, how can we kill the child window and the webview? the proof of which would be the the 'alive' is not printed anymore.\r\n", "attachment": [ { "id": "35113", "filename": "webViewExample.zip", "author": { "name": "anandkumarsingh", "key": "anandkumarsingh", "displayName": "Anand Kumar Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-25T09:14:52.000+0000", "size": 3721408, "mimeType": "application/zip" } ], "flagged": false, "summary": " Removing the child window from parent window does not kill the child window", "creator": { "name": "anandkumarsingh", "key": "anandkumarsingh", "displayName": "Anand Kumar Singh", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "anandkumarsingh", "key": "anandkumarsingh", "displayName": "Anand Kumar Singh", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Tested on iOS. ", "comment": { "comments": [ { "id": "236052", "author": { "name": "aleard", "key": "aleard", "displayName": "Alan Leard", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Anand,\r\nThere are a number of issues with your code. First, you are calling child.close(); which is a function that doesn't exist as \"child\" is a view not a window. Second, you are creating an anonymous interval that cannot be cleared. Using setInterval can be very dangerous so you need to be sure to use it carefully and be sure to name it so you can later remove it. So, the similest fix in your code would be to call parent.close(); on line 39 instead of child.close(). The other option would be to clear the interval before removing the webview which will allow the webview to be released. You could do this by calling a Ti.App.fireEvent() to stop the interval before closing removing and nulling the webview. In this case your code in ex.html would look like this: \r\n{code}\r\n\r\n\r\n\r\n \r\n\texample\r\n\t\r\n\r\n\r\n\t\r\n\r\n{code}\r\nThen your setTimeout could look like this:\r\n{code}\r\n\t\tsetTimeout(function()\r\n\t\t\t{ \r\n\t\t\t\tTi.API.info(\"closing webview window\");\r\n\t\t\t\tTi.App.fireEvent('closeWindow');\r\n\t\t\t\t\r\n\t\t\t\tparent.remove(child);\r\n\t\t\t\tchild = null;\r\n\t\t\t\t\r\n\t\t\t\t//or\r\n\t\t\t\t//parent.close();\r\n\t\t\t\t\r\n\t\t\t}, 10000);\r\n{code}\r\n\r\nHope this helps!", "updateAuthor": { "name": "aleard", "key": "aleard", "displayName": "Alan Leard", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-01-25T23:37:12.000+0000", "updated": "2013-01-25T23:37:12.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }