Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6372] Android: Back button not closing windows in CommonJS modules

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionCannot Reproduce
Resolution Date2011-12-05T13:00:52.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
Labelsbranch-v8, dr-list
ReporterMatthew Apperson
AssigneeAllen Yeung
Created2011-11-29T19:29:13.000+0000
Updated2012-01-11T13:32:57.000+0000

Description

Description: On android app builds and runs correctly, but after the first click, the app ceases to respond to further clicks. This does not occur on Win 7 or Linux 10.04. Steps to reproduce: 1) Create a new mobile project and replace contents of resources dir with contents of attached zip 2) Launch in android emulator 3) Click the button 4) Click "back" hardware button 5) Click the button again Result: App does nothing with further clicks of the button Expected: Each button click opens the second window Note: If you add an event listener like so:
detailContainerWindow.addEventListener('android:back', function(e) {
    detailContainerWindow.close();
});
The code works as expected

Attachments

FileDateSize
Resources 2.zip2011-11-29T19:29:13.000+0000739177

Comments

  1. Matthew Apperson 2011-12-05

    Issue already resolved due to a fix in an unknown ticket
  2. Ivan Skugor 2011-12-09

    Hello. It seems that this issue still exists and is not directly connected to CommonJS. The problem seem to exist when heavyweight window is created and "android:back" event listener is attached to it. Here is my test case:
       var win = Ti.UI.createWindow({
       	fullscreen: true,
       	backgroundColor: '#f00'
       });
       
       var button = Ti.UI.createButton({
       	title: 'Click me!'
       });
       
       button.addEventListener('click', function() {
       	var newWin = Ti.UI.createWindow({
       		modal: true,
       		backgroundColor: '#0f0'
       	});
       	
       	newWin.addEventListener('android:back', function() {
       		Ti.API.debug(typeof newWin.close);
       		Ti.API.debug(typeof this.close);
                       Ti.API.debug(this);
       	});
       	
       	newWin.open();
       });
       
       win.add(button);
       
       win.open();
       
    Environment on which I'm testing on: * Titanium SDK version: 1.8.0.1 (12/08/11 23:42 00e9d8f...) * Android 3.1 (Thinkpad tablet) * Windows XP * Titanium Studio, build: 1.0.7.201112080131 To see the issue, you need to run this example, click on button and then press hardware back-button. You should see that green window didn't close. Furthermore, in DDMS output you should see: undefined function [object global] That is second issue that I noticed, "this" inside window's event handler is wrongly set to global object instead of window object. Hope this clears this issue. If you have questions, please let me know. Cheers.
  3. Ivan Skugor 2011-12-09

    Further investigation has shown that there exists one more issue - window "close" event is being fired twice. Modified test case looks like this:
       var win = Ti.UI.createWindow({
       	fullscreen: true,
       	backgroundColor: '#f00'
       });
       
       var button = Ti.UI.createButton({
       	title: 'Click me!'
       });
       
       button.addEventListener('click', function() {
       
       	var newWin = Ti.UI.createWindow({
       		modal: true,
       		backgroundColor: '#0f0'
       	});
       	
       	var newButton = Ti.UI.createButton({
       		title: 'Close me!'
       	});
       	
       	newButton.addEventListener('click', function() {
       		newWin.close();
       	});
       	
       	newWin.addEventListener('close', function() {
       		Ti.API.info('Close event');
       		Ti.API.debug(this);
       	});
       	
       	newWin.add(newButton);
       	
       	newWin.open();
       });
       
       win.add(button);
       
       win.open();
       
    The output in DDMS: Close event [object global] Close event [object TiBaseWindow] So, as you can see, "close" event is fired twice and in first case "this" is set to incorrect value. Also, if following line is added to window's "close" event handler:
       Ti.API.debug(this.close);
       
    internal Titanium workings are revealed, which shouldn't be desirable. Cheers.
  4. Wilson Luu 2012-01-10

  5. Wilson Luu 2012-01-11

JSON Source