Facebook login returning status aborted the first time (DEF-2531)

I am facing some weird problem with facebook login. (android)
The very first time I call facebook.login_with_read_permissions (for a particular user), the facebook app shows the permissions required window. Then when the user accepts the permissions, I get status as “Aborted”.

The second time, however, everything works as expected, facebook does not ask for permission (because it was granted the first time) no window appears and I get the correct response.

The same thing happens when using facebook.login_with_publish_permissions.

This also happens when the user is logged out of the facebook app and logs in when the window appears.

local function get_me_callback(self, id, response)
    -- The response table includes all the response data
    pprint(response)
end

local function fb_login(self, data)
    pprint(data)
    if data.status == facebook.STATE_OPEN then
        -- Logged in ok. Let's try reading some "me" data through the
        -- HTTP graph API.
        local token = facebook.access_token()
        local url = "https://graph.facebook.com/me/?access_token=" .. token
        http.request(url, "GET", get_me_callback)
        msg.post(self.sender, "fb_login_success")
    elseif data.status == facebook.STATE_CLOSED_LOGIN_FAILED then
        -- Do something to indicate that login failed
        pprint("Error!!")

    else
        pprint("Handle facebook app logout error!!")
    end
end

function on_message(self, message_id, message, sender)
    if message_id == hash("login") then
        facebook.login_with_read_permissions(permissions, fb_login)
    end
end

The output I get only the first time

DEBUG:SCRIPT: 
{
  error = Aborted,
  status = 0,
}

DEBUG:SCRIPT: Handle facebook app logout error!!
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook

Another thing, when the facebook window appears, pressing back is not closing the window. It returns to the game for a second then reopens the facebook window.

Here I tried pressing back a few times

DEBUG:SCRIPT: 
{
  error = Aborted,
  status = 0,
}

DEBUG:SCRIPT: Handle facebook app logout error!!
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook
ERROR:FACEBOOK: No callback set for facebook

What’s going on?

Oh, hmm, this sounds like a potential bug. @jakob.pogulis knows more about the fairly recent changes to the Facebook extension.

1 Like

I tried this on the HTML build and login_with_read_permissions works as expected.

But when I try to get publish permissions I get this error (only in HTML build):

ERROR:SCRIPT: facebook/facebook.script:110: attempt to call field 'login_with_publish_permissions' (a nil value)  dmloader.js:299:32
stack traceback:  dmloader.js:299:32
	facebook/facebook.script:110: in function <facebook/facebook.script:101>

I m also facing the issue in HTML build. Not able to get publish permission on HTML build it shows this error:

ERROR:SCRIPT: facebook/fb.script:80: attempt to call field ‘login_with_publish_permissions’ (a nil value)

Also, when I try to login in facebook using:

facebook.login_with_read_permissions(permissions, fb_login)

it opens login window of fb app on android and when I press back button it doesn’t get back to defold instead it reopens the login window and does not cancel nor does it give any error from facebook.
It’s a critical one for us.

What’s going on?

I had a look at this a couple of days ago and couldn’t see that anything would be wrong. Will take another look first thing tomorrow morning.

1 Like

I tested it on two different phones with android 6 and 7. It only happens when the facebook app is installed.
User cannot cancel the fb app window and first response to a successful login is “Aborted”.
Without the Facebook app installed everything works as expected.

Do you mean a preinstalled Facebook application (from the phone vendor), or the application from the app store?

From Google Play Store

Hello!

Thank you for reporting this problem. Turns out there was a problem with memory corruption of the facebook function table on HTML5 that we hadn’t noticed, the function login_with_publish_permissions was stored as login_with_publish_permission+□� (I’m not sure if it’s actually possible to call it like that).

We’ve tracked down the issue and fixed the problem. The fix should be available in the alpha within a couple of hours, available in the beta on Wednesday next week and be part of Defold 1.2.99 stable.

Regards,
Jakob

7 Likes

Thank you for fixing the publish issue on html build :relaxed:
Could you reproduce the Android issues we are facing? Not able to cancel fb app window is very inconvenient.

2 Likes

Hi guys, have you found or were able to reproduce the issue related to cancelling a fb app login/permission window. This is critical for us as we need to send our app for facebook app review and we are currently blocked because of this. Users should be able to cancel the login/permission window and currently, it is not happening instead it’s again opening the fb app login/permission window and doesn’t return back to defold. It’s happening on Android build.
Can you guys give me any update on this issue.
I have also attached a link of the video of this issue on a sample project:

https://drive.google.com/open?id=0B1vFkH4Iew6xRFZxNFJraVJtX2M

Video link

Would you mind trying Blossom Blast and see if you can reproduce the behaviour in that game? I’ll poke @jakob.pogulis and ask him to get back to you as well.

It did not happen in Blossom Blast, in normal conditions :sweat_smile:

I changed my game to portrait orientation and it works
I tried all combinations, The problem occurs whenever it needs to rotate the screen to open FB.

It works if game is landscape and fb opens in landscape
or when both are in portrait

if ‘auto rotate’ was enabled then sometimes it would work normally, sometimes i could cancel the fb window after few tries.

If not already logged in fb, the fb login windows always opens in portrait mode then again different things would happens

In my case both the phones were set to ‘portrait’ from android so a screen rotation occurs.

In Blossom Blast, set the phone to autorotate, click ‘sign in with facebook’ while holding the phone sideways in landscape so fb opens in landscape view, then try canceling any permission window or login window.

Hello!

I’ve tried to reproduce the problem you’re having on Android but without any luck. I do manage to get LOGIN_CANCELLED as a response if I try to use login_with_read_permissions but without specifying any permissions. This is something that is not mentioned in the documentation, but the table of permissions must contain at least one item.

I haven’t tested to rotate the device as you describe, but if that’s how to recreate the problem it ties into a much more general issue we’re having with Android and rotation. I know that @sven recently worked with some rotation issue on Android, and he might be able to provide more information, or connect some additional dots here.

Regards,
Jakob

2 Likes

We’ve created a separate issue for the Android problems (DEF-2531). I’ve updated the topic of this post to track it.

3 Likes

Ok, Thank You :slight_smile:

Here’s how to reproduce the problem in Blossom Blast
video
Android is set to auto rotate.
(I’m logged in as a test user that’s why fb app shows the error, but that does not affect the behavior)

1 Like

Hi @britzl @jakob.pogulis @sven, any updates on the above issue related to orientation with fb app(from fb portrait to game landscape, fb window cancel issue).

I haven’t heard anything more about this issue. I’ve contacted @Sara to see if we can get an estimate for it.