Facebook-sdk-for-unity: Crash on launch on iOS - [FBSDKGraphRequestConnection errorFromResult:request:]

Created on 28 Dec 2018  ·  131Comments  ·  Source: facebook/facebook-sdk-for-unity

I'm using the sdk for analytics only. I'm getting rare crashes on app launch for some of our users (Unity 2018.2.19 and iOS 12.1) on 4G only (works fine on wifi). Xcode crash logs show:

image

At first I thought it was due to FB not being initialized properly but I'm using
private void Awake() { if (FB.IsInitialized) { FB.ActivateApp(); } else { FB.Init(FB.ActivateApp); } }
And I check that FB has been initialised before logging any analytics event.

Not sure if I'm doing something wrong or if this is a bug. Would love some feedback either way.

Thanks!

Most helpful comment

@sharonreytan Glad to be of help!

All 131 comments

I'm getting this exact issue every time I launch on my iPhone 6s. It was not happening with the 7.14.1 version of the SDK, only 7.15.0. It means I'm completely unable to test my game without going back to an older version of the SDK (which I didn't seem to be getting any events from - hence why I upgraded). Would also love feedback if anyone else knows what might be wrong!

From Xcode the error appears to be: NSInvalidArgumentException: +[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x257dd4f80

Any news on this? We're getting the crash even without calling the API at all, just having it as part of the project. We have to remove the sdk completely for now...

I'm not sure if it'll be helpful but it turns out my problem was caused by the FacebookSettings object breaking when I updated the SDK. I just deleted it and made a new one and now everything is working again.

Hey @NumaNumaNuma @BlazingGillian, FB Unity SDK v7.15.1 is released and the issue should be fixed.

Hi @KylinChang, unfortunately I updated to the latest version and the issue is still occurring, the app crashes on launch every time. (It was also happening with 7.14.1 by the way).

Hi @NumaNumaNuma , thanks for your report. Can you provide more details about the iOS device you use, iOS version and maybe more stack traces?

I've seen it happen on a mix of iPhones and iPads running iOS 11.4, 12 and 12.1, so I'm not sure if it's device related (iPad Pro 11" 2018, iPhone X, iPhone XR, iPhone XS Max). The one interesting thing is for the people affected it works fine on wifi, but crashes 99% of the time on cellular. As for stack traces, I don't have anything besides the crash logs reported by xcode (hundreds of the same crash log). Could I email the .xccrashpoint file to you?

@NumaNumaNuma , sure, you can email .xccrashpoint file to me. Thanks for your report again!

@KylinChang Thanks, sent.

I tried using the sdk example scene AppEvents as a test, to rule out anything being caused by my project, and it 's crashing too. I didn't add anything to the scene besides this script to initialise the sdk that I placed on a gameobject in the scene (the example scene didn't have any init code by default). One thing I noticed is I'm getting a warning for calling init twice (in Awake and in OnApplicationPause), not sure if that's a problem?

`
public class AnalyticsManager: MonoBehaviour
{

    void Awake()
    {
        base.Awake();
        InitFBSDK();
    }

    public void InitFBSDK()
    {
        if (!FB.IsInitialized)
        {
            // Initialize the Facebook SDK
            FB.Init(InitCallback);
        }
        else
        {
            // Already initialized, signal an app activation App Event
            FB.ActivateApp();
        }
    }

    public void InitCallback()
    {
        if (FB.IsInitialized)
        {
            // Signal an app activation App Event
            FB.ActivateApp();
        }
        else
        {
            Debug.Log("Failed to Initialize the Analytics SDK");
        }
    }

    private void OnApplicationPause(bool pauseStatus)
    {
        // Check the pauseStatus to see if we are in the foreground
        // or background
        if (!pauseStatus)
        {
            //app resume
            if (FB.IsInitialized)
            {
                FB.ActivateApp();
            }
            else
            {
                //Handle FB.Init
                FB.Init(InitCallback);
            }
        }
    }

}`

We're seeing the same issue, except for our users it seems disabling wifi and going over 4G works. Maybe it's just something with a change of network connection that temporarily fixes it?

I think whichever is the fastest/slowest is causing problems at init time. Hopefully Kylin finds something in my logs🤞.

@KylinChang Let me know if you want our crash logs as well.

Hi @NumaNumaNuma @kuljaninemir , I think you can add -ObjC flag in exported xcode project to fix the problem. I will keep this issue open and please let me know if it still crashes with the flag. FYI, here is link about how to add the flag http://docs.onemobilesdk.aol.com/ios-ad-sdk/adding-objc-linker-flag-xcode.html

@KylinChang Thanks, I tried adding the flag, but it causes a link error:
/Libraries/Plugins/iOS/libQuantumCore.a(QuantumCore.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. file '/Libraries/Plugins/iOS/libQuantumCore.a' for architecture arm64
I could disable bitcode but I'd rather not. Is there any way around this?
edit: I'll disable bitcode and send to my patient 0, see if the issue is resolved.

All is good on my side and users reported the problem is gone. I'll put a version out to the world and if no one complains then we can call it fixed! @kuljaninemir is it fixed for you too?

I don't have contact with a patient 0 unfortunately so I'll have to push an update with this and see if the crashes stop.

No crashes so far, I think it's fixed! Thanks @KylinChang

Seems to work for us as well, thanks @KylinChang

I have the same issue with my app. Version 7.15.1
Will try to upload next version with -ObjC flag. Sorry, maybe this is stupid question, but why this information is not in instruction with sdk integration?

Why not just add a post processing script to the Unity SDK?

[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
{
    if (buildTarget == BuildTarget.iOS)
    {
        string projPath = PBXProject.GetPBXProjectPath(path);

        PBXProject proj = new PBXProject();
        proj.ReadFromString(File.ReadAllText(projPath));
        string targetName = PBXProject.GetUnityTargetName();
        string targetGUID = proj.TargetGuidByName(targetName);

        proj.AddBuildProperty(targetGUID, "OTHER_LDFLAGS", "-ObjC");

        File.WriteAllText(projPath, proj.WriteToString());
    }
}

Yes please, That's what I ended up doing, but for others please add it to the post build process.

I am encountering the exact same issue.
What you mentioned here of adding the -ObjC did the trick for iPhone, but Apple rejected my binaries because of a crash on an iPad with IOS 12.1.4.
Can anyone shed light on this please? I can't figure that out.
The moment I go on cellular / flight mode / remove the Facebook SDK the error is gone.
On Android everything works perfectly.

@sharonreytan Did you try the solution mentioned above?
Are you using any other analytics solutions?

Yes, I added the -ObjC flag. It did solved the issue on my iPhone with IOS 12.1.4 that I test with, but Apple rejected my app, saying that it crashes on load on an iPad with IOS 12.1.4, on wifi.
I use Game Analytics SDK in addition to Facebook SDK.
The error comes from the Facebook SDK for sure, it is the one that throws the exception that crashes my app. Also, when I remove it everything works well, no crashes.
I use Unity 2018.3.3, Facebook SDK 7.15.1 and xcode 10.1.
The error happens only when the wifi is connected, with that flag, it happens on iPads but not on iPhones. it is not something in my code.

@KylinChang Can you help here? Do you know if any update is coming up from Facebook?

@sharonreytan can you post the exception here?

I will ask from Apple the crash log. Thank you everyone in advance! :)

I suggest that you connect your app to a platform that catches the crashes, like Unity Analytics or Firebase Crashlytics. Unity Analytics is just one switch away. Even if you fix this crash, it is probably not going to be the only one you are ever going to have. https://unitytech.github.io/clouddiagnostics/UnityCloudDiagnosticsSettingUp.html

I do have such thing, but it doesn't catch that exception. I guess it is thrown on the wrapper level of Unity (the Swift stuff that handles such things like networking... That are OS related)

You can also see the crashes if you go to XCode -> Window -> Organizer -> Crashes (at the top, next to Archives) If they are symbolicated, try this to make them readable https://www.youtube.com/watch?v=kBA7H_uYf34

The problem is that I can't reproduce the error locally, because I don't have an iPad, only an iPhone.
Apple alerted me about this issue. As I said, on my iPhone everything works well with the -ObjC flag. The problem persists for iPads on wifi, and I can't simulate this with the simulator

The problem is that I can't reproduce the error locally, because I don't have an iPad, only an iPhone.
Apple alerted me about this issue. As I said, on my iPhone everything works well with the -ObjC flag. The problem persists for iPads on wifi, and I can't simulate this with the simulator

The organizer shows all the crashes related to a specific version. https://8mobile.wordpress.com/2015/02/27/xcode-crashes-organizer/

That's great. Thanks. I will add that

@sharonreytan can you please share the crash report as soon as possible? I am actually holding up my build release because of this issue.

Yep for sure. I am stuck with my release as well

Yep for sure. I am stuck with my release as well

Did you find the crash reports?

Not yet, it is a side project of mine

Same crash here :(

@pmusolino Can you post the crash report please?

@sharonreytan It happens randomly. The next time it happens I'll post it

I opened an empty project on Unity.
It added a simple 3d cube in it and a particle system to it.
I integrated to it the Facebook SDK and GameAnalytics SDK with my original app details.
The error persists on that simple app - only on wifi things go wrong and I get a crash. That is the exact same crash I got on the app that I am trying to release.
The error persist even if I remove the GameAnalytics SDK
I use Unity 2018.3.3, Facebook SDK 7.15.1 and Xcode 10.1.
This is the crash log:

2019-03-26 22:31:37.375996+0200 Jumpy[2798:888564] [DYMTLInitPlatform] platform initialization successful
2019-03-26 22:31:37.440830+0200 Jumpy[2798:888345] Built from '2018.3/staging' branch, Version '2018.3.3f1 (393bae82dbb8)', Build type 'Release', Scripting Backend 'il2cpp'
2019-03-26 22:31:37.446308+0200 Jumpy[2798:888345] -> registered mono modules 0x1035eb250
-> applicationDidFinishLaunching()
2019-03-26 22:31:39.096573+0200 Jumpy[2798:888345] Metal GPU Frame Capture Enabled
2019-03-26 22:31:39.098086+0200 Jumpy[2798:888345] Metal API Validation Disabled
2019-03-26 22:31:39.328250+0200 Jumpy[2798:888345] [Warning] Trying to set delaysTouchesBegan to NO on a system gate gesture recognizer - this is unsupported and will have undesired side effects
-> applicationDidBecomeActive()
GfxDevice: creating device client; threaded=1
Initializing Metal device caps: Apple A11 GPU
Initialize engine version: 2018.3.3f1 (393bae82dbb8)
2019-03-26 22:31:39.653020+0200 Jumpy[2798:888616] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port רמקול (type: Speaker)
2019-03-26 22:31:39.740801+0200 Jumpy[2798:888616] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port רמקול (type: Speaker)
2019-03-26 22:31:40.107347+0200 Jumpy[2798:888345] +[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x26fc19f80
2019-03-26 22:31:40.152342+0200 Jumpy[2798:888345] Uncaught exception: NSInvalidArgumentException: +[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x26fc19f80
(
0 CoreFoundation 0x0000000235d21ebc + 252
1 libobjc.A.dylib 0x0000000234ef1a50 objc_exception_throw + 56
2 CoreFoundation 0x0000000235c3fbbc + 0
3 CoreFoundation 0x0000000235d277bc + 1412
4 CoreFoundation 0x0000000235d2946c _CF_forwarding_prep_0 + 92
5 Jumpy 0x000000010315302c -[FBSDKGraphRequestConnection errorFromResult:request:] + 1720
6 Jumpy 0x00000001031519bc __64-[FBSDKGraphRequestConnection completeWithResults:networkError:]_block_invoke + 516
7 CoreFoundation 0x0000000235c074cc + 216
8 Jumpy 0x00000001031516ec -[FBSDKGraphRequestConnection completeWithResults:networkError:] + 540
9 Jumpy 0x0000000103150a30 -[FBSDKGraphRequestConnection completeFBSDKURLSessionWithResponse:data:networkError:] + 940
10 Jumpy 0x000000010314ebc4 __36-[FBSDKGraphRequestConnection start]_block_invoke_2 + 80
11 libdispatch.dylib 0x00000002357596c8 + 24
12 libdispatch.dylib 0x000000023575a484 + 16
13 libdispatch.dylib 0x0000000235739b34 + 1012
14 CoreFoundation 0x0000000235cb1ce4 + 12
15 CoreFoundation 0x0000000235cacbac + 1964
16 CoreFoundation 0x0000000235cac0e0 CFRunLoopRunSpecific + 436
17 GraphicsServices 0x0000000237f25584 GSEventRunModal + 100
18 UIKitCore 0x000000026300cc00 UIApplicationMain + 212
19 Jumpy 0x0000000102766650 main + 160
20 libdyld.dylib 0x000000023576abb4 + 4
)
2019-03-26 22:31:40.153484+0200 Jumpy[2798:888345] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x26fc19f80'
*
First throw call stack:
(0x235d21ea4 0x234ef1a50 0x235c3fbbc 0x235d277bc 0x235d2946c 0x10315302c 0x1031519bc 0x235c074cc 0x1031516ec 0x103150a30 0x10314ebc4 0x2357596c8 0x23575a484 0x235739b34 0x235cb1ce4 0x235cacbac 0x235cac0e0 0x237f25584 0x26300cc00 0x102766650 0x23576abb4)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

I got pretty much the same networkError from facebook happening with my new game:

2019-03-26 19:31:10.325566-0600 gamename[651:128389] +[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x228d7af80
2019-03-26 19:31:10.380123-0600 gamename[651:128389] Uncaught exception: NSInvalidArgumentException: +[NSError fbErrorWithCode:userInfo:message:underlyingError:]: unrecognized selector sent to class 0x228d7af80
(
0 CoreFoundation 0x00000001ef9a5ebc + 252
1 libobjc.A.dylib 0x00000001eeb75a50 objc_exception_throw + 56
2 CoreFoundation 0x00000001ef8c3bbc + 0
3 CoreFoundation 0x00000001ef9ab7bc + 1412
4 CoreFoundation 0x00000001ef9ad46c _CF_forwarding_prep_0 + 92
5 gamename 0x0000000105ba3f2c -[FBSDKGraphRequestConnection errorFromResult:request:] + 1720
6 gamename 0x0000000105ba28bc __64-[FBSDKGraphRequestConnection completeWithResults:networkError:]_block_invoke + 516
7 CoreFoundation 0x00000001ef88b4cc + 216
8 gamename 0x0000000105ba25ec -[FBSDKGraphRequestConnection completeWithResults:networkError:] + 540
9 gamename 0x0000000105ba1930 -[FBSDKGraphRequestConnection completeFBSDKURLSessionWithResponse:data:networkError:] + 940
10 gamename 0x0000000105b9fac4 __36-[FBSDKGraphRequestConnection start]_block_invoke_2 + 80
11 libdispatch.dylib 0x00000001ef3dd6c8 + 24
12 libdispatch.dylib 0x00000001ef3de484 + 16
13 libdispatch.dylib 0x00000001ef38a9a4 + 1068
14 CoreFoundation 0x00000001ef935ce4 + 12
15 CoreFoundation 0x00000001ef930bac + 1964
16 CoreFoundation 0x00000001ef9300e0 CFRunLoopRunSpecific + 436
17 GraphicsServices 0x00000001f1ba9584 GSEventRunModal + 100
18 UIKitCore 0x000000021cb40c00 UIApplicationMain + 212
19 gamename 0x0000000104dc01e0 main + 160
20 libdyld.dylib 0x00000001ef3eebb4 + 4
)
(lldb)

Funny though, I have the exact opposite happening. My game works great on WIFI, but as soon I'm on 3G it crashes. The crash report from above is on data 3G on a iPhone SE with iOS 12.2. Apple let it through review...

@KylinChang Can you please have a look? This is a fatal error... I can't release my game because of that. Apple rejects my binaries.
Might it be related to iOS >12.1.4?

@elguero44 did you add the -ObjC flag?
I guess Apple missed with your app. It seems to happen even on the simplest project. It is something on the FBSDK for Unity.
My previous game was also approved and released but I see that there are crashes on iPads. It also had the FBSDK

Are you all seeing this since ios 12.2 / XCode 10.2 was released this week?

I experienced it on iOS 12.1.4 and Xcode 10.1 as well.
I will quote apple:
"We discovered one or more bugs in your app when reviewed on iPad running iOS 12.1.4 on Wi-Fi.

Specifically, your app launched to a black screen and no further action was produced."

The black screen is the Unity splash screen. This version was submitted for review with the -ObjC flag

Did anyone report this issue to Facebook bug tracker?

@oct-test I did not. Can you please? I am far away from my project at the moment... And they require some stuff I can't gather right now

Great, thanks

Hi @oct-test @sharonreytan , sorry for the late reply. I will investigate the issue and will reply to you as fast as possible. Do you have the same exception as Uncaught exception: NSInvalidArgumentException: +[NSError fbErrorWithCode:userInfo:message:underlyingError:]:? Can you upload a sample project if possible?

Thanks for your comments and help in this issue!

@KylinChang Yeah, that is the error. I want to help you get to the issue - it happens on iOS > 12.1.4, on Facebook SDK for Unity 7.15.1.
On an iPhone -ObjC solved this issue.
On iPads the error persists on wifi. Some of us experienced it for cellular. It happens on load, before we get to call FB.Init().
I will upload a sample project soon.
Thank you for reopening the issue

https://drive.google.com/open?id=1aLdPTQyiqpCJf1bMyOGjLeOPg2D8NjZx

Sorry it's not on git.
It is a simple project with a cube, particles system and Facebook SDK 7.15.1 integrated to my app ID.
Notice that the Unity project is with my app's bundle name. Change it as you wish.
Unity version is 2018.3.3.

What version should we use in the mean time?

@elguero44 did you add the -ObjC flag?
I guess Apple missed with your app. It seems to happen even on the simplest project. It is something on the FBSDK for Unity.
My previous game was also approved and released but I see that there are crashes on iPads. It also had the FBSDK

No I haven't added ObjC flag. Weird though that this would swap the behaviour...

@elguero44 No, it solves the error on my iPhone. Try it. I can't test on an iPad but for that Apple rejects me.
I think that for now I will release only for iPhones until the issue is fixed. I'll keep you updated if Apple will approve or reject it

No I haven't added ObjC flag. Weird though that this would swap the behaviour...

From what I've seen It happens on either wifi / 3G depending on which one is slower / faster where you are. And definitely add the objC flag, it fixed it for me a few months ago but now with all those recent posts I'm worried the problem is back with the new iOS / XCode.
Waiting on more info from KylinChang 👍

I think it has something to do with the velocity of the internet connection? Because suddenly sometimes on data it works too...

@KylinChang I have attached the crash report.
Crash Report

@sharonreytan By any chance, do you have a space after your app ID in the fb SDK edit settings panel? I found that I had one there by accident, after I removed it, the problem was fixed, even without the -ObjC flag. I will leave the ObjC flag there just in case.

@happypepper Oh no if it is the issue I will feel so bad... I will check this asap. I don't think this is the case because I copied from the Facebook for Developers site by click, but everything is possible.. Did you check it on wifi, cellular and flight mode and everything was fine? Did it crash only on iOS? on which iOS version did it happen?

I also copy pasted from FB developer site, but somehow the space was included. I tried wifi and cellular but not flight mode, they were both fine. With the space, it was breaking on cellular but fine on wifi. I've only been testing on 12.1.2

@happypepper thank you so much for writing this, I will check if that's the case. Hopefully that's the issue

@happypepper No extra spaces in the app id. Still crashes.

hard to explain how it solved the issue for that day. Maybe the wifi was bad and it worked for my testers and I. Please ignore this, the error persists

@happypepper How can I send you some flowers???? You solved my issue!!!! Thanks!!
@oct-test @elguero44 @pmusolino
I had a space in my app name, I removed it. Boom. Everything works well even without the -ObjC flag.. I'm on the same wifi, same device, same os, same fbsdk with GameAnalytics on unity, same unity, same Xcode, same project... It was the only change I made and now it works like a charm every single launch...

I had the same issue with sdk 7.15.1
The problem seems to be in the FBUnityInterface.mm file at this line 114:
[FBUnityUtility sendMessageToUnity:FBUnityMessageName_OnInitComplete userData:userData requestId:0];

if i comment this line out, everything works without crash

@happypepper How can I send you some flowers???? You solved my issue!!!! Thanks!!
@oct-test @elguero44 @pmusolino
I had a space in my app name, I removed it. Boom. Everything works well even without the -ObjC flag.. I'm on the same wifi, same device, same os, same fbsdk with GameAnalytics on unity, same unity, same Xcode, same project... It was the only change I made and now it works like a charm every single launch...

@sharonreytan Congratulations! Thank you @happypepper. I will investigate further on the reason and will add warning or fix the issue in the next release.

@KylinChang thanks! Let's validate that everyone's errors with this issue got to solve it as well. I really hope so

@sharonreytan Glad to be of help!

No extra spaces in the app id. Still crashes.

So @oct-test no extra space + objC flag still doesn't do it for you?

@NumaNumaNuma @sharonreytan @KylinChang
No extra space in the app id + objC flag = issue not resolved

I am able to see the in-game events in the Facebook Analytics dashboard. In my case, the build randomly crashes when the code tries to send an event.

@oct-test try to change your app name to a single word, something like "production", remove the client token, copy the app id again and make sure that there are no spaces in the beginning and in the end.
Make sure that your event messages have no spaces.
Make sure that your iOS bundle ID is correct on the Facebook for Developers dashboard > settings > basic.
In my case the crash was on load, now it runs well even without this -ObjC flag, but I don't send events to fb. Only initialize it.
Does the game crash on load, or crashes in-game when you send an event?

@sharonreytan

  1. Do I need to change the app name in Facebook Dashboard or in the Xcode project? Can you please help me understanding that how app name can possibly cause this issue?
  2. Where can I find the client token?
  3. I have checked and confirmed that there is no extra space in the app id.
  4. No spaces in the event messages.
  5. Yes, the iOS bundle id is correct on the Facebook dashboard.
  6. Yes, the game crashes on load and in-game too. But this crash is not continuous. It is happening randomly.

@oct-test

  1. On unity > Facebook settings
    If you don't use unity then probably in the xcode.
    I assume that there is a bug in the FBSDK that it can't handle space in its input parameters. Maybe there is a regex that validates your string and it can't accept spaces... I don't know. It can be anything. As a developer you know that bugs can surprise you and be unexpected. If they were expected there wouldn't be any bugs ever! I don't know the cause but it will be solved in a future version hopefully, but for now try to do everything you can to find a workaround.
  2. On unity it's in the Facebook settings inspector

Thank you for the explanation.

  1. Regarding the app name in the Facebook settings, that is an optional field just for our own purpose. I think Facebook is not using this information.
  2. I checked it and this field is already removed.

Were you able to reproduce the issue 100% times? If yes, what type of device (model and iOS version) and network connection you were testing the build?

@oct-test

  1. Yep I agree, but an optional field can crash stuff as well. That's a bug. Try everything you can do to overcome it. It helped me then it might help you.
  2. Check every free text you can and remove spaces from it.

I didn't need the -ObjC flag anymore, ran the game on simulators and sent a test flight to friends. It works perfectly on their devices, with wifi or cellular or flight mode. On my iPhone 8 it runs smoothly as well. Beforehead the game crashed immediately on load without the -ObjC flag on wifi. Now everything runs as expected

@KylinChang @oct-test
My celebration was too early. The game has been rejected for the same reason -

On iPad running iOS 12.2 on wifi the game crashed

Better apple catching it than your users (that's what happened to me). If you can do without, temporarily, there's also the option of completely removing the sdk.
I'll be holding out on my releases until this is fixed.

For sure. Do you think I can release to iPhones only? I can't give up on the sdk.
@NumaNumaNuma

Risky :)

Holding out on your release is not a solution. It seems that this problem exists for a long time now. At least 2 years. We went through all releases since 2017 and the problem is the same. There must be another solution that some devs accidentally do in order to not get the crashes.

For me as soon as I added the objC flag everything has been fine, for months. But it seems the problem is back, maybe because of the new iOS?

I actually realized that I have objC flag in my project all along. And still have the problem. I also checked back my older projects and I see that after doing an update to fb sdk 4.38 just recently my crash rate went down significantly. I'm doing a test right now with unity version 7.14.1 that has this version of fb sdk included. Will report back. We also moved the initialization to the start method (from the awake method).

Question: can we update manually in Xcode to the latest FB SDK, replacing the one that comes with Unity SDK? Anyone has tried that?

For me as soon as I added the objC flag everything has been fine, for months. But it seems the problem is back, maybe because of the new iOS?

I'm using ios 12.1.4 on the device I registered myself the problem.
Unity version used is: 2018.2.9

@elguero44 did anything you try solved this? I noticed that when the internet's downstream Mb/s is low it doesn't crash mostly

I reopened the issue on Facebook:
https://developers.facebook.com/support/bugs/2313553335596878/?disable_redirect=0

@oct-test @elguero44 @NumaNumaNuma @pmusolino and everyone else that experiences this, Please mark the "same here" flag

done 👍

Don't know if that has anything to do with it, but I noticed sometimes the LSApplicationQueriesSchemes values are not being added to the info.plist file. Maybe if they're missing and the sdk is trying to call them, it causes problems? I logged this as a separate issue but maybe they're related.
"fbapi", "fb-messenger-api", "fbauth2", "fbshareextension"

I reopened the issue on Facebook:
https://developers.facebook.com/support/bugs/2313553335596878/?disable_redirect=0

@oct-test @elguero44 @NumaNumaNuma @pmusolino and everyone else that experiences this, Please mark the "same here" flag

Done.

Don't know if that has anything to do with it, but I noticed sometimes the LSApplicationQueriesSchemes values are not being added to the info.plist file. Maybe if they're missing and the sdk is trying to call them, it causes problems? I logged this as a separate issue but maybe they're related.
"fbapi", "fb-messenger-api", "fbauth2", "fbshareextension"

Can you please post the Facebook Bug Tracker link here?

Don't know if that has anything to do with it, but I noticed sometimes the LSApplicationQueriesSchemes values are not being added to the info.plist file. Maybe if they're missing and the sdk is trying to call them, it causes problems? I logged this as a separate issue but maybe they're related.
"fbapi", "fb-messenger-api", "fbauth2", "fbshareextension"

In my Xcode project, all those schemes are present but the problem still persist. @NumaNumaNuma anything else I should look into?

@KylinChang we are looking for some help from you. Please let us know the progress made on the bug resolution by the Facebook team. Thank you.

@KylinChang @NumaNumaNuma @sharonreytan
Do you know how can we integrate the FB iOS SDK version 4.40 (latest FB iOS SDK) in this Unity version?

Current version of Unity FB SDK (v7.15.1) uses FB iOS SDK version 4.39.1.

The changelog here suggest that there are few bug fixes in the latest FB iOS SDK.

@oct-test also this version presents the issue.

Hey all, you can change SDK version by following steps: 1. change the version in scripts/build.properties 2. run ./scripts/setup.sh && ./scripts/build.sh. Open project UnitySDK and then export the package.

@pmusolino
Facebook iOS SDK 4.40 has this issue?

Hello all,

On my end, the frequency of this crash issue in very low. I am thinking to release my game and try my luck.

I wanted to know if any other developer here got his/her game approved from Apple? If yes, are there any user complaints about the crash? What's the frequency of the crash on the users' end?

Thank you.

@oct-test
I wouldn't take the risk of releasing. On my wifi the crash happens every launch. You don't want users to give you bad reviews for these crashes, you put too much effort in it to be scored badly for crashes. People write bad reviews faster than they write good reviews. I decided to wait for a resolution before my release (a fix or a workaround, but stabilization is a must...)

I decided to release the app anyway, so far so good no crashes.
just in case it helps, this is how I'm initializing the sdk (nothing special there but who knows maybe for those who have crashes on launch...):

private void Awake()
        {
            InitFBSDK();
        }

        private void InitFBSDK()
        {
            if (!FB.IsInitialized)
            {
                FB.Init(InitCallback);
            }
            else
            {
                // Already initialized, signal an app activation App Event
                FB.ActivateApp();
            }
        }

        public void InitCallback()
        {
            if (FB.IsInitialized)
            {
                // Signal an app activation App Event
                FB.ActivateApp();
            }
            else
            {
                Debug.Log("Failed to Initialize the Analytics SDK");
            }
        }

        private void OnApplicationPause(bool pauseStatus)
        {
            if (!pauseStatus)
            {
                if (FB.IsInitialized)
                {
                    FB.ActivateApp();
                }
                else
                {
                    FB.Init(InitCallback);
                }
            }
        }

Please let us know if Apple approved. I think it has to do with the internet's Mb/s, one day my wifi was slow and everything worked... The day after it went back to normal and the crash persisted.
Which fb sdk version do you use?

yeah approved and released 2 apps on Monday, no problem at all. But maybe that's just me.

I am glad to hear that! I will try to submit as well, this time only for iPhones.
Which fb sdk version do you use?

I used the latest unity one, 7.15.1

@sharonreytan @NumaNumaNuma

My game got approved by Apple yesterday (just like last time). I will monitor the crash rate for my game over few days to see if the issue still persist.

Rejected by Apple, again.
@KylinChang anything new on this? What to do?

Did anyone find a fix to this? My app ratings are destroyed because of it.

hey @sharonreytan @sarebots , sorry for late reply, can you try adding -all_load linker flags as indicated in https://stackoverflow.com/questions/2906147/what-does-the-all-load-linker-flag-do. From what I found, that's because NSError methods defined in FBSDKCoreKit are not recognized and that's a known Xcode issue.
Reference link: https://developer.apple.com/library/archive/qa/qa1490/_index.html

@KylinChang so -ObjC and -all_load combined? Can you add this to the post build commands from Unity to xcode in a future release?

@KylinChang so -ObjC and -all_load combined? Can you add this to the post build commands from Unity to xcode in a future release?

Yes, combine them together and adding compiling flags in post build is already in our roadmap.

@sharonreytan Did this fix work for you? I'm getting crash reports with the exact same issue.

I sent some test flights but Apple didn't approve my app yet, because they are now investigating my account, because I submitted many times... Very frustrating, but I am waiting for their answer patiently.
My testers reported no issues. Did you add the flags -ObjC and -all_load?

It did fix the issue for me.

@sharonreytan I haven't tried adding the flags yet, just wanted to see if anyone has had success before I submit a new build to apple.

It did help me, but until Apple won't approve I can't confirm. It happens on certain connections, and doesn't happen all the time. When I was able to reproduce it my internet was 150 Mb/s.
In any case I'd release a fix with those flags after some testing if I was in your place. The issue happened after iOS 12.1 and the solution seems to work well. I tested it on multiple devices and connection types and speeds

Facing the same issue, something related to wifi or mobile networks or switching between these. Some people are facing this on Wifi Networks. I am facing this on a 4G Mobile network. App just crashes on launch. I have to finally remove Facebook SDK completely to submit to the app store until we have a solution. Also, the app works perfectly fine on Android, it's just an iOS issue.

This similar issue 472 reported against the iOS SDK details that adding the _-ObjC_ linker flag may not completely resolve the crash.

Adding the _force_load_ linker flag and the correct path to the _FBSDKCoreKit_ Framework did however fix the crash for me, as @Umar559 also reports below

Initially just using the _force_load_ linker flag against the _FBSDKLoginKit_ was not enough to stop the crash from occurring on some test devices.

it's work for me. Thanks @julianD77

Adding the following to Other Linker Flags fixed it:
-force_load
${PROJECT_DIR}/Frameworks/FBSDKCoreKit.framework/FBSDKCoreKit
it fixed crash on mobile data

Note: the path may be different depending on where your FBSDKCoreKit.framework is located

In v7.16.0, Unity SDK will add -force_load to "Other Linker Flag" for your project

@KylinChang what about -ObjC flag?

Hi @happypepper, I don't think you will need -ObjC flag With -force_load

If the problem is still not solved by some of you guys. The might be a life saver. Worked pretty much for my last 3 hyper casual games. Check out the following link

Good luck

I updated to 7.16.1 with -force_load flag, but the crash still happened

Anyone experiencing same issue?

@inxidious
Can you try again with the latest fbsdk version (7.17.1)?
The issue was solved for me on fbsdk 7.15.0 with the -force_load flag, iOS 12.3.1, unity 2019.1.1f, xcode 10.2.1.
I had 60 users in my app, ~230 sessions and no crashes were reported (all of them on iOS).
Did you get the same error - FBSDKGraphRequestConnection errorFromResult:request:?

@sharonreytan i tried 7.17.1, but after importing the SDK, there are weird errors. All my code referencing TextMeshPro are throwing errors, saying TextMeshPro could not be found. so i switched back to 7.16.1

Hey @inxidious, the root cause of the issue is that NSError category in FBSDKCoreKit is not loaded and -force_load should help fix the issue. Did you get the same error - FBSDKGraphRequestConnection errorFromResult:request:?

@KylinChang 7.16.1 added -all_load by default, but i'm unable to build with -all_load because of an error, so i changed it to -force_load and FBSDKCoreKit path {PROJECT_PATH}/Frameworks/FacebookSDK/Plugins/iOS/FBSDKCoreKit.framework/FBSDKCoreKit

after couple of launches, it crashes on app startup. Here's the log from xcode:

2019-07-09 10:11:44.811486+0700 gametitle[20035:4320446] I/UnityAds: +[UnityServices initialize:delegate:testMode:] (line:47) :: Initializing Unity Ads 3.1.0 (3100) with game id 2832682 in test mode
2019-07-09 10:11:44.815973+0700 gametitle[20035:4320446] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-07-09 10:11:44.816421+0700 gametitle[20035:4320446] [MC] Reading from public effective user settings.
Unloading 7 Unused Serialized files (Serialized files now loaded: 0)
2019-07-09 10:11:44.819778+0700 gametitle[20035:4320762] [NetworkInfo] Could not successfully update network info for descriptor <CTServiceDescriptor 0x282d77ae0, domain=1, instance=2> during initialization.
2019-07-09 10:11:44.821022+0700 gametitle[20035:4320446] [NetworkInfo] Could not successfully update network info for descriptor <CTServiceDescriptor 0x282d863a0, domain=1, instance=2> during initialization.
2019-07-09 10:11:44.821054+0700 gametitle[20035:4320762] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x282d77b60, domain=1, instance=1>
2019-07-09 10:11:44.821658+0700 gametitle[20035:4320762] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x282d77ae0, domain=1, instance=2>
2019-07-09 10:11:44.822644+0700 gametitle[20035:4320446] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x282d863c0, domain=1, instance=1>
2019-07-09 10:11:44.822801+0700 gametitle[20035:4320446] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x282d863a0, domain=1, instance=2>
2019-07-09 10:11:44.825375+0700 gametitle[20035:4320762] [NetworkInfo] Could not successfully update network info for descriptor <CTServiceDescriptor 0x282d863a0, domain=1, instance=2> during initialization.
2019-07-09 10:11:44.825467+0700 gametitle[20035:4320760] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x10fb60050] get output frames failed, state 8196
2019-07-09 10:11:44.825502+0700 gametitle[20035:4320760] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C1.1:2][0x10fb60050] get output frames failed, state 8196
2019-07-09 10:11:44.827003+0700 gametitle[20035:4320760] TIC Read Status [1:0x0]: 1:57
2019-07-09 10:11:44.827021+0700 gametitle[20035:4320760] TIC Read Status [1:0x0]: 1:57
2019-07-09 10:11:44.827071+0700 gametitle[20035:4320760] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x10fcb61a0] get output frames failed, state 8196
2019-07-09 10:11:44.827793+0700 gametitle[20035:4320762] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x282d863c0, domain=1, instance=1>
2019-07-09 10:11:44.828153+0700 gametitle[20035:4320760] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C2.1:2][0x10fcb61a0] get output frames failed, state 8196
2019-07-09 10:11:44.828517+0700 gametitle[20035:4320762] [NetworkInfo] Signal strength query returned error: Error Domain=NSPOSIXErrorDomain Code=13 "Permission denied", descriptor: <CTServiceDescriptor 0x282d863a0, domain=1, instance=2>
2019-07-09 10:11:44.829897+0700 gametitle[20035:4320760] TIC Read Status [2:0x0]: 1:57
2019-07-09 10:11:44.829907+0700 gametitle[20035:4320760] TIC Read Status [2:0x0]: 1:57
2019-07-09 10:11:44.830863+0700 gametitle[20035:4320765] I/UnityAds: -[USRVInitializeStateConfig execute] (line:167) :: Unity Ads init: load configuration from https://config.unityads.unity3d.com/webview/3.1.0/release/config.json
2019-07-09 10:11:44.926640+0700 gametitle[20035:4320587] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x10fb54e00] get output frames failed, state 8196
2019-07-09 10:11:44.926683+0700 gametitle[20035:4320587] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C6.1:2][0x10fb54e00] get output frames failed, state 8196
2019-07-09 10:11:44.926770+0700 gametitle[20035:4320587] TIC Read Status [6:0x0]: 1:57
2019-07-09 10:11:44.926779+0700 gametitle[20035:4320587] TIC Read Status [6:0x0]: 1:57
Using configuration builder objects
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(Object)
UnityEngine.Purchasing.StoreCatalogImpl:handleCachedCatalog(Action`1)
UnityEngine.Purchasing.<>c__DisplayClass10_0:<FetchProducts>b__1(String)
System.Action`1:Invoke(T)
UnityEngine.Purchasing.<Process>d__4:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

(Filename: ./Runtime/Export/Debug.bindings.h Line: 45)

2019-07-09 10:11:45.033545+0700 gametitle[20035:4320446] UnityIAP: Requesting 9 products
2019-07-09 10:11:45.033923+0700 gametitle[20035:4320446] UnityIAP: Requesting product data...
2019-07-09 10:11:45.065621+0700 gametitle[20035:4320762] I/UnityAds: -[USRVInitializeStateLoadWeb execute] (line:236) :: Unity Ads init: loading webapp from https://webview.unityads.unity3d.com/webview/3.1.0/437c309040cf0337b5b2f01b0da802c1d0c028c8/release/index.html
2019-07-09 10:11:45.098913+0700 gametitle[20035:4320760] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C10.1:2][0x11c18f840] get output frames failed, state 8196
2019-07-09 10:11:45.098953+0700 gametitle[20035:4320760] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C10.1:2][0x11c18f840] get output frames failed, state 8196
2019-07-09 10:11:45.099042+0700 gametitle[20035:4320760] TIC Read Status [10:0x0]: 1:57
2019-07-09 10:11:45.099051+0700 gametitle[20035:4320760] TIC Read Status [10:0x0]: 1:57
2019-07-09 10:11:45.202734+0700 gametitle[20035:4320600] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C7.1:2][0x10fc10d20] get output frames failed, state 8196
2019-07-09 10:11:45.202795+0700 gametitle[20035:4320600] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C7.1:2][0x10fc10d20] get output frames failed, state 8196
2019-07-09 10:11:45.202935+0700 gametitle[20035:4320600] TIC Read Status [7:0x0]: 1:57
2019-07-09 10:11:45.202949+0700 gametitle[20035:4320600] TIC Read Status [7:0x0]: 1:57
2019-07-09 10:11:45.369770+0700 gametitle[20035:4320761] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C14.1:2][0x11bce9590] get output frames failed, state 8196
2019-07-09 10:11:45.369947+0700 gametitle[20035:4320761] [BoringSSL] nw_protocol_boringssl_get_output_frames(1301) [C14.1:2][0x11bce9590] get output frames failed, state 8196
2019-07-09 10:11:45.370331+0700 gametitle[20035:4320761] TIC Read Status [14:0x0]: 1:57
2019-07-09 10:11:45.370367+0700 gametitle[20035:4320761] TIC Read Status [14:0x0]: 1:57
2019-07-09 10:11:45.568275+0700 gametitle[20035:4320446] Uncaught exception: NSInvalidArgumentException: *** -[__NSSetM addObject:]: object cannot be nil
(
    0   CoreFoundation                      0x00000001a327a3c0 <redacted> + 256
    1   libobjc.A.dylib                     0x00000001a247fd00 objc_exception_throw + 60
    2   CoreFoundation                      0x00000001a31f1870 _CFArgv + 0
    3   CoreFoundation                      0x00000001a31648fc <redacted> + 788
    4   gametitle                        0x0000000104b3504c +[FBSDKInternalUtility extractPermissionsFromResponse:grantedPermissions:declinedPermissions:expiredPermissions:] + 484
    5   gametitle                        0x0000000104b191c0 __75+[FBSDKGraphRequestPiggybackManager addRefreshPiggyback:permissionHandler:]_block_invoke.89 + 272
    6   gametitle                        0x0000000104b55ff4 -[FBSDKGraphRequestMetadata invokeCompletionHandlerForConnection:withResults:error:] + 152
    7   gametitle                        0x0000000104b5eed8 __82-[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:]_block_invoke + 160
    8   gametitle                        0x0000000104b5edbc -[FBSDKGraphRequestConnection processResultBody:error:metadata:canNotifyDelegate:] + 688
    9   gametitle                        0x0000000104b5e96c __64-[FBSDKGraphRequestConnection completeWithResults:networkError:]_block_invoke + 400
    10  CoreFoundation                      0x00000001a315e044 <redacted> + 232
    11  gametitle                        0x0000000104b5e710 -[FBSDKGraphRequestConnection completeWithResults:networkError:] + 540
    12  gametitle                        0x0000000104b5da5c -[FBSDKGraphRequestConnection completeFBSDKURLSessionWithResponse:data:networkError:] + 940
    13  gametitle                        0x0000000104b5ba44 __36-[FBSDKGraphRequestConnection start]_block_invoke_2 + 80
    14  libdispatch.dylib                   0x00000001a2c88304 <redacted> + 32
    15  libdispatch.dylib                   0x00000001a2c89884 <redacted> + 20
    16  libdispatch.dylib                   0x00000001a2c9573c _dispatch_main_queue_callback_4CF + 1012
    17  CoreFoundation                      0x00000001a320a024 <redacted> + 16
    18  CoreFoundation                      0x00000001a3204cd4 <redacted> + 1888
    19  CoreFoundation                      0x00000001a3204254 CFRunLoopRunSpecific + 452
    20  GraphicsServices                    0x00000001a5443d8c GSEventRunModal + 108
    21  UIKitCore                           0x00000001d054c4c0 UIApplicationMain + 216
    22  gametitle                        0x0000000104b6daf0 main + 212
    23  libdyld.dylib                       0x00000001a2cc0fd8 <redacted> + 4
)
(lldb) 

Try with these linker flags: -ObjC and -all_load @inxidious

@sharonreytan changing to that linker flags makes the build process throwing error:

Undefined symbols for architecture arm64: "_OBJC_CLASS_$_FIRDynamicLinks", referenced from: objc-class-ref in libFirebaseCppApp.a(invites_receiver_internal_ios_aa7b75b2efc3269e88f1077e55250e5a.o) ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I just integrated fbsdk 7.17.2 and published to the appstore. No crashes no mess. Exported from unity to xcode to the store easily.
Thanks @KylinChang and I hope it will be OK for everyone else on this thread

Yeah, i have updated to 7.17.2 and all my issues seemed to be resolved too.
Thanks everyone!

Was this page helpful?
0 / 5 - 0 ratings