BranchMetrics / unity-branch-deep-linking-attribution

The Branch Unity SDK for deep linking and attribution. Branch helps mobile apps grow with deep links / deeplinks that power paid acquisition and re-engagement campaigns, referral programs, content sharing, deep linked emails, smart banners, custom user onboarding, and more.
https://docs.branch.io/apps/unity/
MIT License
118 stars 25 forks source link

IOS App Crashes on launch when opened first by a Branch link #104

Closed mahdiRemal closed 7 years ago

mahdiRemal commented 7 years ago

In the latest Unity Branch commit V0.3.24 "the one that fixed IOS @/# import bug"

When an App is being first opened by a Branch link in IOS, it crashes. When an App is being sent to foreground after being suspended, it functions correctly.

"OurApp" is the name of our game app //////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////Error log////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////

Thread 0 (crashed)
0   libsystem_kernel.dylib      >>>>>        __pthread_kill 
1   libsystem_c.dylib        >>>>>           abort 
2   OurApp              >>>>>              -[UnityPLCrashReporter generateLiveReportWithThread:] 
3   OurApp           >>>>>                 UncaughtExceptionHandler(NSException*) 
4   CoreFoundation           >>>>>           __handleUncaughtException 
5   libobjc.A.dylib          >>>>>           _objc_terminate() 
6   libc++abi.dylib          >>>>>           std::__terminate(void (*)()) 
7   libc++abi.dylib          >>>>>           __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*) 
8   libobjc.A.dylib          >>>>>           _objc_exception_destructor(void*) 
9   CoreFoundation         >>>>>             -[NSException initWithCoder:] 
10  OurApp                >>>>>            +[Branch setBranchKey:] 
11  OurApp               >>>>>             +[Branch getInstance:] 
12  OurApp            >>>>>                -[BranchUnityWrapper continueUserActivity:] 
13  OurApp            >>>>>                -[BranchAppController application:continueUserActivity:restorationHandler:] 
14  UIKit                >>>>>               -[UIApplication activityContinuationManager:continueUserActivity:] 
15  UIKit              >>>>>                 -[UIActivityContinuationManager _continueUserActivity:] 
16  UIKit               >>>>>                __72-[UIActivityContinuationManager handleActivityContinuation:isSuspended:]_block_invoke_3 
17  UIKit               >>>>>                -[_UIApplicationModalProgressController _callAndClearDismissalHandlerWasDismissedByUser:] 
18  UIKit              >>>>>                 -[_UIApplicationModalProgressController hideAfterMinimumUptimeWithDismissalHandler:] 
19  UIKit              >>>>>                 -[UIApplication activityContinuationManager:hideProgressUIWithCompletion:] 
20  UIKit              >>>>>                 -[UIActivityContinuationManager _endCurrentActivityContinuationWithCompletion:] 
21  UIKit               >>>>>                __72-[UIActivityContinuationManager handleActivityContinuation:isSuspended:]_block_invoke_2 
22  libdispatch.dylib       >>>>>            _dispatch_call_block_and_release 
23  libdispatch.dylib       >>>>>            _dispatch_client_callout 
24  libdispatch.dylib        >>>>>           _dispatch_main_queue_callback_4CF$VARIANT$mp 
25  CoreFoundation         >>>>>             __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 
26  CoreFoundation        >>>>>              __CFRunLoopRun 
27  CoreFoundation         >>>>>             CFRunLoopRunSpecific 
28  GraphicsServices      >>>>>              GSEventRunModal 
29  UIKit           >>>>>                    UIApplicationMain 
30  OurApp         >>>>>                   main 
31  libdyld.dylib       >>>>>                start 

//////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////End of log////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////

The issue holds with Unity Branch Demo.

antonargunov commented 7 years ago

@mahdiRemal , what Unity3d version do you use?

mahdiRemal commented 7 years ago

Unity 5.6.2f1

shirkan commented 7 years ago

+1, i'm seeing this too. Unity 5.6.1f1 xcode 8.3.3

antonargunov commented 7 years ago

