ibm-bluemix-mobile-services/bms-clientsdk-swift-push

Carthage is crashing BMSPushClient:457

Closed this issue ยท 13 comments

After more that 6 hours of troubleshooting the above crash I decided to remove the dependency from Carthage and move it to Cocoapods. The problem was fixed.

It was crashing when didRegisterForRemoteNotificationsWithDeviceToken was calling push.registerWithDeviceToken(deviceToken: deviceToken). The crash was happening in line 457. It was consistent on every application start.

Line 457 has the following

let getRequest = Request(url: resourceURL, method: method, headers: headers, queryParameters: nil, timeout: 60)

All of the input variables were not nil and the same as the one that was running through Cocoapods

Can you provide the versions of BMSPush and BMSCore that are getting installed with Carthage, and the versions that are getting installed with Cocoapods? Also, what command line tools (found in Xcode preferences, in the Locations tab) are you using?

Apologies the post was not very descriptive. My head was exploding after all these hours of troubleshooting.

With Cocoapods I get the following:

Using BMSAnalyticsAPI (2.2.0)
Using BMSCore (2.3.1)
Using BMSFacebookAuthentication (2.0.7)
Using BMSPush (3.1.0)
Using BMSSecurity (2.0.10)
Using Bolts (1.8.4)
Using FBSDKCoreKit (4.17.0)
Using FBSDKLoginKit (4.17.0)

With Carthage I get:

*** Skipped downloading bms-clientsdk-swift-analytics-api.framework binary due to the error:
"Bad credentials"
*** Checking out bms-clientsdk-swift-analytics-api at "2.2.0"
*** Skipped downloading bms-clientsdk-swift-core.framework binary due to the error:
"Bad credentials"
*** Checking out bms-clientsdk-swift-core at "2.3.1"
*** Skipped downloading bms-clientsdk-swift-push.framework binary due to the error:
"Bad credentials"
*** Checking out bms-clientsdk-swift-push at "3.1.0"
*** Skipped downloading bms-clientsdk-swift-security.framework binary due to the error:
"Bad credentials"
*** Checking out bms-clientsdk-swift-security at "v2.0.10"

So version wise it is the same.

Command line tools are set to Xcode 8.2.1 (8C1002).

I would prefer to have everything installed through Carthage, as it precompiles everything and the compile speed gain is huge.

The last log lines are the following:

sendAnalyticsData(logType:logStringData:) in /Users/zirinisp/Documents/xcode/kitespotter/Carthage/Checkouts/bms-clientsdk-swift-push/Source/BMSPushClient.swift:916 :: Verifying previous device registration.
Message from debugger: Terminated due to signal 9

At the same time I get "Thread 1: signal SIGABRT"

Thanks @zirinisp. I reproduced the problem, and confirmed that the app is crashing with an EXC_BREAKPOINT error on this line in BMSPush:

let getRequest = Request(url: resourceURL, method: method, headers: headers, queryParameters: nil, timeout: 60)

Unfortunately, I am completely stumped on what's causing this. It works fine on Cocoapods, and I can call the same Request initializer in the app itself when using either Cocoapods or Carthage. The versions of BMSPush and BMSCore are the same in each circumstance. For some reason, the combination of installing with Carthage and initializing Request within BMSPush causes a runtime error.

At least there is a workaround: using Cocoapods instead of Carthage. Perhaps there is an unknown defect in Carthage that is causing this. You could keep an eye on their releases and update when a new version is released, in case it resolved this issue.

@AnanthaKrish Do you have any other ideas?

@AnthonyOliveri I am also trying to find out the reason for the crash. Using Cocoapods is the only workaround for this right now.

It is a very strange problem, as I also tried to created a Request in the app and it was working without any crashes.

Let me know if you have any updates and thank you for the support.

I am getting a similar crash, but on line 291 (inside public func registerWithDeviceToken(deviceToken:WithUserId:completionHandler:)):

let getRequest = Request(url: resourceURL, method: method, headers: headers, queryParameters: nil, timeout: 60)

Unfortunately, can't find out much more because:

BMSPush was compiled with optimization - stepping may behave oddly; variables may not be available.

I can't afford using CocoaPods.

Off topic: Why is the parameter label WithUserId capitalized? ;)

The framework seems to be crashing (unless optimization makes the debugger point to a different line than the one causing the actual crash) when instantiating an object of type Request.

This rings a bell because, when I do carthage update and build the frameworks, I get these warnings:

/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/BMSURLSessionUtility.swift:44:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/BMSURLSessionUtility.swift:44:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/BMSURLSessionUtility.swift:44:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/BMSURLSessionUtility.swift:44:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/BMSURLSessionUtility.swift:44:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-core/Source/Network Requests/BMSURLSessionUtility.swift:44:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture armv7
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture arm64
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture armv7
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture arm64
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/BMSURLSession.swift:294:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/BMSURLSession.swift:294:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture i386
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture x86_64
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture i386
warning: no rule to process file '/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Resources/module.modulemap' of type sourcecode.module-map for architecture x86_64
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/BMSURLSession.swift:294:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/BMSURLSession.swift:294:38: warning: 'BaseRequest' is deprecated: Please use the Request class instead.
/<Path To Project>/Carthage/Checkouts/bms-clientsdk-swift-push/Pods/BMSCore/Source/Network Requests/Request.swift:27:21: warning: 'BaseRequest' is deprecated: Please use the Request class instead.

Can anyone with knowledgeable in the framework's internals rule this out as a cause of/related to the issue?


EDIT: I'm modifying the optimization level of Release to "O0 (None)" and investigate what I can gather from the debugger... At the very least, perhaps I can print the request attributes and replicate it using my own networking library instead :-)

I believe I figured it out! The runtime error goes away when the Cocoapods dependencies are updated in the BMSPush project.

As of BMSPush version 3.1.0, the Cocoapods dependency for BMSCore is version 2.2.0: https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-swift-push/blob/3.1.0/Podfile.lock#L3

Carthage, however, is installing the latest version of BMSCore (currently 2.3.1). This is my guess as to what is happening: Carthage and Cocoapods are competing with each other within BMSPush, such that Carthage wants to use one version of BMSCore (the latest), but Cocoapods has already installed a different version (2.2.0) in the BMSPush repository. This may explain why everything works fine when installing BMSPush with Cocoapods, since Cocoapods does not in any way depend on Carthage, whereas Carthage does require dependencies installed by Cocoapods (at least in the Bluemix Mobile Services SDKs).

I confirmed this by opening the BMSPush project, updating its Cocoapods dependencies, and re-running the app with no crashes occurring.

@AnanthaKrish I noticed you already made this change in the development, and I confirmed that this issue does not occur using the code from that branch. Can you merge development into master (after testing), and release a new patch version? That should resolve this issue.

Hi
Any progress on the merge?
I guess I could modify my cartfile to pull the develop branch in the meantime, right?

@nicolas-miari ,Please do not use development branch. Will provide the fix soon. Thank you..

Understood; thank you.

Do you guys need some help? :-)

Released patch version 3.1.1