Facebook的统一SDK登录很慢,有时会崩溃 [英] Facebook Unity SDK login very slow and sometimes crashes

查看:1814
本文介绍了Facebook的统一SDK登录很慢,有时会崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到这个问题6.1,但降级到6.0后仍然存在。

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

在某些Android设备上,Facebook的登录窗口需要较长时间才能出现。加载图标显示间歇,然后Facebook的窗口最终显示,还是游戏崩溃。

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.

问题是不一致的,但我觉得有时候试图表明Facebook的窗口崩溃时,有时崩溃回到比赛的时候。

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:致命异常[主]统一版本:4.6.0b21
  设备型号:摩托罗拉XT1032设备指纹识别:
  摩托罗拉/ falcon_retgb / falcon_umts:4.4.4 / KXB21.14-L1.40 / 36:用户/释放键

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

引起:了java.lang.RuntimeException:失败交付结果
  ResultInfo {谁= NULL,请求= 64206,结果= -1,数据= {意向(有
  演员)}}到活动
  {com.companyname.gamename / com.facebook.unity.FBUnityLoginActivity}:
  显示java.lang.NullPointerException:尝试调用虚函数
  布尔com.facebook.Session.onActivityResult(android.app.Activity,
  INT,INT,android.content.Intent)上以空对象引用
  android.app.ActivityThread.deliverResults(ActivityThread.java:3432)在
  android.app.ActivityThread.handleSendResult(ActivityThread.java:3475)
  在android.app.ActivityThread.access $ 1300(ActivityThread.java:139)在
  android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1258)
  在android.os.Handler.dispatchMessage(Handler.java:102)在
  android.os.Looper.loop(Looper.java:136)在
  android.app.ActivityThread.main(ActivityThread.java:5086)在
  java.lang.reflect.Method.invoke(本机方法)的
  com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:785)
  在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)所引起
  按:显示java.lang.NullPointerException:尝试调用虚函数
  布尔com.facebook.Session.onActivityResult(android.app.Activity,
  INT,INT,android.content.Intent)上以空对象引用
  com.facebook.unity.FBLogin.onActivityResult(FBLogin.java:245)在
  com.facebook.unity.FBUnityLoginActivity.onActivityResult(FBUnityLoginActivity.java:25)
  在android.app.Activity.dispatchActivityResult(Activity.java:5446)在
  android.app.ActivityThread.deliverResults(ActivityThread.java:3428)
  ...... 9点多

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

下面是从登陆时坠毁我的设备上的logcat的警告和错误:

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

引擎收录

P.S。对不起,这个问题倒像是一个bug报告,而不是一个问题。 Facebook的已经要求用户通过堆栈溢出报告的反馈和错误。

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.

推荐答案

我想通了什么导致这个问题。虽然我不知道我在做什么是不正确的,或者是否有错误。

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.

我被引用我MonoBehaviour和方法的实例传递回调方法。看来参考回调有时会丢失这种方式。如果我只是传递给方法的引用,它工作正常。

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);
    }
}

这篇关于Facebook的统一SDK登录很慢,有时会崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