@mahdiRemal , @shirkan check please your Branch prefab, I was able to reproduce that issue when I set prefab fields with empty values.

shirkan commented 7 years ago

My branch prefab isn't empty, attaching images of the prefab and the BranchData.asset. image image

mahdiRemal commented 7 years ago

I have the same fields filled in Branch prefab as @shirkan, Unity 5.6.2f1, and I'm using Xcode V9.0

antonargunov commented 7 years ago

@mahdiRemal , @shirkan something strange happens, I have no this issue, try please delete IOS build and make new from scratch

I am going to create new project from scratch, may be I will be able to catch this issue.

antonargunov commented 7 years ago

Also, can you describe me your steps to reproduce that issue?

My steps: 1) Click Branch link 2) Start building and running from xcode 3) Then I move the app to background and click link again 4) Then I close the app and click link again

antonargunov commented 7 years ago

I created new project with Branch plugin, all is ok. Unity 5.6.2f1 + xcode 9

shirkan commented 7 years ago

I'm using unity cloud build, not local building

shirkan commented 7 years ago

I experience the crash after the app is already installed and NOT open. I click on a branch link in my iOS device and the app is starting, but crashing only after a few seconds.

antonargunov commented 7 years ago

let's try this way: 1) open Branch.cs 2) goto row 411 3) comment that rows if (BranchData.Instance.testMode) { _setBranchKey(BranchData.Instance.testBranchKey); } else { _setBranchKey(BranchData.Instance.liveBranchKey); }

shirkan commented 7 years ago

@antonargunov This makes the app crash even when starting it normally, without clicking a branch link.

mahdiRemal commented 7 years ago

commenting the lines in Branch.cs

if (BranchData.Instance.testMode) {
_setBranchKey(BranchData.Instance.testBranchKey);
}
else {
_setBranchKey(BranchData.Instance.liveBranchKey);
}

causes the app to crash at launch in all cases, just like what @shirkan commented.

I've tried to Delete All Branch files and reimport using the unity package, this too didn't solve the problem, and the same crash with first time open through branch link occurs.

And finally, I've tried to build a clean empty unity project and only included Branch unity package. and I still experience the same issue of crash in first launch through branch link.

So to generate the crash:

make sure the app is not running in the background ["double tap the home button" in most iphones, in IphoneX "swipe up from the bottom of the screen" to see the list of background suspended apps, and swipe up to dismiss/close the app that is running], now sense the app is not running in the background, simply trigger its open from a branch link, and the crash should occur.

Tested on iPhone 5s, IOS 11.0.1, Unity 5.6.2f1, and Xcode 9.0, using whatsapp application as the app that contains the branch link that will open the unity project with branch package.

