Titanium

[TIMOB-1975] Android: Showing JS error dialog (rhino dialog) can FC app if activity has finished

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:57:42.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.5.0
ComponentsAndroid
Labelsandroid, defect
ReporterBill Dawson
AssigneeBill Dawson
Created2011-04-15T03:07:00.000+0000
Updated2011-04-17T01:57:42.000+0000

Description

Attempting to show an error dialog inside the JS (our doRhinoDialog in TiContext) FCs the app if the activity belonging to the context that is attempting to show the dialog has finished.

This can happen, for example, if a user backs out of a heavyweight window while a separate thread (like an XHR callback, which is how we found out about this problem) is running JS in that window's context and comes across an error.

For a failcase, use this app.js and then win.js.

app.js:

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

win.js:

var win = Ti.UI.currentWindow;
win.addEventListener('close', function(){
    Ti.API.info(win.nonsense.nonsense);
});

The FC is this exception:

android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy@45d433c8 is not valid; is your activity running?
at android.view.ViewRoot.setView(ViewRoot.java:509)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
at android.view.Window$LocalWindowManager.addView(Window.java:424)
at android.app.Dialog.show(Dialog.java:241)
at org.appcelerator.titanium.TiContext$1.run(TiContext.java:811)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:

Comments

  1. Bill Dawson 2011-04-15

    (from [480434de05223577f1903689349b567fd8cfccd7]) [#1975 state:fixed-in-qa] Check if activity finished/finishing before attempting to display dialog in it http://github.com/appcelerator/titanium_mobile/commit/480434de05223577f1903689349b567fd8cfccd7"> http://github.com/appcelerator/titanium_mobile/commit/480434de05223...

  2. Thomas Huelbert 2011-04-15

    1.4.2.4ce7ff G1 running 1.6, 2.2 simulator

JSON Source