Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2962] Android: Facebook module events stop firing on heavyweight windows

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T02:00:33.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.6.0 M07
ComponentsAndroid
Labelsandroid, defect, facebook, release-1.5.2, release-1.6.0, reported-1.5.2
ReporterBill Dawson
AssigneeBill Dawson
Created2011-04-15T03:33:48.000+0000
Updated2011-04-17T02:00:33.000+0000

Description

This concerns our facebook "custom" module, not the module that is in titanium_mobile core. If you use the module in a heavyweight window, then back out of that window and open it again, you won't get any of the module's events starting with that second invocation and all following invocations.

To re-create the failcase, create a new project and make the tiapp.xml's "modules" section look like this:

 <modules>
        <module version="0.1">ti.facebook</module>
    </modules>

Next, put the attached ZIP file into the project's root folder.

Next, make app.js look like this:

Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({  
    title:'Test',
    backgroundColor:'#fff',
    exitOnClose: true
});

var btn = Ti.UI.createButton({
    title: 'Open heavy window'
});
btn.addEventListener('click', function() {
    Ti.UI.createWindow({
        url: 'win.js',
        backgroundColor: 'black',
        fullscreen: false
    }).open();
});
win.add(btn);
win.open();

And a file, win.js, looking like this:

var win = Ti.UI.currentWindow;
var APPID = "134793934930";
var FB = require("ti.facebook");
FB.appid = APPID;
FB.permissions = ['publish_stream', 'create_event'];

var login = FB.createLoginButton({
    top: 10, style:'wide'
});
win.add(login);

function loginListener() {
    Ti.API.info('LOGIN LISTENER');
}

FB.addEventListener('login', loginListener);

win.addEventListener('close', function() {
    FB.removeEventListener('login', loginListener);
});

var close = Ti.UI.createButton({
    title: 'Close',
    bottom: 5, height: 40, left: 20, right: 20
});
close.addEventListener('click', function() {win.close();});
win.add(close);

Run the project, and follow these steps:

  • Click "Open heavy window"
  • Click "Connect with Facebook"
  • When the Facebook login dialog comes up, just click the "Cancel" button (this fires the login event even though you're canceling).
  • Look at the console, you'll see the info message "LOGIN LISTENER" -- that's good, it means the login event listener in win.js fired.
  • Now back out of this window.
  • When back at the first window, click "Open heavy window" again.
  • Click "Connect with Facebook" again.
  • When the Facebook login dialog shows, again just click "Cancel".
  • Look at the console: no new info message will appear. that's bad.

Attachments

FileDateSize
tifacebook-android-01.zip2011-04-15T03:33:48.000+000078617

Comments

  1. Bill Dawson 2011-04-15

    (from [d1a99ef2944f56117511cd1cb450acc5feff18a4]) [#2962 state:fixed-in-qa] Custom modules -- those brought into being with require() -- are now created instantiated with root activity's context https://github.com/appcelerator/titanium_mobile/commit/d1a99ef2944f56117511cd1cb450acc5feff18a4"> https://github.com/appcelerator/titanium_mobile/commit/d1a99ef2944f...

  2. Bill Dawson 2011-04-15

    (from [17baaed6047e515dabe0f238b6d5f5287b30c276]) [#2962 state:fixed-in-qa] Custom modules -- those brought into being with require() -- are now created instantiated with root activity's context https://github.com/appcelerator/titanium_mobile/commit/17baaed6047e515dabe0f238b6d5f5287b30c276"> https://github.com/appcelerator/titanium_mobile/commit/17baaed6047e...

  3. Opie Cyrus 2011-04-15

    Verified with emulator 2.2.

    Login listener fired again when canceling connect prompt the second time.

JSON Source