here is another log unmodified generated from the empty Unity App with only branch package: the device name used is "Kammelna’s iPhone"

Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Notice: This report is abbreviated for syslog inclusion because it could not be saved to disk.
Symbolication may be possible by manually cleaning up and including the Binary Image section of a full report from this same device -- good luck!
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Process:             kammelna [1821]
Path:                /private/var/containers/Bundle/Application/3B5338AE-4C4B-4094-ACAE-717CA59723DE/kammelna.app/kammelna
OS Version:          iPhone OS 11.0.1 (15A402)
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Triggered by Thread:  0
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Application Specific Information:
abort() called
Oct 19 13:28:19 Kammelnas-iPhone SpringBoard(SplashBoard)[53] <Notice>: [net.whatsapp.WhatsApp] Snapshot data for <XBApplicationSnapshot: 0x13764ff20; \M-b\M^@\M-&958DB75F9B5F> written to file: /private/var/mobile/Containers/Data/Application/11F36BD8-A96D-4C70-8956-50B56642A051/Library/Caches/Snapshots/net.whatsapp.WhatsApp/downscaled/8BE28401-72A9-406C-94A0-958DB75F9B5F@2x.png
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x0000000181f75348 0x181f54000 + 136008
1   libsystem_pthread.dylib         0x0000000182089354 0x182086000 + 13140
2   libsystem_c.dylib               0x0000000181ee4fd8 0x181e82000 + 405464
3   libc++abi.dylib                 0x0000000181948068 0x181946000 + 8296
4   libc++abi.dylib                 0x0000000181948210 0x181946000 + 8720
5   libobjc.A.dylib                 0x0000000181970810 0x181968000 + 34832
6   libc++abi.dylib                 0x000000018196054c 0x181946000 + 107852
7   libc++abi.dylib                 0x000000018195fea8 0x181946000 + 106152
8   libobjc.A.dylib                 0x000000018197065c 0x181968000 + 34396
9   CoreFoundation                  0x000000018245bc80 0x18231a000 + 1318016
10  kammelna                        0x000000010100f93c 0x100cb0000 + 3537212
11  kammelna                        0x000000010100eb68 0x100cb0000 + 3533672
12  kammelna                        0x0000000101<\M-b\M^@\M-&>
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 1:
0   libsystem_pthread.dylib         0x0000000182086c2c 0x182086000 + 3116
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 2:
0   libsystem_kernel.dylib          0x0000000181f75dbc 0x181f54000 + 138684
1   libsystem_pthread.dylib         0x0000000182086fb0 0x182086000 + 4016
2   libsystem_pthread.dylib         0x0000000182086c30 0x182086000 + 3120
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 3:
0   libsystem_kernel.dylib          0x0000000181f75dbc 0x181f54000 + 138684
1   libsystem_pthread.dylib         0x0000000182086fb0 0x182086000 + 4016
2   libsystem_pthread.dylib         0x0000000182086c30 0x182086000 + 3120
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 4:
0   libsystem_pthread.dylib         0x0000000182086c2c 0x182086000 + 3116
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 5:
0   libsystem_pthread.dylib         0x0000000182086c2c 0x182086000 + 3116
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 6 name:  com.apple.uikit.eventfetch-thread
Thread 6:
0   libsystem_kernel.dylib          0x0000000181f54bc4 0x181f54000 + 3012
1   libsystem_kernel.dylib          0x0000000181f54a3c 0x181f54000 + 2620
2   CoreFoundation                  0x0000000182403ce4 0x18231a000 + 957668
3   CoreFoundation                  0x00000001824018b0 0x18231a000 + 948400
4   CoreFoundation                  0x00000001823222d8 0x18231a000 + 33496
5   Foundation                      0x0000000182d4a6e4 0x182d3e000 + 50916
6   Foundation                      0x0000000182d69afc 0x182d3e000 + 178940
7   UIKit                           0x000000018c41b02c 0x18b85c000 + 12316716
8   Foundation                      0x0000000182e4b860 0x182d3e000 + 1103968
9   libsystem_pthread.dylib         0x000000018208832c 0x182086000 + 9004
10  libsystem_pthread.dylib         0x00000001820881f8 0x182086000 + 8696
11  libsystem_pthread.dylib         0x0000000182086c38 0x182086000 + 3128
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 7 name:  GC Finalizer
Thread 7:
0   libsystem_kernel.dylib          0x0000000181f75150 0x181f54000 + 135504
1   libsystem_pthread.dylib         0x000000018208ad40 0x182086000 + 19776
2   kammelna                        0x00000001015a3ac0 0x100cb0000 + 9386688
3   kammelna                        0x0000000101589d84 0x100cb0000 + 9280900
4   kammelna                        0x00000001015a082c 0x100cb0000 + 9373740
5   kammelna                        0x00000001015a4200 0x100cb0000 + 9388544
6   libsystem_pthread.dylib         0x000000018208832c 0x182086000 + 9004
7   libsystem_pthread.dylib         0x00000001820881f8 0x182086000 + 8696
8   libsystem_pthread.dylib         0x0000000182086c38 0x182086000 + 3128
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 8 name:  BatchDeleteObjects
Thread 8:
0   libsystem_kernel.dylib          0x0000000181f54c00 0x181f54000 + 3072
1   libdispatch.dylib               0x0000000181de33d4 0x181de0000 + 13268
2   libdispatch.dylib               0x0000000181de3d84 0x181de0000 + 15748
3   kammelna                        0x00000001012b266c 0x100cb0000 + 6301292
4   kammelna                        0x00000001011f7b20 0x100cb0000 + 5536544
5   kammelna                        0x00000001012b1bbc 0x100cb0000 + 6298556
6   libsystem_pthread.dylib         0x000000018208832c 0x182086000 + 9004
7   libsystem_pthread.dylib         0x00000001820881f8 0x182086000 + 8696
8   libsystem_pthread.dylib         0x0000000182086c38 0x182086000 + 3128
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 9 name:  AsyncReadManager
Thread 9:
0   libsystem_kernel.dylib          0x0000000181f54c00 0x181f54000 + 3072
1   libdispatch.dylib               0x0000000181de33d4 0x181de0000 + 13268
2   libdispatch.dylib               0x0000000181de3d84 0x181de0000 + 15748
3   kammelna                        0x000000010110a804 0x100cb0000 + 4564996
4   kammelna                        0x000000010110a5bc 0x100cb0000 + 4564412
5   kammelna                        0x00000001012b1bbc 0x100cb0000 + 6298556
6   libsystem_pthread.dylib         0x000000018208832c 0x182086000 + 9004
7   libsystem_pthread.dylib         0x00000001820881f8 0x182086000 + 8696
8   libsystem_pthread.dylib         0x0000000182086c38 0x182086000 + 3128
Oct 19 13:28:19 Kammelnas-iPhone ReportCrash(CrashReporterSupport)[1822] <Notice>: Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x0000000000000000   x1: 0x0000000000000000   x2: 0x0000000000000000   x3: 0x00000001c40f25b7
    x4: 0x0000000181965afd   x5: 0x000000016f14d300   x6: 0x000000000000006e   x7: 0xffffffffffffffec
    x8: 0x0000000008000000   x9: 0x0000000004000000  x10: 0x000000018208d63c  x11: 0x0000000000000003
   x12: 0xffffffffffffffff  x13: 0x0000000000000001  x14: 0x0000000181efb557  x15: 0x0000000000000010
   x16: 0x0000000000000148  x17: 0x00000000ffffffff  x18: 0x0000000000000000  x19: 0x0000000000000006
   x20: 0x00000001b2e1bb80  x21: 0x000000016f14d300  x22: 0x0000000000000303  x23: 0x00000001b2e1bc60
   x24: 0x00000001b2e1bc60  x25: 0x0000000000000014  x26: 0x00000001c0461f00  x27: 0x0000000000000000
   x28: 0x0000000002ffffff   fp: 0x000000016f14d260   lr: 0x0000000182089354
    sp: 0x000000016f14d230   pc: 0x0000000181f75348 cpsr: 0x00000000
