{ "id": "62406", "key": "TIMOB-1774", "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": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:08.000+0000", "created": "2011-04-15T03:01:55.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "defect" ], "versions": [], "issuelinks": [], "assignee": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2011-04-17T01:57:08.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}

This is a bit of a complex one and hard to test from a QE\nperspective.

\n

Because our memory cleanup (and the releasing / garbage\ncollecting of objects) has improved, we actually have a weird\nsituation where if you re-open an existing window (meaning, call\n.open on an existing window proxy) that had previously\nbeen closed, the activity attached to its context might be null\n(garbage collected). The .open() process creates our\nwindow view instance, which in turn creates an Android intent to\nopen a new activity. The code to create the intent is in the\nTiUIWindow constructor:

\n
\nif (newActivity){\n  lightWeight = false;\n  Activity activity = proxy.getTiContext().getActivity();\n  Intent intent = createIntent(activity, options);\n
\n

The problem is that the getActivity() you see there\nmight be null, because the proxy's context -- from the previous\ntime the window was closed -- has been released and its activity\ncleaned up.

\n

During the creation of a window, the proxy's context is actually\nswitched from the context it was created in to the context that it\ncreates -- and that's the context that gets cleaned up when it's\nclosed.

\n

The fix for this is: when the window is closed, switch its\ncontext back to its creating context (from which it was switched\naway when it created its own context the last time it was\nopened.)

{html}", "attachment": [], "flagged": false, "summary": "Android: Reopening a window sometimes fails with runtime error", "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": "126624", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

By the way, you can get away with this error not happening --\nit's just that if a garbage collection occurs and wipes out that\nold activity, then it will happen when the window is reopened.\nUsing DDMS I can force a garbage collection and get the problem to\noccur everytime.

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

Relevant commit, for which , as so often, i screwed up the\ncomment so it didn't get here automatically:

\n

\nhttp://github.com/appcelerator/titanium_mobile/commit/6c2b0d450f4a8...

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

Thomas,

\n

This might be tough one to test. You need a tool like DDMS to\nforce a garbage collection. In case you want to try, here's a fail\ncase consisting of three files:

\n

app.js:

\n
\nvar win = \nTitanium.UI.createWindow({  \n    title:'Test Anything',\n    backgroundColor:'#fff',\n    url: 'w1.js',\n    fullscreen:true,\n    exitOnClose: true\n    \n});\nwin.open();\n
\n

w1.js:

\n
\nvar win = Ti.UI.currentWindow;\nvar win2;\n\nvar btn = Ti.UI.createButton({\n    title: 'open subwindow'\n});\nbtn.addEventListener('click', function(){win2.open();});\nwin.add(btn);\n\nwin2 = Ti.UI.createWindow({\n    url: 'w2.js', backgroundColor:'green', fullscreen: true\n});\n
\n

w2.js:

\n
\nvar win = Ti.UI.currentWindow;\n\nvar lbl = Ti.UI.createLabel({color: 'black',text: 'Hit back button to go back'});\nwin.add(lbl);\n
\n

Then follow these steps:

\n\n

To test the fail case, you need a version prior to the above\ncommit (obviously :) ) but still very recent, like in the last two\ndays.

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

closing, 1.6 g1 device, 2.2 simulator. Thanks for the debug flag\ninfo for device, as well as the test case.

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:56.000+0000", "updated": "2011-04-15T03:01:56.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }