Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-630] Android: TabGroup stops window being re-shown

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2018-08-02T17:06:41.000+0000
Affected Version/sRelease 1.7.2, Release 2.0.1, Release 3.0.0, Release 3.2.0
Fix Version/sn/a
ComponentsAndroid
Labelsexalture
ReporterJon Alter
AssigneeIngo Muschenetz
Created2011-04-15T02:33:13.000+0000
Updated2018-08-02T17:08:41.000+0000

Description

start with a standalone window that fires an event, a listener in app.js then closes the window and opens a tabgroup (think logon window) - all good. the tabgroup fires an event which is listened to in app.js which closes the tabgroup and opens the initial window. This fails - the tabgroup goes away, logging shows the original window is being re-built, but it is never shown. It is shown in iPhone. Pseudo code for app.js...
var loginWin;
var logoutGroup;

function makeLoginWindow() {
   loginWin = window with single button firing LOGIN event;
   loginWin.open();
}

function makeLogoutWindow() {
   logoutGroup = tabGroup containing one window with...

   single button firing LOGOUT event;

   logoutGroup.close();
}

makeLoginWindow()
addEventListener(LOGIN) {
  loginWin.close();
  makeLogoutWindow();
}

addEventListener(LOGOUT) {
  logoutGroup.close();
  makeLoginWindow();
}
* Should this work? * Should I raise this sort of thing as a query or ask in the forums in future?

Attachments

FileDateSize
testi.zip2011-04-15T02:33:14.000+00001396

