Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7024] Android: ActivityIndicator on window focus event crash

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-07-04T05:01:03.000+0000
Affected Version/sRelease 1.8.0.1, Release 2.0.0, Release 2.0.1
Fix Version/sRelease 2.1.0, Sprint 2012-12 API
ComponentsAndroid
Labelsapi, module_activityindicator, qe-testadded
ReporterRadamantis Torres-Lechuga
AssigneeJosh Roesslein
Created2012-01-06T17:01:22.000+0000
Updated2012-08-28T20:32:05.000+0000

Description

Expected behavior

The window opens , push the button to open another window, push the hardware back android button, we need to be able to do this so many times without problems.

Actual behavior

The window opens, push the button to open another window, push the hardware back android button, wait 2 seconds, an error alert goes up

Test Case

var win1 = Ti.UI.createWindow({
	fullscreen : false
});

win1.add(Ti.UI.createLabel({
	top : '0dp',
	text : 'Win1'
}));

win2Button = Ti.UI.createButton({
	title : 'Open Win2'
});

win2Button.addEventListener('click', function(){
	var win2 = Ti.UI.createWindow({
		fullscreen : false
	});
	win2.add(Ti.UI.createLabel({
		top : '0dp',
		text : 'Win2'
	}));
	
	var win2BackButton = Ti.UI.createButton({
		title : 'Go Back'
	});
	
	win2BackButton.addEventListener('click', function(){
		win2.close();
	});
	
	win2.add(win2BackButton);
	
	win2.open();
});

win1.add(win2Button);



win1.addEventListener('focus', function(){
	
	var actInd = Ti.UI.createActivityIndicator({
		bottom : 10,
		height : 50,
		width : 10,
		message : 'Loading...'
	});
	
	actInd.show();
	
	setTimeout(function(){
		actInd.hide();
	}, 2000);
	
});


win1.open();

Log

D/AndroidRuntime(  724): Shutting down VM
W/dalvikvm(  724): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/TiApplication(  724): (main) [1675,11364] Sending event: exception on thread: main msg:java.lang.IllegalArgumentException: View not attached to window manager; Titanium 1.8.0.1,2011/12/17 19:53,c903964
E/TiApplication(  724): java.lang.IllegalArgumentException: View not attached to window manager
E/TiApplication(  724): 	at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355)
E/TiApplication(  724): 	at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200)
E/TiApplication(  724): 	at android.view.Window$LocalWindowManager.removeView(Window.java:432)
E/TiApplication(  724): 	at android.app.Dialog.dismissDialog(Dialog.java:278)
E/TiApplication(  724): 	at android.app.Dialog.access$000(Dialog.java:71)
E/TiApplication(  724): 	at android.app.Dialog$1.run(Dialog.java:111)
E/TiApplication(  724): 	at android.app.Dialog.dismiss(Dialog.java:268)
E/TiApplication(  724): 	at ti.modules.titanium.ui.widget.TiUIActivityIndicator.handleHide(TiUIActivityIndicator.java:217)
E/TiApplication(  724): 	at ti.modules.titanium.ui.widget.TiUIActivityIndicator.handleMessage(TiUIActivityIndicator.java:77)
E/TiApplication(  724): 	at android.os.Handler.dispatchMessage(Handler.java:95)
E/TiApplication(  724): 	at android.os.Looper.loop(Looper.java:130)
E/TiApplication(  724): 	at android.app.ActivityThread.main(ActivityThread.java:3683)
E/TiApplication(  724): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication(  724): 	at java.lang.reflect.Method.invoke(Method.java:507)
E/TiApplication(  724): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/TiApplication(  724): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/TiApplication(  724): 	at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(  724): FATAL EXCEPTION: main
E/AndroidRuntime(  724): java.lang.IllegalArgumentException: View not attached to window manager
E/AndroidRuntime(  724): 	at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:355)
E/AndroidRuntime(  724): 	at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:200)
E/AndroidRuntime(  724): 	at android.view.Window$LocalWindowManager.removeView(Window.java:432)
E/AndroidRuntime(  724): 	at android.app.Dialog.dismissDialog(Dialog.java:278)
E/AndroidRuntime(  724): 	at android.app.Dialog.access$000(Dialog.java:71)
E/AndroidRuntime(  724): 	at android.app.Dialog$1.run(Dialog.java:111)
E/AndroidRuntime(  724): 	at android.app.Dialog.dismiss(Dialog.java:268)
E/AndroidRuntime(  724): 	at ti.modules.titanium.ui.widget.TiUIActivityIndicator.handleHide(TiUIActivityIndicator.java:217)
E/AndroidRuntime(  724): 	at ti.modules.titanium.ui.widget.TiUIActivityIndicator.handleMessage(TiUIActivityIndicator.java:77)
E/AndroidRuntime(  724): 	at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(  724): 	at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(  724): 	at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(  724): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  724): 	at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(  724): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(  724): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(  724): 	at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(   64):   Force finishing activity com.appcelerator.app562821/org.appcelerator.titanium.TiActivity
D/dalvikvm(  724): GC_CONCURRENT freed 254K, 47% free 3104K/5831K, external 1497K/1828K, paused 5ms+4ms
W/ActivityManager(   64): Activity pause timeout for HistoryRecord{40753b30 com.appcelerator.app562821/org.appcelerator.titanium.TiActivity}

Comments

  1. Frank Apap 2012-02-08

    Having a similar issue, or at least getting the same stack trace in the crash log on the android dev console.
  2. Gale Shafer 2012-03-07

    Can Verify that this is still an issue in SDK 2.0.0.v20120306123149
  3. Ryan Marr 2012-03-07

    I have implemented a work around to this issue for now. Add an event listener to your window for the "android:back" event that will close the window.
  4. Gale Shafer 2012-03-07

    Ryan, I'm glad you found a temporary work around and appreciate the suggestion; however, the specified workaround only applies to scenarios caused by the back button. This issue happens if focus is purposely shifted to a different window, via another source other than the back button, while an activity indicator is in use.
  5. Ivan Skugor 2012-03-08

    This might be related to this: https://gist.github.com/1986524
  6. Junaid Younus 2012-05-17

    Tested with 2.0.1GA2 on a Samsung Galaxy S2, issue still exists.
  7. Josh Roesslein 2012-06-05

    Submitted [PR #2324](https://github.com/appcelerator/titanium_mobile/pull/2324) to resolve this issue. Once fix is applied I can no longer reproduce any crashes when returning to the first window. Activity indicator shows and goes away after 2 seconds w/o any crash. Was never able to reproduce the stack trace on this ticket on master, but did run into null pointer and timing issues with activity switching.
  8. Tamila Smolich 2012-06-23

    Closing as fixed. Verified with: Titanium Studio, build: 2.1.0.201206221045 Titanium SDK: 2.1.0.v20120622174154 Devices: Samsung Galaxy tab (3.2) and Android simulator
  9. Neha Chhabra 2012-07-04

    Reopening to update labels.

JSON Source