{ "id": "62374", "key": "TIMOB-1742", "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": "11240", "name": "Release 1.6.0 M07", "archived": true, "released": true, "releaseDate": "2011-01-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:02.000+0000", "created": "2011-04-15T03:01:04.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [ "android", "back", "backbutton", "button", "close", "defect", "event", "eventlistener", "listener", "release-1.6.0", "tabGroup", "tabgroup" ], "versions": [], "issuelinks": [], "assignee": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:57:02.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 similar problem to \"Android: Window Closed with Back\nButton Won't Reopen\" (https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobi...)\nbut this happens if you use TabGroups instead Windows.

\n
    \n
  1. Create two TabGroups with two windows.
  2. \n
  3. Attach a click event listener to the window in first TabGroup.\nThis listener should open the second TabGroup.
  4. \n
  5. Open first TabGroup.
  6. \n
  7. Click on window and activate listener.
  8. \n
  9. Second TabGroup will open.
  10. \n
  11. Click Android back button, this will close second\nTabGroup.
  12. \n
  13. Click on window and activate listener. Nothing happens.
  14. \n
\n

Testcase:

\n
\nTitanium.UI.setBackgroundColor('#000');\n\n// create tab group\nvar tabGroup1 = Titanium.UI.createTabGroup();\nvar tabGroup2 = Titanium.UI.createTabGroup();\n\n// create base UI tab and root window\nvar win1 = Titanium.UI.createWindow({\n    navBarHidden:false,\n    title:'Tab 1',\n    backgroundColor:'#fff'\n});\n\nvar tab1 = Titanium.UI.createTab({\n    icon:'KS_nav_views.png',\n    title:'Tab 1',\n    window:win1\n});\n\nvar label1 = Titanium.UI.createLabel({\n    color:'#999',\n    text:'I am Window 1',\n    font:{\n        fontSize:20,\n        fontFamily:'Helvetica Neue'\n    },\n    textAlign:'center',\n    width:'auto'\n});\n\nwin1.add(label1);\n\n// create controls tab and root window\nvar win2 = Titanium.UI.createWindow({\n    navBarHidden:false,\n    title:'Tab 2',\n    backgroundColor:'#fff'\n});\nvar tab2 = Titanium.UI.createTab({\n    icon:'KS_nav_ui.png',\n    title:'Tab 2',\n    window:win2\n});\n\nvar label2 = Titanium.UI.createLabel({\n    color:'#999',\n    text:'I am Window 2',\n    font:{\n        fontSize:20,\n        fontFamily:'Helvetica Neue'\n    },\n    textAlign:'center',\n    width:'auto'\n});\n\nwin2.add(label2);\n\n//  add tabs\ntabGroup1.addTab(tab1);\ntabGroup1.addTab(tab2);\n\n// open first tab group\ntabGroup1.open();\n\n// create base UI tab and root window\nvar win3 = Titanium.UI.createWindow({\n    navBarHidden:false,\n    title:'Tab 3',\n    backgroundColor:'#fff'\n});\n\nvar tab3 = Titanium.UI.createTab({\n    icon:'KS_nav_views.png',\n    title:'Tab 3',\n    window:win3\n});\n\nvar label3 = Titanium.UI.createLabel({\n    color:'#999',\n    text:'I am Window 3',\n    font:{\n        fontSize:20,\n        fontFamily:'Helvetica Neue'\n    },\n    textAlign:'center',\n    width:'auto'\n});\n\nwin3.add(label3);\n\n// create controls tab and root window\nvar win4 = Titanium.UI.createWindow({\n    navBarHidden:false,\n    title:'Tab 4',\n    backgroundColor:'#fff'\n});\n\nvar tab4 = Titanium.UI.createTab({\n    icon:'KS_nav_ui.png',\n    title:'Tab 4',\n    window:win4\n});\n\nvar label4 = Titanium.UI.createLabel({\n    color:'#999',\n    text:'I am Window 4',\n    font:{\n        fontSize:20,\n        fontFamily:'Helvetica Neue'\n    },\n    textAlign:'center',\n    width:'auto'\n});\n\nwin4.add(label4);\n\n//  add tabs\ntabGroup2.addTab(tab3);\ntabGroup2.addTab(tab4);\n\n// attach click listener\nwin1.addEventListener('click', function(){\n    // this will fire only once\n    Ti.API.debug('fired click listener!');\n    tabGroup2.open();\n});\n
\n

Trace:

\n
\n// first click\n[TRACE] E/TiUIView( 2146): (main) [8045,11705] TAP, TAP, TAP\n[DEBUG] [28,11733] fired click listener!\n[TRACE] I/TabGroupProxy( 2146): (main) [8,11741] handleOpen\n[TRACE] I/ActivityManager( 61): Starting activity: Intent { cmp=com.AndroidBackButton/ti.modules.titanium.ui.TiTabActivity (has extras) }\n[TRACE] D/PhoneWindow( 2146): couldn't save which view has focus because the focused view com.android.internal.policy.impl.PhoneWindow$DecorView@43e92980 has no id.\n[TRACE] W/TiTabActivity( 2146): (main) [104,11845] Notifying TiTabGroup, activity is created\n[TRACE] W/TiActivity( 2146): (main) [198,12043] Notifying TiUIWindow, activity is created\n[TRACE] I/ActivityManager( 61): Displayed activity com.AndroidBackButton/ti.modules.titanium.ui.TiTabActivity: 417 ms (total 417 ms)\n// back button\n[TRACE] W/KeyCharacterMap( 2146): No keyboard for id 0\n[TRACE] W/KeyCharacterMap( 2146): Using default keymap: /system/usr/keychars/qwerty.kcm.bin\n[TRACE] E/TiActivity( 2146): (main) [4082,16125] Layout cleanup.\n// second click\n[TRACE] E/TiUIView( 2146): (main) [2329,18454] TAP, TAP, TAP\n
\n

EDITED:
\nTested with mobilesdk-1.4.1-20100904221103-osx.zip

{html}", "attachment": [ { "id": "18052", "filename": "app.js", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:01:05.000+0000", "size": 3761, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "Android: Window in TabGroup loses event listeners", "creator": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "126523", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

We need to check this with the new Kroll.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:05.000+0000", "updated": "2011-04-15T03:01:05.000+0000" }, { "id": "126524", "author": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Another similar ticket 'Android: event listeners in reopened\nwindow do not fire.' \nhttps://appcelerator.lighthouseapp.com/projects/32238-titanium-mobi...

{html}", "updateAuthor": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:05.000+0000", "updated": "2011-04-15T03:01:05.000+0000" }, { "id": "126525", "author": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I've changed a little bit fail case. I've added a button to the\nfirst window. If you open and close (with back button) the second\ntab group also the button loses its listener.

\n

Tested with newest build:\nmobilesdk-1.4.1-20100909194301-osx.zip

{html}", "updateAuthor": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:05.000+0000", "updated": "2011-04-15T03:01:05.000+0000" }, { "id": "126526", "author": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Is there ANY chance to solve this?

{html}", "updateAuthor": { "name": "lukasz", "key": "lukasz", "displayName": "Lukasz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:06.000+0000", "updated": "2011-04-15T03:01:06.000+0000" }, { "id": "126527", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

We're still working on the kroll rewrite, but we're getting\ncloser to a first pass. We will use this as a test case.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:06.000+0000", "updated": "2011-04-15T03:01:06.000+0000" }, { "id": "126528", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Please verify of still an issue in 1.6. If so talk with me so we\ncan see if it can be fixed in time.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:07.000+0000", "updated": "2011-04-15T03:01:07.000+0000" }, { "id": "126529", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Issue resolved via #2640. The app needs to be modified to use the\n{exitOnClose: false} option when creating the second tab group\notherwise closing the tab would result in the root activity being\nclosed.

\n

I update the test app to call tabGroup1.open() only once and\nalso to set the exitOnClose flag. The issue can be verified by:
\n1) Run attached test app.js
\n2) click button and check log to verify event is fired
\n3) double click on main window of tab 1 to open tab group 2
\n4) hit the back button to close tab group 2 and return to tab group\n1
\n5) click button and check log to verify event will still fire