Oct 19 13:28:19 Kammelnas-iPhone callservicesd[127] <Notice>: Updated isRunning for <private> because new application state is 4
Oct 19 13:28:19 Kammelnas-iPhone homed(HomeKitDaemon)[149] <Notice>: Received app state changed with info {
    BKSApplicationStateAppIsFrontmost = 0;
    BKSApplicationStateExtensionKey = 0;
    SBApplicationStateDisplayIDKey = "net.whatsapp.WhatsApp";
    SBApplicationStateKey = 4;
    SBApplicationStateProcessIDKey = 1779;
    SBApplicationStateRunningReasonsKey =     (
                {
            SBApplicationStateRunningReasonAssertionIdentifierKey = "FBSceneSnapshotAction:net.whatsapp.WhatsApp";
            SBApplicationStateRunningReasonAssertionReasonKey = 4;
        },
                {
            SBApplicationStateRunningReasonAssertionIdentifierKey = Suspending;
            SBApplicationStateRunningReasonAssertionReasonKey = 10001;
        },
                {
            SBApplicationStateRunningReasonAssertionIdentifierKey = "Called by UIKit, from <redacted>";
            SBApplicationStateRunningReasonAssertionReasonKey = 4;
        },
                {
            SBApplicationStateRunningReasonAssertionIdentifierKey = "Called by UIKit, from <redacted>";
            SBApplicationStateRunningReasonAssertionReasonKey = 4;
        },
                {
            SBApplicationStateRunningReasonAssertionIdentifierKey = "Called by UIKit, from <redacted>";
            SBApplicationStateRunningReasonAssertionReasonKey = 4;
        }
    );
    SBMostElevatedStateForProcessID = 4;
}
antonargunov commented 7 years ago

