2
votes

I noticed this issue with 6.1, but it persists after downgrading to 6.0.

On some Android devices, the Facebook login window takes a long time to appear. The loading icon shows intermittently, and then the Facebook window eventually shows, or the game crashes.

The problem is inconsistent, but I think sometimes it crashes when trying to show the Facebook window, and sometimes it crashes when returning to the game.

Here's a crash report from one of my testers:

java.lang.Error: FATAL EXCEPTION [main] Unity version : 4.6.0b21 Device model : motorola XT1032 Device fingerprint: motorola/falcon_retgb/falcon_umts:4.4.4/KXB21.14-L1.40/36:user/release-keys

Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=64206, result=-1, data=Intent { (has extras) }} to activity {com.companyname.gamename/com.facebook.unity.FBUnityLoginActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.facebook.Session.onActivityResult(android.app.Activity, int, int, android.content.Intent)' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:3432) at android.app.ActivityThread.handleSendResult(ActivityThread.java:3475) at android.app.ActivityThread.access$1300(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1258) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5086) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.facebook.Session.onActivityResult(android.app.Activity, int, int, android.content.Intent)' on a null object reference at com.facebook.unity.FBLogin.onActivityResult(FBLogin.java:245) at com.facebook.unity.FBUnityLoginActivity.onActivityResult(FBUnityLoginActivity.java:25) at android.app.Activity.dispatchActivityResult(Activity.java:5446) at android.app.ActivityThread.deliverResults(ActivityThread.java:3428) ... 9 more

Here's the logcat warnings and errors from when login crashed on my device:

pastebin

p.s. Sorry that this question reads like a bug report, not a question. Facebook have asked users to report feedback and bugs through Stack Overflow.

1

1 Answers

0
votes

I figured out what was causing this issue. Although I'm not sure if what I was doing was incorrect, or whether there is a bug.

I was passing the callback method by referencing the instance of my MonoBehaviour and the method. It seems the reference to the callback was sometimes lost this way. If I just pass a reference to the method it works fine.

// instance is a reference to this instance of monobehaviour

// this sometimes crashes
public static void TryFBLogin() {
    if (instance != null && FB.IsInitialized) {
        FB.Login("public_profile,user_friends", instance.OnFBLoginAttempted);
    }
}

// this works
public void TryFacebookLogin() {
    if (FB.IsInitialized) {
        FB.Login("public_profile,user_friends", OnFBLoginAttempted);
    }
}