\n

Thanks
\nOpie

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:01:07.000+0000", "updated": "2011-04-15T03:01:07.000+0000" }, { "id": "126530", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

If I follow the script above it works. If I do what the test\nsays and double-click on the second tab group. It crashes with.

\n
\nD/TiAPI   ( 3296): (kroll$5) [2,71549] win3 fired dblclick listener!\nE/KrollCallback( 3296): (kroll$5) [94,71643] ECMA Error evaluating source, invocation: [callMethod UI.Window.UI.Window:event:dblclick null], message: ReferenceError: \"tabGroup2\" is not defined. (app://app.js#125)\nE/KrollCallback( 3296): org.mozilla.javascript.EcmaError: ReferenceError: \"tabGroup2\" is not defined. (app://app.js#125)\nE/KrollCallback( 3296):     at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3761)\nE/KrollCallback( 3296):     at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3739)\nE/KrollCallback( 3296):     at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3824)\nE/KrollCallback( 3296):     at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1760)\nE/KrollCallback( 3296):     at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1790)\nE/KrollCallback( 3296):     at script(app://app.js:125)\nE/KrollCallback( 3296):     at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\nE/KrollCallback( 3296):     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\nE/KrollCallback( 3296):     at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\nE/KrollCallback( 3296):     at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3161)\nE/KrollCallback( 3296):     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)\nE/KrollCallback( 3296):     at org.appcelerator.titanium.kroll.KrollCallback.callSync(KrollCallback.java:139)\nE/KrollCallback( 3296):     at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:163)\nE/KrollCallback( 3296):     at android.os.Handler.handleCallback(Handler.java:587)\nE/KrollCallback( 3296):     at android.os.Handler.dispatchMessage(Handler.java:92)\nE/KrollCallback( 3296):     at android.os.Looper.loop(Looper.java:123)\nE/KrollCallback( 3296):     at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:73)\nE/TiContext( 3296): (kroll$5) [8,71651] Rhino Error: app://app.js:125,0\nE/TiContext( 3296): (kroll$5) [1,71652]  Message: ReferenceError: \"tabGroup2\" is not defined. (app://app.js#125)\nE/TiContext( 3296): (kroll$5) [0,71652]  Source: null\n
{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:01:07.000+0000", "updated": "2011-04-15T03:01:07.000+0000" }, { "id": "126531", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Fixed test to address error found by Don.

\n

New test attached.

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:01:08.000+0000", "updated": "2011-04-15T03:01:08.000+0000" }, { "id": "126532", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "{html}

Emulator 2.2, ba41eca7d

\n

Verified the updated app.js ...

\n
{html}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-04-15T03:01:08.000+0000", "updated": "2011-04-15T03:01:08.000+0000" } ], "maxResults": 10, "total": 10, "startAt": 0 } } }