@mahdiRemal , delete your branch key etc. and send me please your "empty" project

antonargunov commented 7 years ago

@mahdiRemal , @shirkan

let's try this way:

1) Open BranchPostProcessBuild.cs 2) goto row 117 3) comment rows else if (line.Contains("CLANG_ENABLE_MODULES") ) { fCurrentXcodeProjFile.Write("\t\t\t\tCLANG_ENABLE_MODULES = YES;\n"); }

mahdiRemal commented 7 years ago

There you go @antonargunov:

https://drive.google.com/drive/folders/0ByYNJCzcr2yZUUozdFhZSlFJS1E?usp=sharing

In this shared folder there is the .zip for the compiled Xcode project "kinda useless but maybe helpful in debugging", and a .zip file for the "not too empty" Unity project with Branch Unity Package only.

I hope they help...

shirkan commented 7 years ago

@antonargunov I'll give it a try but I strongly doubt it will change something. I see that PBXProject.cs and another SDK post processor script is setting CLANG_ENABLE_MODULES to YES...

antonargunov commented 7 years ago

@mahdiRemal , thank you, I will try @shirkan , as I understood, you use Unity cloud for building, UCB had an issue with Soomla plugin (you can try to find info); that issue was because Soomla used custom compile flag in xcode project. Try please changed postprocess script with UCB.

mahdiRemal commented 7 years ago

@antonargunov, regarding your latest suggestion to:

comment rows

else if (line.Contains("CLANG_ENABLE_MODULES") ) {
fCurrentXcodeProjFile.Write("\t\t\t\tCLANG_ENABLE_MODULES = YES;\n");
}

in BranchPostProcessBuild.cs

I've tried that and it seems to have no effect on the issue, such that the same behavior before commenting the lines is exhibited.

Branch Links crash the app when they are used first to open it, and they resume the app correctly when the app is in the background.

antonargunov commented 7 years ago

@mahdiRemal , I sent a request to access to your zip file.

mahdiRemal commented 7 years ago

@antonargunov, done, sorry for the inconvenience!

shirkan commented 7 years ago

@antonargunov Just did, same result. Also, I see that the bug Soomla caused (which no longer exists for more than a year I think) was fixed in UCB. Anyways, it happens also with local build so I guess this is not the problem here.

antonargunov commented 7 years ago

@mahdiRemal , @shirkan I have no this issue in test projects from @mahdiRemal .

Something strange happens.

I will ask you to try our ios native testbed: https://github.com/BranchMetrics/ios-branch-deep-linking

shirkan commented 7 years ago

@antonargunov Please supply exact steps what to do

antonargunov commented 7 years ago

@shirkan , 1) download Branch IOS TestBed from github https://github.com/BranchMetrics/ios-branch-deep-linking 2) open Branch-TestBed.xcworkspace 3) set your params for deep linking in Branch-TestBed-Info.plist 4) build and launch

I want to check if native testbed has this issue

mahdiRemal commented 7 years ago

@antonargunov, I've downloaded Branch IOS TestBed, provided my game app key in the info.plist, and applinks: in the associated domains capability, configured the provisioning profiles to mine, and it worked perfectly...

The issue is no longer there, and I was able to open the app from branch links or resume the app from the background with no crashes. Also old links I created for the game was correctly launching the test bed.

So it seems that IOS TestBed is working fine "As Expected".

antonargunov commented 7 years ago

@mahdiRemal , thanks

antonargunov commented 7 years ago

@mahdiRemal , @shirkan try please this version of plugin https://www.dropbox.com/s/sl5ocp404exydxi/BranchUnityWrapper.unitypackage?dl=0

mahdiRemal commented 7 years ago

