{ "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.
\nBecause 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:
\nif (newActivity){\n lightWeight = false;\n Activity activity = proxy.getTiContext().getActivity();\n Intent intent = createIntent(activity, options);
\n
\nThe 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.
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.
\nThe 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.)
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.
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...
Thomas,
\nThis 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:
\napp.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
\nw1.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
\nw2.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
\nThen follow these steps:
\nTo test the fail case, you need a version prior to the above\ncommit (obviously :) ) but still very recent, like in the last two\ndays.
closing, 1.6 g1 device, 2.2 simulator. Thanks for the debug flag\ninfo for device, as well as the test case.