{ "id": "62609", "key": "TIMOB-1977", "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:43.000+0000", "created": "2011-04-15T03:07:03.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:43.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}

If you back out of a window while a separate thread (such as a\ncallback from an XHR, which is how we discovered this problem) is\nmaking use of proxy objects (view proxies and such) on that window,\nyou can cause an FC. The FC can occur at multiple places in code,\noften in the form of a NullPointerException when\ntrying to access something that doesn't exist anymore because the\nwindow's context and activity have been released. Here's a sample\nFC:

\n
\nE/TiUncaughtHandler(  231): java.lang.NullPointerException\nE/TiUncaughtHandler(  231):     at ti.modules.titanium.ui.TableViewProxy.rowProxyFor(TableViewProxy.java:400)\nE/TiUncaughtHandler(  231):     at ti.modules.titanium.ui.TableViewProxy.handleInsertRowBefore(TableViewProxy.java:240)\nE/TiUncaughtHandler(  231):     at ti.modules.titanium.ui.TableViewProxy.handleMessage(TableViewProxy.java:466)\nE/TiUncaughtHandler(  231):     at android.os.Handler.dispatchMessage(Handler.java:95)\nE/TiUncaughtHandler(  231):     at android.os.Looper.loop(Looper.java:123)\nE/TiUncaughtHandler(  231):     at android.app.ActivityThread.main(ActivityThread.java:4203)\nE/TiUncaughtHandler(  231):     at java.lang.reflect.Method.invokeNative(Native Method)\nE/TiUncaughtHandler(  231):     at java.lang.reflect.Method.invoke(Method.java:521)\n
\n

You can cause an FC using this app.js + win.js + table.js:

\n

app.js:

\n
\nTitanium.UI.setBackgroundColor('#000');\nTitanium.UI.createWindow({  \n    title:'Test',\n    backgroundColor:'#fff',\n    fullscreen: true,\n    exitOnClose: true,\n    url: 'win.js'\n}).open();\n
\n

win.js:

\n
\nvar win = Ti.UI.currentWindow;\nvar btn = Ti.UI.createButton({\n    title: 'Open 2nd Window'\n});\nbtn.addEventListener('click', function(){\n    Ti.UI.createWindow( {\n        fullscreen:true,\n        url: 'table.js',\n        backgroundColor: 'black'\n    }).open();\n});\nwin.add(btn);\n
\n

table.js:

\n
\nvar win = Ti.UI.currentWindow;\nvar tv = Ti.UI.createTableView();\ntv.setData( [ Ti.UI.createTableViewRow({ title: 'Loading...' }) ] );\nwin.add(tv);\n\n// Now start a second thread that will update the table\nsetTimeout(function() {\n    for (var i = 1; i <= 1000; i++) {\n        tv.insertRowBefore(0, \n            Ti.UI.createTableViewRow( {title: 'New row ' + i} ));\n    }\n}, 50);\n
\n

When you run it and you open the second window, click your\nhardware back button while the table is being assembled. After you\nget back to the first window, just wait a while and it'll\ncrash.

{html}", "attachment": [], "flagged": false, "summary": "Android: Backing out of window with other thread using proxies can cause FC", "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": "127139", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

(from [763b1ded2db7f71fac628db4261770f292f9d283])\n[#1977 state:fixed-in-qa] Avoid NPEs in several\nlocations when an activity and context have been released but code\non some thread (like an XHR callback) is still trying to work with\nthem. \nhttp://github.com/appcelerator/titanium_mobile/commit/763b1ded2db7f...

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

thanks for the test case, 1.4.2.4ce7ff G1 running 1.6, 2.2\nsimulator.

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