{ "id": "85491", "key": "TIMOB-7413", "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": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-02-08T17:20:47.000+0000", "created": "2012-01-25T17:23:25.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "qe-and012312" ], "versions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" }, { "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" } ], "issuelinks": [ { "id": "14865", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "outwardIssue": { "id": "85021", "key": "TIMOB-7246", "fields": { "summary": "iOS - Window Proxy does not get release if animated with callback", "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": "Critical", "id": "1" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2013-05-01T20:06:59.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": "The following app.js results in a runtime error in both runtimes:\r\n\r\n{code:title=\"app.js\"}\r\nvar f = Ti.UI.createWindow().open;\r\nf();\r\n{code}\r\n\r\nThe error:\r\n\r\n{code}\r\nE/TiJSError( 764): (main) [512,1939] ----- Titanium Javascript Runtime Error -----\r\nE/TiJSError( 764): (main) [1,1940] - In ti:/window.js:173,38\r\nE/TiJSError( 764): (main) [0,1940] - Message: Uncaught TypeError: Cannot read property 'closed' of undefined\r\nE/TiJSError( 764): (main) [0,1940] - Source: \t\tif (this.currentState != this.state.closed) {\r\nE/V8Exception( 764): Exception occurred at ti:/window.js:173: Uncaught TypeError: Cannot read property 'closed' of undefined\r\n{code}\r\n\r\nIt could be that this goes beyond windows methods... It's just that we know of this particular example.\r\n\r\nh3. Original Description\r\nRunning standard code causes internal runtime error. Log Attached.\r\n\r\nThere is a similar crash in Rhino.\r\n\r\nCode works fine in iOS.\r\n\r\nSteps to Reproduce:\r\n\r\n1. Run Code:\r\n\r\n{code:title=app.js}\r\nfunction Window1(){\r\n\tvar self = {};\r\n\t\r\n\tvar win = Ti.UI.createWindow();\r\n\tvar btn = Ti.UI.createButton({\r\n\t\ttitle:'open',\r\n\t\tleft:20,\r\n\t\tright:20,\r\n\t\theight:44\r\n\t});\r\n\r\n\tbtn.addEventListener('click', function(){\r\n\t\tWindow2().open();\r\n\t});\r\n\r\n\twin.add(btn);\r\n\tself.open = win.open;\r\n\tself.close = win.close;\r\n\treturn self;\r\n}\r\n\r\nfunction Window2(){\r\n\tvar self = {};\r\n\t\r\n\tvar win = Ti.UI.createWindow({\r\n\t\tbackgroundColor:'green'\r\n\t});\r\n\twin.addEventListener('open', function(){\r\n\t\twin.animate({\r\n\t\t\tleft:10,\r\n\t\t\tduration:300\r\n\t\t}, function(){\r\n\t\t\tTi.API.info('complete');\r\n\t\t});\r\n\t});\r\n\tvar btn = Ti.UI.createButton({title:'close', left:20,right:20,height:44});\r\n\tbtn.addEventListener('click', function(){\r\n\t\twin.close();\r\n\t});\r\n\twin.add(btn);\r\n\t\r\n\tself.open = win.open;\r\n\tself.close = win.close;\r\n\treturn self;\r\n}\r\n\r\nWindow1().open();\r\n{code}\r\n\r\nExpected Result:\r\n\r\nApp should run.\r\n\r\nActual Result:\r\n\r\nRuntime error.\r\n\r\nNote: This test code exists in /titanium_mobile_tests_internal/FeatureTest/Window/Window_timob7246\r\nNote: Will investigate behavior on other devices in future.\r\n", "attachment": [ { "id": "25338", "filename": "android v8 runtime error.txt", "author": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-25T17:23:25.000+0000", "size": 6992, "mimeType": "text/plain" } ], "flagged": false, "summary": "Android: Function variables for Windows methods cannot be successfully invoked.", "creator": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK: 1.8.0.1.v20120119133134, 1.8.1.v20120125154634\r\nAndroid: V8, Rhino (similar error)\r\nStudio: 1.0.8.201201210622\r\nOS: Lion\r\nDevices Tested: Droid 2.2.3, Galaxy Nexus 4.0.2, Nexus One 2.2.2", "comment": { "comments": [ { "id": "181078", "author": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Same test code as TIMOB-7246.", "updateAuthor": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-01-30T11:39:18.000+0000", "updated": "2012-01-30T11:39:18.000+0000" }, { "id": "182477", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "Changed the title and description to reflect underlying problem.", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-02-08T15:38:19.000+0000", "updated": "2012-02-08T15:38:19.000+0000" }, { "id": "182511", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{{self.open = win.open}} (and then calling {{self.open();}} via {{Window1().open();}}) is not really valid Javascript. (I mean, it's syntactically okay, but the hoped-for behavior shouldn't occur.) If it's working in iOS, then it's really kinda just luck, i.e., setting a window's {{open}} method to a variable and having it work successfully must mean that the method itself somehow has a pre-bound context to it due to some kind of plumbing in our iOS implementation.\r\n\r\nThis similar plain-old Javascript code makes the point:\r\n\r\n{code:test.js}\r\nvar o = {\r\n\tx: 5,\r\n\tf: function() {\r\n\t\tconsole.log(\"this.x == \" + this.x);\r\n\t}\r\n};\r\nvar f = o.f;\r\nf();\r\n{code}\r\n\r\nWhen you take {{f}} away from {{o}} it becomes \"this-less\", so to speak. :) So the result is:\r\n\r\n{code}\r\nthis.x == undefined\r\n{code}\r\n\r\nThe same with {{window.open}}... When {{open}} is taken by itself, any code within it (when it is invoked) that tries to manipulate \"its\" window ... its {{this}} ... is going to fail.\r\n\r\nYou can get the test to work by changing those lines that set {{self.open}} and {{self.close}} so they do something like:\r\n\r\n{code:example.js}\r\nself.open = function(){win.open();};\r\n{code}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2012-02-08T17:19:53.000+0000", "updated": "2012-02-08T17:20:29.000+0000" }, { "id": "249774", "author": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing.", "updateAuthor": { "name": "dhyde", "key": "dhyde", "displayName": "Dustin Hyde", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-01T20:06:59.000+0000", "updated": "2013-05-01T20:06:59.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }