Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-15258

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Backlog
    • Component/s: iOS
    • Environment:

      MacOS X 10.8.4
      Titanium CLI version 3.1.2, Titanium SDK version 3.1.2.GA
      iOS SDK: 6.1 and 7.0
      Xcode 4.6.3 and 5-DP6
      Titanium's Facebook module 3.1.1

    • Story Points:
      1
    • Sprint:
      2016 Sprint 17 SDK

      Description

      Test case:

      1. login into Facebook using your Titanium's app
      2. kill it from Dock
      3. 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?...
      4. "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:

      1. run the app
      2. click "Login" button
      3. login into your Fb account
      4. you will be bring back to the app
      5. close simulator
      6. open simulator stand-alone, without titanium
      7. 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
        

      8. 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

          Activity

            People

            • Assignee:
              emerriman Eric Merriman
              Reporter:
              bobrosoft Vladimir Tolstikov
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-17498
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Integration