SDKBOX IAP crash on IOS

Hello,

I am using the SDKBOX IAP library v1.5.2.6 and I encountered a crash.

To reproduce the issue in simulator, do the following:
1/ unplug your network cable.
2/ In code just add the IAP::init() like so:

bool AppDelegate::applicationDidFinishLaunching() {
	sdkbox::IAP::init();
....

3/ Start the application and wait for it to start.
4/ Connect the network cable
5/ Application crashes with the following error:

2016-01-13 12:00:13.258 klonedike-mobile[35911:964344] Reachability Flag Status: -R ------- networkStatusForFlags
2016-01-13 12:00:15.358 klonedike-mobile[35911:964344] *** Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArrayM removeObjectAtIndex:]: index 0 beyond bounds for empty array’
*** First throw call stack:
(
0 CoreFoundation 0x000000010b85be65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b22ddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010b77c2e1 -[__NSArrayM removeObjectAtIndex:] + 417
3 klonedike-mobile 0x000000010709d6a1 -[TrackingLocalStorage backgroundPendingTrackingResult:withUrl:] + 67
4 klonedike-mobile 0x000000010709d77b _ZN19TrackingURLDelegate6onLoadERKN6sdkbox14XMLHttpRequestE + 55
5 klonedike-mobile 0x00000001070ac5c3 _ZN6sdkbox14XMLHttpRequest10callOnLoadEv + 57
6 CFNetwork 0x000000010c2b0a88 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
7 CFNetwork 0x000000010c2b0a2c -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
8 CFNetwork 0x000000010c2b0b81 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
9 CFNetwork 0x000000010c11efbe ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 104
10 CFNetwork 0x000000010c20c965 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 100
11 libdispatch.dylib 0x000000010c92949b _dispatch_client_callout + 8
12 libdispatch.dylib 0x000000010c90b54b _dispatch_block_invoke + 716
13 CFNetwork 0x000000010c10b1ac _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24
14 CoreFoundation 0x000000010b75aee4 CFArrayApplyFunction + 68
15 CFNetwork 0x000000010c10b0a5 _ZN19RunloopBlockContext7performEv + 137
16 CFNetwork 0x000000010c10af5e _ZN17MultiplexerSource7performEv + 282
17 CFNetwork 0x000000010c10ad80 _ZN17MultiplexerSource8_performEPv + 72
18 CoreFoundation 0x000000010b787a31 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
19 CoreFoundation 0x000000010b77d95c __CFRunLoopDoSources0 + 556
20 CoreFoundation 0x000000010b77ce13 __CFRunLoopRun + 867
21 CoreFoundation 0x000000010b77c828 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x000000010c088ad2 GSEventRunModal + 161
23 UIKit 0x000000010911f610 UIApplicationMain + 171
24 klonedike-mobile 0x0000000105cca294 main + 100
25 libdyld.dylib 0x000000010c95d92d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Is it possible to buy the source code for this plugin?

Thank you for any help.

Hello @kristiaan

Please update to the latest version of sdkbox.
Run this command - sdkbox update it will also update your plugins used in the project.

After that let me know, if you face any issues.
The current version is - v0.5.8.12

Best,
Pabitra

Hello,

Thank you for the reply.
I did run your command but I don’t see any modified files(GIT does not show any modified files).

/sdkbox update


|______ | \ |____/ |] | | _/
| |/ | _ |
] |____| _/ _

Copyright (c) 2015 Chukong Technologies Inc. v0.5.8.12

  1. /Users/user/Desktop/solitar/klonedike/proj.ios_mac/ios/libs/Chartboost/ChartboostExample/ChartboostExampleApp.xcodeproj/
  2. /Users/user/Desktop/solitar/klonedike/proj.ios_mac/klonedike.xcodeproj/
    type quit to abort
    Select XCODE_PROJECT_DIR : 1
    downloading package sdkbox-googleplayservices_v1.5.2.6.tar.gz

