Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2280] Facebook: fb.permissions leading to crash inconsistently on iOS

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-08-16T06:45:21.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.0.0
ComponentsFacebook
Labelsn/a
ReporterShuo Liang
AssigneeHans Knöchel
Created2016-08-05T03:16:19.000+0000
Updated2018-08-06T17:49:34.000+0000

Description

Reproduce

1. Run the following code in a simple classic project.
var win = Ti.UI.createWindow({
	backgroundColor: "white",
});

// facebook
var fb = require('facebook');
fb.initialize();
fb.addEventListener('login', function(e) {
    if (e.success) {
        Ti.API.info('login from uid: '+e.uid+', name: '+ JSON.parse(e.data).name);
        checkPermission();
    }
    else if (e.cancelled) {
        alert('cancelled');
    }
    else {
        alert(e.error);
    }
});

// button to tigger facebook authorise and check the permission
var button = Ti.UI.createButton({
	title:"Authorise and check the permission",
	top: 100
});
button.addEventListener('click',function(e){
	if (!fb.loggedIn) {
		console.log("not logged yet.");
		fb.authorize();
	} else {	
		checkPermission();
	}
});
win.add(button);

function checkPermission() {
	if(fb.permissions.indexOf('publish_actions') < 0) {
		Ti.API.info("No publish_action permission");
	} else {
		Ti.API.info("Do have publish_action permission");
	}
}

win.open();
2. Click the button to login/authorise. 3. Then click it again to check permissions.

Problem.

App will cash if you click the button for several times.

Note

No any crash log in console.

Comments

  1. Hans Knöchel 2016-08-05

    Can you add fb.initialize() before using the module instance? Just some troubleshooting.
  2. Hans Knöchel 2016-08-06

    I've put it into this sprint for further investigation. Is there a difference between main-thread enabled and disabled? The issue is definitely threading-related and I guess the problem is that we wait for the permissions [here](https://github.com/appcelerator-modules/ti.facebook/blob/master/ios/Classes/FacebookModule.m#L178) which can produce problems when being used in properties that need to return something immediately. I'll update this ticket as soon as I've tested it.
  3. Hans Knöchel 2016-08-08

    PR: https://github.com/appcelerator-modules/ti.facebook/pull/60 Ok, so here it what the PR does: - The getter was forced to run on the main-thread and wait for the result. That caused major problems, since the return value has not been retained. - I also found out that this was a known issue in the Facebook-SDK, so I updated it to the latest stable available - While I did that, I also found some memory-leaks across the share-dialogs which I fixed - I tested the change with both kroll- and main-thread and did a click-penetration with 20+ clicks and no crash (before: crash after 2-3 times visible) - Finally bumped the version of ti.facebook to 1.2.3
  4. Hans Knöchel 2016-08-10

    Pre-release: https://github.com/appcelerator-modules/ti.facebook/releases/tag/ios-5.2.3
  5. Chee Kiat Ng 2016-08-16

    [~hansknoechel] PR merged. Proceed to have the packaged Facebook module PR into titanium_mobile please.
  6. Hans Knöchel 2016-08-16

    PR (titanium_mobile/master): https://github.com/appcelerator/titanium_mobile/pull/8234 New ti.facebook iOS version 5.2.3 released.
  7. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source