Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15258] iOS: Facebook module throws "FBSession: should only be used from a single thread" error on reviving app with Facebook request URL

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2016-08-27T12:43:57.000+0000
Affected Version/sn/a
Fix Version/sBacklog
ComponentsiOS
Labelsfacebook, ios, mobilesdk
ReporterVladimir Tolstikov
AssigneeEric Merriman
Created2013-09-10T10:13:33.000+0000
Updated2017-03-27T17:53:09.000+0000

Description

Test case:

login into Facebook using your Titanium's app

kill it from Dock

try to open app with Facebook user-to-user request URL from your notifications section in Facebook or newsfeed story. It should be something like fb116843021780929://authorize?...

"FBSession: should only be used from a single thread" red screen appears

XCode console on a device says:
Sep 10 12:40:08 iPhone Printpie[31305] <Warning>: *** Assertion failure in -[FBSession handleOpenURL:], /Volumes/Datums/CodeValhalla/Github/Mine/titanium_modules/facebook/mobile/ios/Classes/FBConnect/FBSession.m:426
Sep 10 12:40:08 iPhone Printpie[31305] <Warning>: [ERROR] Script Error FBSession: should only be used from a single thread
Test application code is simple as a child's tear:
var fb = require('facebook');
fb.appid = '116843021780929';

var win = Ti.UI.createWindow();

var loginButton = Ti.UI.createButton({
    title: 'Login'
});
loginButton.addEventListener('click', function(){fb.authorize();});
win.add(loginButton);

win.open();
Don't forget to add into your Info.plist next string for Facebook URL chema support:
	<key>CFBundleURLTypes</key>
	<array>
		<dict>
			<key>CFBundleURLName</key>
			<string>com.printpie.cleverbug</string>
			<key>CFBundleURLSchemes</key>
			<array>
				<string>printpie</string>
				<string>fb116843021780929</string>
			</array>
		</dict>
	</array>
So:

run the app

click "Login" button

login into your Fb account

you will be bring back to the app

close simulator

open simulator stand-alone, without titanium

try next URL (it's similar as from Facebook native app or Safari's web-version of FB):

fb116843021780929://authorize?expires_in=3600&access_token=qkjKR42UQsewYckYagPhU2Avo4eLruAKH41Vd1u192UORNvhzGftEUi7sOK375opZCKzpK1ZCAyxkBH5je3BUG3E8Shp6mI8VmdXWU2dxrOe4oB7BoDPSAZDZD&target_url=http%3A%2F%2Fm.facebook.com%2Fapps%2Fcleverbug-printpie%3Ffb_source%3Dnotification%26request_ids%3D511072445602499%26ref%3Dnotif%26app_request_type%3Duser_to_user

you will see "FBSession: should only be used from a single thread"

I saw many similar questions on Q&A section with no answers :( P.S. sorry, no time to make a bundle with test application, but I hope I explained it above.

Attachments

FileDateSize
screenshot_2013-09-10_14.10.26.png2013-09-10T10:13:33.000+000040052

Comments

  1. Vladimir Tolstikov 2013-09-10

    Probably I know why it happens: old Ti.Facebook module still in SDK, and not requires initialization (with "require(..") right? Maybe that is a first thread which is capturing and handle openURL param.
  2. Hans Knöchel 2016-08-27

    This should not happen with Ti.Facebook 5.0.0 and later (e.g. 5.2.3 currently). Resolving for now, please leave your comments if you still see it.
  3. Lee Morris 2017-03-27

    Closing ticket as fixed with reference to the above comments.

JSON Source