[###################################] 100%
1.5.2.6 1.5.2.6

downloading package sdkbox-iap_v1.5.2.6.tar.gz
[###################################] 100%

1.5.2.6 1.5.2.6

all packages are up to date

I think I already had the latest sdkbox since I installed it 2 days ago.
The issue remains. I am also able to reproduce it outside of simulator by starting with wifi off, turn on the app, go to settings and turn on wifi(3G not available) and go back quickly to the app, This causes the crash.

Are you unable to reproduce the issue? For me it’s 100% reproduction rate and it probably occurs when network conectivity is restored after the IAP::init() call.

Regards

I believe we fixed this issue on 1.5.3, can you use the following command to upgrade sdkbox to the staging version and give it another try?

sdkbox update --staging

Hello,

I upgraded to sdkbox 1.5.3.2 and IAP plugin 1.5.3.2 by using your command.
However the issue still occurs.
The crash seems to be caused in [TrackingLocalStorage backgroundPendingTrackingResult:withUrl:], which is a function from sdkbox, which attempts to read the first element of an empty array.

Is there any way of getting the source code for these plugins?

No internet:

2016-01-14 09:18:05.919 klonedike-mobile[39831:1058355] Reachability Flag Status: – ------- networkStatusForFlags

With internet:

2016-01-14 09:18:25.836 klonedike-mobile[39831:1058355] Reachability Flag Status: -R ------- networkStatusForFlags
2016-01-14 09:18:27.796 klonedike-mobile[39831:1058355] *** Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArrayM removeObjectAtIndex:]: index 0 beyond bounds for empty array’
*** First throw call stack:
(
0 CoreFoundation 0x0000000112e16e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001127e8deb objc_exception_throw + 48
2 CoreFoundation 0x0000000112d372e1 -[__NSArrayM removeObjectAtIndex:] + 417
3 klonedike-mobile 0x000000010e6573d1 -[TrackingLocalStorage backgroundPendingTrackingResult:withUrl:] + 67
4 klonedike-mobile 0x000000010e6574ab _ZN19TrackingURLDelegate6onLoadERKN6sdkbox14XMLHttpRequestE + 55
5 klonedike-mobile 0x000000010e6661d3 _ZN6sdkbox14XMLHttpRequest10callOnLoadEv + 57
6 CFNetwork 0x000000011386ba88 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke + 69
7 CFNetwork 0x000000011386ba2c -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
8 CFNetwork 0x000000011386bb81 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 48
9 CFNetwork 0x00000001136d9fbe ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke + 104
10 CFNetwork 0x00000001137c7965 ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 100
11 libdispatch.dylib 0x0000000113ee449b _dispatch_client_callout + 8
12 libdispatch.dylib 0x0000000113ec654b _dispatch_block_invoke + 716
13 CFNetwork 0x00000001136c61ac _ZN19RunloopBlockContext13_invoke_blockEPKvPv + 24
14 CoreFoundation 0x0000000112d15ee4 CFArrayApplyFunction + 68
15 CFNetwork 0x00000001136c60a5 _ZN19RunloopBlockContext7performEv + 137
16 CFNetwork 0x00000001136c5f5e _ZN17MultiplexerSource7performEv + 282
17 CFNetwork 0x00000001136c5d80 _ZN17MultiplexerSource8_performEPv + 72
18 CoreFoundation 0x0000000112d42a31 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
19 CoreFoundation 0x0000000112d3895c __CFRunLoopDoSources0 + 556
20 CoreFoundation 0x0000000112d37e13 __CFRunLoopRun + 867
21 CoreFoundation 0x0000000112d37828 CFRunLoopRunSpecific + 488
22 GraphicsServices 0x0000000113643ad2 GSEventRunModal + 161
23 UIKit 0x00000001106da610 UIApplicationMain + 171
24 klonedike-mobile 0x000000010d283fc4 main + 100
25 libdyld.dylib 0x0000000113f1892d start + 1
26 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Best regards

Hello @kristiaan

Have you checked this with an iOS device (not simulator)… !!
Can you check quickly and let me know if this issue still comes in a real iOS device.

I believe IAP items are checked always with real devices.
Let me know, if you face this issue with a device also, we will quickly look into the issue.

@Ibon could you help us here.

Best,
Pabitra

Hello,

As I said before:

I am also able to reproduce it outside of simulator by starting with wifi off, turn on the app, go to settings and turn on wifi(3G not available) and go back quickly to the app, This causes the crash.

Are you unable to reproduce? I am using latest Xcode and IOS sdk.

Note that, today I decided to stop being lazy and I wrote my own plugin for IOS.
So I won’t be using this sdkbox IAP for now.

Regards

Sorry for the inconvenience, we’re working to fix this issue, will update the staging build today.

Just updated our staging build to 1.5.3.3, I wasn’t able to reproduce your issue. we do test wifi on/off in each release, could be because of different device or network. can you try 1.5.3.3 on your project, and let me know if it fixes the issue?

Thanks a lot :slight_smile:

Hello,

The crash seems to be fixed in 1.5.3.3 since I am no longer able to reproduce it.

Best regards

This is a wild guess but are you using the reachablity sample code from apple with the default notification center id:

#define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"

If yes this may be the cause of your crash since there are some 3rd party libs(like StartApp) that I am using that also seem to post that message but with a diffrent object attached.

Thanks a lot for verifying the fix and a great catch, we in deed are using the default notification to detect reachability, we’ll update that in our next release.