Hi @antonargunov, I've tried the early version "0.3.25" BranchUnityPackage you shared through Dropbox, and Sadly, the issue is still there, with no differences.

Here are some more crash analytics we record of our app, some of them may be related to this issue:

Native Crash - __pthread_kill (Unknown File)
Thread 0 (crashed)
0   libsystem_kernel.dylib              __pthread_kill 
1   libsystem_c.dylib                   abort 
2   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
3   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
4   CoreFoundation                      __handleUncaughtException 
5   libobjc.A.dylib                     _objc_terminate() 
6   libc++abi.dylib                     std::__terminate(void (*)()) 
7   libc++abi.dylib                     std::terminate() 
8   libdispatch.dylib                   _dispatch_client_callout 
9   libdispatch.dylib                   _dispatch_block_invoke_direct$VARIANT$mp 
10  FrontBoardServices                  __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ 
11  FrontBoardServices                  -[FBSSerialQueue _performNext] 
12  FrontBoardServices                  -[FBSSerialQueue _performNextFromRunLoopSource] 
13  CoreFoundation                      __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ 
14  CoreFoundation                      __CFRunLoopDoSource0 
15  CoreFoundation                      __CFRunLoopDoSources0 
16  CoreFoundation                      __CFRunLoopRun 
17  CoreFoundation                      CFRunLoopRunSpecific 
18  GraphicsServices                    GSEventRunModal 
19  UIKit                               UIApplicationMain 
20  OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
21  libdyld.dylib                       start 
Native Crash - <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> (Unknown File)
Thread 0 (crashed)
0   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
1   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
2   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
3   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
4   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
5   OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
6   UIKit                               <system symbols missing> 
7   UIKit                               <system symbols missing> 
8   libdispatch.dylib                   <system symbols missing> 
9   libdispatch.dylib                   <system symbols missing> 
10  libdispatch.dylib                   <system symbols missing> 
11  libdispatch.dylib                   <system symbols missing> 
12  libdispatch.dylib                   <system symbols missing> 
13  CoreFoundation                      __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 
14  CoreFoundation                      __CFRunLoopRun 
15  CoreFoundation                      CFRunLoopRunSpecific 
16  GraphicsServices                    GSEventRunModal 
17  UIKit                               <system symbols missing> 
18  OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
19  libdyld.dylib                       <system symbols missing> 
Native Crash - CFDictionaryGetValue (Unknown File)
Thread 0 (crashed)
0   CoreFoundation                      CFDictionaryGetValue 
1   Foundation                          _NSSetBoolValueAndNotify 
2   AVFoundation                        -[AVPlayerItem _updateVideoSuppressionOnFigPlaybackItem:basedOnOutputs:] 
3   AVFoundation                        __58-[AVPlayerItem(AVPlayerItemOutputs) _evaluateVideoOutputs]_block_invoke 
4   libdispatch.dylib                   _dispatch_call_block_and_release 
5   libdispatch.dylib                   _dispatch_client_callout 
6   libdispatch.dylib                   _dispatch_queue_serial_drain$VARIANT$mp 
7   libdispatch.dylib                   _dispatch_queue_invoke$VARIANT$mp 
8   libdispatch.dylib                   _dispatch_main_queue_callback_4CF$VARIANT$mp 
9   CoreFoundation                      __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 
10  CoreFoundation                      __CFRunLoopRun 
11  CoreFoundation                      CFRunLoopRunSpecific 
12  GraphicsServices                    GSEventRunModal 
13  UIKit                               UIApplicationMain 
14  OurApp                            <symbols missing for uuid: 4498c6d01882394fa5c1299da538bb5d> 
15  libdyld.dylib                       start 

Notice that UIKit was one of the packages that were changed with the latest “@/# import” bug… could that be related somehow?

antonargunov commented 7 years ago

@mahdiRemal try please branch plugin in empty project

shirkan commented 7 years ago

@antonargunov - I experience the same issue with SDK v0.3.25 as well.

mahdiRemal commented 7 years ago

@antonargunov, I've used the (Early access UnityBranchV0.3.25) in a new empty unity project, and the issue persists.

