[TIMOB-7705] Android: Quickly opening and closing windows eventually causes new window to not close
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | Medium |
| Status | Closed |
| Resolution | Cannot Reproduce |
| Resolution Date | 2013-03-19T12:45:04.000+0000 |
| Affected Version/s | Release 1.8.2 |
| Fix Version/s | Release 3.0.2 |
| Components | Android |
| Labels | n/a |
| Reporter | Marshall Culpepper |
| Assignee | jithinpv |
| Created | 2012-02-17T09:24:57.000+0000 |
| Updated | 2017-03-21T22:15:09.000+0000 |
Description
In the attached test case, if you quickly tap "Open window" and "close window" over and over again, you will eventually see this debug message in the log:
I/TiAPI ( 4250): closing window 2
D/Window ( 4250): unable to close, window is not opened
There isn't an associated stack trace, but it seems the fast open/close is causing the internal state tracking in window.js to be out of sync
Here's the code:
//create window 1.
Ti.API.info("opening window 1");
var win = Ti.UI.createWindow({
backgroundColor: "#fff",
navBarHidden: true,
softInputMode: Ti.UI.Android.SOFT_INPUT_ADJUST_RESIZE,
exitOnClose: true
});
win.open();
var label = Ti.UI.createLabel({ text: "Window 1", width: "auto", height: "auto", top: 10 });
win.add(label);
var openWindow2Button = Ti.UI.createButton({ title: "Open Window 2", height: "auto", width: "auto", bottom: 10 });
openWindow2Button.addEventListener("click", function() {
//create window 2.
Ti.API.info("opening window 2");
var win2 = Ti.UI.createWindow({
backgroundColor: "#fff",
navBarHidden: true,//this causes crash on window 2 close!!
softInputMode: Ti.UI.Android.SOFT_INPUT_ADJUST_RESIZE,
exitOnClose: false
});
win2.open();
var label2 = Ti.UI.createLabel({ text: "Window 2", width: "auto", height: "auto", top: 10 });
win2.add(label2);
var closeWindow2Button = Ti.UI.createButton({ title: "Close Window 2", height: "auto", width: "auto", bottom: 10 });
closeWindow2Button.addEventListener("click", function() {
Ti.API.info("closing window 2");
win2.close();
});
win2.add(closeWindow2Button);
var table = Ti.UI.createTableView({ top: 60, bottom: 60, left: 0, right: 0, data: [] });
win2.add(table);
});
win.add(openWindow2Button);
Issue does not reproduces Tested with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4 jithinpv
I have exactly the same issue, but a simplified test like the following doesn't replicate so the weight of the actually windows being closed must be part of the problem:
var appWindow = Ti.UI.createWindow({ backgroundColor: 'red', exitOnClose: true, modal: false // Force heavyweight }); var mainWindow = Ti.UI.createWindow({ backgroundColor: 'green', modal: false // Force heavyweight }); mainWindow.addEventListener('click', function () { Ti.API.info('Main window tapped, now closing main window'); mainWindow.close(); }); mainWindow.addEventListener('close', function () { Ti.API.info('Main window closed, now closing app window'); appWindow.close(); }); appWindow.addEventListener('open', function () { Ti.API.info('App window opened, now opening main window'); mainWindow.open(); }); appWindow.open();(deleted - not relevant)
Closing ticket as the issue cannot be reproduced and due to the above comments.