Comments

  1. hal 2011-04-15

    I can confirm that this issue still exists on android, using latest builds of both 1.4.X and 1.5 master dated 6th Nov 2010, tested via the android emulator on ubuntu.

    There is another ticket describing this, or a very similar, issue at https://appcelerator.lighthouseapp.com/projects/32238-titanium-mobile/tickets/2015">#2015. Hence, maybe this ticket can be closed as a duplicate.

  2. hal 2011-04-15

    Deleted by poster
  3. Jon Alter 2011-08-02

    When the tabGroup closes, the windows loose their event listeners. Step 1: run the code below Step 2: click the login button Step 3: click the logout button Step 4: click the login button again (notice that it does not work this time because the eventListener has gone missing)
       var master  = Titanium.UI.createWindow({  
           title:'main',
           fullscreen : false,
           backgroundColor:'#fff'
       });
       
       var mButton = Titanium.UI.createButton({
       	title:'Login',
       	height:50,
       	width:200
       });
       
       mButton.addEventListener('click',function() {
       	master.close();
       	tabGroup.open();
       });
       master.add(mButton);
       
       var tabGroup = Titanium.UI.createTabGroup();
       var win1 = Titanium.UI.createWindow({  
           title:'Tab 1',
           backgroundColor:'#fff'
       });
       var tab1 = Titanium.UI.createTab({  
           icon:'KS_nav_views.png',
           title:'Tab 1',
           window:win1
       });
       var tButton = Titanium.UI.createButton({
       	title:'Log off',
       	height:50,
       	width:200
       });
       win1.add(tButton);
       tabGroup.addTab(tab1);
       
       tButton.addEventListener('click', function() {
       	tabGroup.close();
       	master.open();
       });
       
       master.open();
       

    Tested with

    TiSDK 1.7.2 Android Emulator 2.2

    Associated Helpdesk Ticket

    http://appc.me/c/APP-448628
  4. Dan Tamas 2011-08-30

    @Jon, could you please provide me an working example of the workaround. I don't seem to manage to make it work. And it's pretty urgent :( Thank you.
  5. Jon Alter 2011-09-06

    After more testing, the workaround is not reliable. I am removing it from the ticket.
  6. Art Sosa 2012-02-25

    FYI. bug is still present within 1.8.1 Android. Works as expected in iOS 1.8.1.
  7. Junaid Younus 2012-05-14

    Tried it with 2.0.1GA2 on a Samsung Galaxy S2 (2.3.6) and the issue still exists. If you keep pressing login/logout, the app will eventually crash. Works fine on the iOS simulator.
  8. Federico Casali 2012-05-16

    Not able to reproduce the bug anymore on 2.1 latest CI build. Marking as closed.
  9. Junaid Younus 2012-08-13

    Tested the code with a Samsung Galaxy S3, TiSDK 2.2.0v20120810194112, TiStudio 2.1.1.201207271312 and the app crashes when I press the 'log out' button. This is the ddms output:
       08-13 10:26:21.752: E/TiApplication(4610): (main) [1673,1673] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 2.2.0,2012/08/10 19:41,61078b0
       08-13 10:26:21.752: E/TiApplication(4610): java.lang.NullPointerException
       08-13 10:26:21.752: E/TiApplication(4610): 	at android.content.ComponentName.<init>(ComponentName.java:75)
       08-13 10:26:21.752: E/TiApplication(4610): 	at android.content.Intent.<init>(Intent.java:3219)
       08-13 10:26:21.752: E/TiApplication(4610): 	at ti.modules.titanium.ui.TiUIActivityWindow.createIntent(TiUIActivityWindow.java:558)
       08-13 10:26:21.752: E/TiApplication(4610): 	at ti.modules.titanium.ui.TiUIActivityWindow.createNewActivity(TiUIActivityWindow.java:112)
       08-13 10:26:21.752: E/TiApplication(4610): 	at ti.modules.titanium.ui.TiUIActivityWindow.<init>(TiUIActivityWindow.java:81)
       08-13 10:26:21.752: E/TiApplication(4610): 	at ti.modules.titanium.ui.ActivityWindowProxy.handleOpen(ActivityWindowProxy.java:110)
       08-13 10:26:21.752: E/TiApplication(4610): 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:96)
       08-13 10:26:21.752: E/TiApplication(4610): 	at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:91)
       08-13 10:26:21.752: E/TiApplication(4610): 	at android.os.Handler.dispatchMessage(Handler.java:95)
       08-13 10:26:21.752: E/TiApplication(4610): 	at android.os.Looper.loop(Looper.java:137)
       08-13 10:26:21.752: E/TiApplication(4610): 	at android.app.ActivityThread.main(ActivityThread.java:4514)
       08-13 10:26:21.752: E/TiApplication(4610): 	at java.lang.reflect.Method.invokeNative(Native Method)
       08-13 10:26:21.752: E/TiApplication(4610): 	at java.lang.reflect.Method.invoke(Method.java:511)
       08-13 10:26:21.752: E/TiApplication(4610): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
       08-13 10:26:21.752: E/TiApplication(4610): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
       08-13 10:26:21.752: E/TiApplication(4610): 	at dalvik.system.NativeStart.main(Native Method)
       08-13 10:26:21.752: D/MenuAppsGridFragment(884): onResume
       08-13 10:26:21.752: W/InputManagerService(532): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@42a88168 (uid=10138 pid=4610)
       08-13 10:26:21.762: E/MP-Decision(1291): UP Ld:34 Nw:1.990000 Tw:140 rq:2.900000 seq:145.000000
       08-13 10:26:21.762: W/SurfaceFlinger(224): id=99(19) createSurface 0xa3504c (720x1280),1 flag=0
       08-13 10:26:21.762: D/KeyguardViewMediator(532): setHidden false
       08-13 10:26:21.762: D/STATUSBAR-StatusBarManagerService(532): setSystemUiVisibility(0x0)
       08-13 10:26:21.762: D/STATUSBAR-StatusBarManagerService(532): manageDisableList what=0x0 pkg=WindowManager.LayoutParams
       08-13 10:26:21.772: I/Adreno200-EGLSUB(884): <ConfigWindowMatch:2078>: Format RGBA_8888.
       08-13 10:26:21.772: D/memalloc(224): ion: Allocated buffer base:0x4399a000 size:3768320 fd:38
       08-13 10:26:21.772: D/memalloc(884): ion: Mapped buffer base:0x5f496000 size:3768320 offset:0 fd:60
       08-13 10:26:21.782: I/ClipboardServiceEx(532): Send intent for dismiss clipboard dialog inside hideCurrentInputLocked() !
       08-13 10:26:21.812: E/AndroidRuntime(4610): FATAL EXCEPTION: main
       08-13 10:26:21.812: E/AndroidRuntime(4610): java.lang.NullPointerException
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at android.content.ComponentName.<init>(ComponentName.java:75)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at android.content.Intent.<init>(Intent.java:3219)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at ti.modules.titanium.ui.TiUIActivityWindow.createIntent(TiUIActivityWindow.java:558)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at ti.modules.titanium.ui.TiUIActivityWindow.createNewActivity(TiUIActivityWindow.java:112)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at ti.modules.titanium.ui.TiUIActivityWindow.<init>(TiUIActivityWindow.java:81)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at ti.modules.titanium.ui.ActivityWindowProxy.handleOpen(ActivityWindowProxy.java:110)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:96)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at ti.modules.titanium.ui.ActivityWindowProxy.handleMessage(ActivityWindowProxy.java:91)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at android.os.Handler.dispatchMessage(Handler.java:95)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at android.os.Looper.loop(Looper.java:137)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at android.app.ActivityThread.main(ActivityThread.java:4514)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at java.lang.reflect.Method.invokeNative(Native Method)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at java.lang.reflect.Method.invoke(Method.java:511)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:980)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:747)
       08-13 10:26:21.812: E/AndroidRuntime(4610): 	at dalvik.system.NativeStart.main(Native Method)
       
  10. Sunila 2014-09-24

    With heavyweight windows, each window (or TabGroup) corresponds to an activity and to launch an activity, current activity is needed. Closing the current window before opening the new window makes the current activity inaccessible and hence the crash. I think changing the order by opening the new window and closing the old one will work. Something like tabGroup.open(); master.close();
  11. Eric Merriman 2018-08-02

    Cleaning up old tickets. If this is still requested, please reopen.

JSON Source