While trying debugging our App, I think I've found the issue in one of the logs, or at least something really close to it...

Oct 25 10:48:07 My-iPhone OurApp[2462] <Notice>: Uncaught exception: NSInternalInconsistencyException: Invalid Branch key format. Passed key is ''.
(
    0   CoreFoundation                      0x000000018245bd50 <redacted> + 148
    1   libobjc.A.dylib                     0x0000000181970528 objc_exception_throw + 56
    2   CoreFoundation                      0x000000018245bc80 <redacted> + 0
    3   OurApp                            0x000000010089f73c +[Branch setBranchKey:] + 536
    4   OurApp                            0x000000010089e968 +[Branch getInstance:] + 28
    5   OurApp                            0x0000000100898268 -[BranchUnityWrapper continueUserActivity:] + 56
    6   OurApp                            0x0000000100891d48 -[BranchAppController application:continueUserActivity:restorationHandler:] + 76
    7   UIKit                               0x000000018bad1260 <redacted> + 168
    8   UIKit                               0x000000018be34814 <redacted> + 76
    9   UIKit                               0x000000018be3558c <redacted> + 72
    10  UIKit
Oct 25 10:48:07 My-iPhone OurApp(CoreFoundation)[2462] <Notice>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid Branch key format. Passed key is ''.'
*** First throw call stack:

Branch key was read as empty... Could the problem be bound to specific branch keys? this may explain why you couldn't reproduce it... Also, it's good to note that our Branch key works fine in Unity Android, and in Native IOS... And of course it works fine in Unity IOS if the app was running in background.

Hope this log can make some progress.

shirkan commented 7 years ago

@mahdiRemal

Also, it's good to note that our Branch key works fine in Unity Android, and in Native IOS... And of course it works fine in Unity IOS if the app was running in background.

+1, exactly what I'm experiencing.

@antonargunov - is it possible this issue is related to some server-side configuration at your end? The crash is happening quite fast when trying to start the app, so I highly doubt it, but still, it might worth checking, isn't it?

antonargunov commented 7 years ago

@mahdiRemal Open please xcode project: 1) do you have "branch_key" value in plist? 2) do you have "_branchKey" value in BranchiOSWrapper.mm?

mahdiRemal commented 7 years ago

I've checked my info.plist, and it seem to include the branch_key correctly:

screen shot 2017-10-26 at 9 14 12 am

I've also checked the _branchKey value and it looks like this: screen shot 2017-10-26 at 9 11 32 am probably that wasn't helpful.

I also noticed that I had this comment from Xcode, in BranchiOSWrapper.mm : screen shot 2017-10-26 at 9 13 10 am

I'm not sure how I can debug these values at runtime, if you'd like me to do so, can you give me a brief description, if that helps...

antonargunov commented 7 years ago

@mahdiRemal 1) Open Unity3d project 2) Make some changes in Branch prefab (for example: add symbol and then delete symbol) 3) You will see two buttons "Update IOS Wrapper" and "Update Android Manifest" 4) Tap both

All will work nice. Note: or you can add value into _branchKey manually

shirkan commented 7 years ago

@antonargunov Excellent, works great for me. Please note, whenever Branch SDK is updated, these settings are overridden (also BranchData.asset). You should clearly state it in your docs, or even better, think about a way to fix it. This is an ugly pitfall for the users. Thanks for your dedicated support. Cheers.

mahdiRemal commented 7 years ago

Yep, it finally worked, The solution is rather very simple, I feel ashamed that I fell into it, even when I recreated a new branch unity project.

What made the issue worse was its symptoms "works on background, but not fresh launches".

+1 important note from @shirkan

Please note, whenever Branch SDK is updated, these settings are overridden (also BranchData.asset). You should clearly state it in your docs, or even better, think about a way to fix it. This is an ugly pitfall for the users.

Thanks a lot for your efforts with us @antonargunov, also thanks for your time and help @shirkan.

mahdiRemal commented 7 years ago

The issue is resolved.

So what we learned from this issue is that with every Branch update you do, don't forget to press on (Update IOS Wrapper). hopefully that gets automated soon.