facebook / facebook-sdk-for-unity

The facebook sdk for unity.
https://developers.facebook.com/docs/unity
Other
492 stars 257 forks source link

Crash on launch on iOS - [FBSDKGraphRequestConnection errorFromResult:request:] #208

Closed NumaNumaNuma closed 5 years ago

NumaNumaNuma commented 5 years ago

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!

sharonreytan commented 5 years ago

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?

NumaNumaNuma commented 5 years ago

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

sharonreytan commented 5 years ago

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?

NumaNumaNuma commented 5 years ago

I used the latest unity one, 7.15.1

oct-test commented 5 years ago

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

sharonreytan commented 5 years ago

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

sarebots commented 5 years ago

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

KylinChang commented 5 years ago

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

sharonreytan commented 5 years ago

@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 commented 5 years ago

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

hkilian commented 5 years ago

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

sharonreytan commented 5 years ago

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?

sarebots commented 5 years ago

It did fix the issue for me.

hkilian commented 5 years ago

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

sharonreytan commented 5 years ago

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

whogaurav commented 5 years ago

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.

julianD77 commented 5 years ago

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

Adding the _forceload 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 _forceload linker flag against the FBSDKLoginKit was not enough to stop the crash from occurring on some test devices.

Umar559 commented 5 years ago

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

KylinChang commented 5 years ago

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

happypepper commented 5 years ago

@KylinChang what about -ObjC flag?

KylinChang commented 5 years ago

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

tashfiq103 commented 5 years ago

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

inxidious commented 5 years ago

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

Anyone experiencing same issue?

sharonreytan commented 5 years ago

@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:?

inxidious commented 5 years ago

@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

KylinChang commented 5 years ago

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:?

inxidious commented 5 years ago

@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) 
sharonreytan commented 5 years ago

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

inxidious commented 5 years ago

@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)

sharonreytan commented 5 years ago

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

inxidious commented 5 years ago

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