Chartboost video reward ads make my app crash on iOS! HELP!

Hi there everyone!

My app worked fine until I implemented chartboost video reward ads!

I need help figuring out what is causing the crash!

Below is where I implement the ads:

  1. –create chart boost ads
  2.  
  3. local chartboost = require “plugin.chartboost”
  4.  
  5. –The ChartBoost listener function
  6. local function chartBoostListener( event )
  7.     for k, v in pairs( event ) do
  8.         print( tostring(k)… “=”… tostring(v) )
  9.     end
  10. end
  11.  
  12. –Your Chartboost app id and signature for iOS
  13. local yourAppID = “5568b9e304b0163bf576f83d”
  14. local yourAppSignature = “02242cec3ec9b2539eb3264537c40e16934c5489”
  15.  
  16. – Initialise ChartBoost
  17. chartboost.init {
  18.         appID        = yourAppID,
  19.         appSignature = yourAppSignature, 
  20.         listener     = chartBoostListener
  21.     }
  22.  
  23. – Show an interstitial reward video ad
  24.  
  25. chartboost.show( “rewardedVideo” )
  26.  
  27. – Is the rewarded video cached?
  28. print( "Has cached rewarded video: " …tostring( chartboost.hasCachedRewardedVideo() ))
  29.  
  30.  
  31. –ensure that chart boost ads work!
  32. local function systemEvent( event )
  33.     local phase = event.phase
  34.  
  35.     if event.type == “applicationResume” then
  36.         – Start a ChartBoost session
  37.         chartboost.startSession( yourAppID, yourAppSignature )
  38.     end
  39.     
  40.     return true
  41. end
  42.  
  43. Runtime:addEventListener( “system”, systemEvent )

 

I have also added the correct plugin info in my build.settings!  Everything works fine and prints out fine on the simulator! Also the app builds fine with no errors!

 

All help is appreciated! Thanks!!!

 

-Max Goldberg

It’s difficult to say what may be wrong without the error log. What is the error you’re getting in your device log? One thing I can think of with rewarded videos is that the reward needs to be set up in the Chartboost web console, however I don’t think it should cause a crash if it isn’t.

@ingemar

Below is my console log when the crash occurs:

May 30 07:17:16 Maxs-iphone Spin[690] <Warning>: Has cached rewarded video: false

May 30 07:17:16 Maxs-iphone Spin[690] <Warning>: Runtime error

stack traceback:

?: in function <?:13>

?: in function ‘dispatchEvent’

?: in function ‘gotoScene’

?: in function <?:174>

?: in function <?:221>

May 30 07:17:16 Maxs-iphone ReportCrash[691] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)

May 30 07:17:16 Maxs-iphone ReportCrash[691] <Notice>: ReportCrash acting against PID 690

May 30 07:17:16 Maxs-iphone diagnosticd[116] <Error>: error evaluating process info - pid: 690, punique: 690

May 30 07:17:16 Maxs-iphone ReportCrash[691] <Notice>: Formulating crash report for process Spin[690]

May 30 07:17:16 Maxs-iphone com.apple.xpc.launchd[1] (UIKitApplication:com.gegelgames.spin[0x8134][690]) <Notice>: Service exited due to signal: Segmentation fault: 11

May 30 07:17:16 Maxs-iphone mediaserverd[37] <Notice>: ‘’ com.gegelgames.spin(pid = 690) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None

May 30 07:17:16 Maxs-iphone mediaserverd[37] <Notice>: ‘’ (pid = 690) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None

May 30 07:17:17 Maxs-iphone ReportCrash[691] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/Spin_2015-05-30-071716_Maxs-iphone.ips.beta

May 30 07:17:17 Maxs-iphone SpringBoard[43] <Warning>: Application ‘UIKitApplication:com.gegelgames.spin[0x8134]’ crashed.

May 30 07:17:17 Maxs-iphone assertiond[58] <Warning>: pid_suspend failed for <BKNewProcess: 0x15d49600; com.gegelgames.spin; pid: 690; hostpid: -1>: Unknown error: -1, Unknown error: -1

May 30 07:17:17 Maxs-iphone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x15d49600; com.gegelgames.spin; pid: 690; hostpid: -1> to 2, priority: No such process

May 30 07:17:17 Maxs-iphone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x15d49600; com.gegelgames.spin; pid: 690; hostpid: -1> to 4096, priority: No such process

May 30 07:17:26 Maxs-iphone OTACrashCopier[692] <Notice>: (Warn ) <OTACrashCopierController.m __42-[OTACrashCopierController handleRequest:]_block_invoke:445> Creating Power Assertion for 600 secs

May 30 07:17:27 Maxs-iphone OTACrashCopier[692] <Notice>: (Warn ) <OTALogSubmissionOperation.m -[OTALogSubmissionOperation postToServer:forRouting:ofLogs:withConnection:usingParams:]:137> ‘job-1-session’ sending request of 854 bytes

I don’t know why I am getting an error because I literally copied and pasted all of the code I need from the github files on how to implement chartboost for corona sdk.  

Thanks in advance!

-Max

What’s interesting here is this:

stack traceback:

?: in function <?:13>

?: in function ‘dispatchEvent’

?: in function ‘gotoScene’

?: in function <?:174>

?: in function <?:221>

…which seems to indicate that gotoScene is involved with the crash.

One thing I’m starting to suspect is that your chartboost listener has disappeared when a callback occurs.

You should call chartboost.init() only once. For simplicity I’d recommend you put it in main.lua where also the listener should be defined. The same goes for the systemEvent function and its addEventListener (put it in main.lua).

You should then only use chartboost.cache(“rewardedVideo”), chartboost.hasCachedRewardedVideo() and chartboost.show(“rewardedVideo”) in your scenes.

@ingemar

I did exactly what you said, and the app no longer crashes!

However, the video rewards ads don’t show!
Any suggestions? Testing mode IS ON in the chart boost web console.

Thanks in advance!

-Max

If you’re still using the same chartboost listener as you posted above you should be getting a lot of info from chartboost printed in your device log. There you should be able to see any reason for ads not showing. 

@ingemar

Now, I put my statement to cache the ad in the main.lua so it gives the ad time to be ready.  

I then built for the device and it crashed 5 times before the app would run and the ad DID WORK PERFECTLY!

However, the app crashes about 5 times to get to that point which obviously isn’t good at all…

Below is my console log when the app crashes:

May 31 08:34:15 Maxs-iphone wifid[70] <Notice>: WiFi:[454768455.769765]: Client assistantd set type to normal application

May 31 08:34:15 Maxs-iphone wifid[70] <Notice>: WiFi:[454768455.774096]: __WiFiManagerSetEnableState: state TRUE, manager->enable.setting TRUE, manager->unlockedSinceBoot TRUE

May 31 08:34:15 Maxs-iphone wifid[70] <Notice>: WiFi:[454768455.776139]: BG Application: Not Present, BG Daemon: Present. Daemons: itunesstored networkd apsd 

May 31 08:34:16 Maxs-iphone kernel[0] <Notice>: xpcproxy[602] Container: /private/var/mobile/Containers/Data/Application/43A2808D-1120-4518-AA5F-A435856DBF8C (sandbox)

May 31 08:34:16 Maxs-iphone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0

May 31 08:34:16 Maxs-iphone Spin[602] <Error>: assertion failed: 12F70: libxpc.dylib + 51915 [8DB46991-F182-35E3-8E95-918A4007AA7A]: 0x7d

May 31 08:34:16 Maxs-iphone Unknown[602] <Error>: 

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: Platform: iPhone / iPhone5,2 / 8.3 / PowerVR SGX 543 / OpenGL ES 2.0 IMGSGX543-115.5 / 2015.2625

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: type=rewardedVideo

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: Runtime error

attempt to concatenate a function value

stack traceback:

C: in function ‘print’

?: in function <?:20>

?: in main chunk

C: in function ‘require’

?: in function ‘require’

?: in main chunk

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: type=rewardedVideoindex a string value=nil

May 31 08:34:16 Maxs-iphone ReportCrash[603] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)

May 31 08:34:16 Maxs-iphone ReportCrash[603] <Notice>: ReportCrash acting against PID 602

May 31 08:34:17 Maxs-iphone ReportCrash[603] <Notice>: Formulating crash report for process Spin[602]

May 31 08:34:17 Maxs-iphone SpringBoard[43] <Warning>: BSXPCMessage received error for message: Connection invalid

May 31 08:34:17 Maxs-iphone com.apple.xpc.launchd[1] (UIKitApplication:com.gegelgames.spin[0xa7cb][602]) <Notice>: Service exited due to signal: Segmentation fault: 11

May 31 08:34:17 Maxs-iphone wifid[70] <Notice>: WiFi:[454768457.141870]: BG Application: Not Present, BG Daemon: Present. Daemons: itunesstored networkd apsd 

May 31 08:34:17 Maxs-iphone ReportCrash[603] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/Spin_2015-05-31-083416_Maxs-iphone.ips.beta

May 31 08:34:17 Maxs-iphone SpringBoard[43] <Warning>: Application ‘UIKitApplication:com.gegelgames.spin[0xa7cb]’ crashed.

I don’t know what the stack traceback is telling me in all honesty, but I think that is the cause of the crashing.  

As you can see the log reads, “type = rewardedVideo” and then I get the runtime error.

Thanks for you help already and I can’t wait to figure this out!

-Max

It seems like chartboost is returning values that can’t be printed directly. The chartboost listener in the sample app is *very* basic and doesn’t have any value or type checking as it wasn’t intended to be used elsewhere.

In the mean time, for a quick test, you can replace the whole for loop in the chartboost listener with:
print(event.type)
print(event.response)
print(event.location)
print(event.info)

That should get rid of any crashes and will also give you some output with useful debugging info, but it should be replaced with more meaningful handling before your app goes live.

I’d recommend that you check out the ‘Listener events’ section from the docs to determine which events you want to handle:
https://github.com/swipeware/CoronaChartboostPlugin/blob/modernized/docs/init.markdown

@ingemar works great! Thanks a lot!

It’s difficult to say what may be wrong without the error log. What is the error you’re getting in your device log? One thing I can think of with rewarded videos is that the reward needs to be set up in the Chartboost web console, however I don’t think it should cause a crash if it isn’t.

@ingemar

Below is my console log when the crash occurs:

May 30 07:17:16 Maxs-iphone Spin[690] <Warning>: Has cached rewarded video: false

May 30 07:17:16 Maxs-iphone Spin[690] <Warning>: Runtime error

stack traceback:

?: in function <?:13>

?: in function ‘dispatchEvent’

?: in function ‘gotoScene’

?: in function <?:174>

?: in function <?:221>

May 30 07:17:16 Maxs-iphone ReportCrash[691] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)

May 30 07:17:16 Maxs-iphone ReportCrash[691] <Notice>: ReportCrash acting against PID 690

May 30 07:17:16 Maxs-iphone diagnosticd[116] <Error>: error evaluating process info - pid: 690, punique: 690

May 30 07:17:16 Maxs-iphone ReportCrash[691] <Notice>: Formulating crash report for process Spin[690]

May 30 07:17:16 Maxs-iphone com.apple.xpc.launchd[1] (UIKitApplication:com.gegelgames.spin[0x8134][690]) <Notice>: Service exited due to signal: Segmentation fault: 11

May 30 07:17:16 Maxs-iphone mediaserverd[37] <Notice>: ‘’ com.gegelgames.spin(pid = 690) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None

May 30 07:17:16 Maxs-iphone mediaserverd[37] <Notice>: ‘’ (pid = 690) setting DiscoveryMode = DiscoveryMode_None, currentDiscoveryMode = DiscoveryMode_None

May 30 07:17:17 Maxs-iphone ReportCrash[691] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/Spin_2015-05-30-071716_Maxs-iphone.ips.beta

May 30 07:17:17 Maxs-iphone SpringBoard[43] <Warning>: Application ‘UIKitApplication:com.gegelgames.spin[0x8134]’ crashed.

May 30 07:17:17 Maxs-iphone assertiond[58] <Warning>: pid_suspend failed for <BKNewProcess: 0x15d49600; com.gegelgames.spin; pid: 690; hostpid: -1>: Unknown error: -1, Unknown error: -1

May 30 07:17:17 Maxs-iphone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x15d49600; com.gegelgames.spin; pid: 690; hostpid: -1> to 2, priority: No such process

May 30 07:17:17 Maxs-iphone assertiond[58] <Warning>: Could not set priority of <BKNewProcess: 0x15d49600; com.gegelgames.spin; pid: 690; hostpid: -1> to 4096, priority: No such process

May 30 07:17:26 Maxs-iphone OTACrashCopier[692] <Notice>: (Warn ) <OTACrashCopierController.m __42-[OTACrashCopierController handleRequest:]_block_invoke:445> Creating Power Assertion for 600 secs

May 30 07:17:27 Maxs-iphone OTACrashCopier[692] <Notice>: (Warn ) <OTALogSubmissionOperation.m -[OTALogSubmissionOperation postToServer:forRouting:ofLogs:withConnection:usingParams:]:137> ‘job-1-session’ sending request of 854 bytes

I don’t know why I am getting an error because I literally copied and pasted all of the code I need from the github files on how to implement chartboost for corona sdk.  

Thanks in advance!

-Max

What’s interesting here is this:

stack traceback:

?: in function <?:13>

?: in function ‘dispatchEvent’

?: in function ‘gotoScene’

?: in function <?:174>

?: in function <?:221>

…which seems to indicate that gotoScene is involved with the crash.

One thing I’m starting to suspect is that your chartboost listener has disappeared when a callback occurs.

You should call chartboost.init() only once. For simplicity I’d recommend you put it in main.lua where also the listener should be defined. The same goes for the systemEvent function and its addEventListener (put it in main.lua).

You should then only use chartboost.cache(“rewardedVideo”), chartboost.hasCachedRewardedVideo() and chartboost.show(“rewardedVideo”) in your scenes.

@ingemar

I did exactly what you said, and the app no longer crashes!

However, the video rewards ads don’t show!
Any suggestions? Testing mode IS ON in the chart boost web console.

Thanks in advance!

-Max

If you’re still using the same chartboost listener as you posted above you should be getting a lot of info from chartboost printed in your device log. There you should be able to see any reason for ads not showing. 

@ingemar

Now, I put my statement to cache the ad in the main.lua so it gives the ad time to be ready.  

I then built for the device and it crashed 5 times before the app would run and the ad DID WORK PERFECTLY!

However, the app crashes about 5 times to get to that point which obviously isn’t good at all…

Below is my console log when the app crashes:

May 31 08:34:15 Maxs-iphone wifid[70] <Notice>: WiFi:[454768455.769765]: Client assistantd set type to normal application

May 31 08:34:15 Maxs-iphone wifid[70] <Notice>: WiFi:[454768455.774096]: __WiFiManagerSetEnableState: state TRUE, manager->enable.setting TRUE, manager->unlockedSinceBoot TRUE

May 31 08:34:15 Maxs-iphone wifid[70] <Notice>: WiFi:[454768455.776139]: BG Application: Not Present, BG Daemon: Present. Daemons: itunesstored networkd apsd 

May 31 08:34:16 Maxs-iphone kernel[0] <Notice>: xpcproxy[602] Container: /private/var/mobile/Containers/Data/Application/43A2808D-1120-4518-AA5F-A435856DBF8C (sandbox)

May 31 08:34:16 Maxs-iphone locationd[64] <Notice>: Gesture EnabledForTopCLient: 0, EnabledInDaemonSettings: 0

May 31 08:34:16 Maxs-iphone Spin[602] <Error>: assertion failed: 12F70: libxpc.dylib + 51915 [8DB46991-F182-35E3-8E95-918A4007AA7A]: 0x7d

May 31 08:34:16 Maxs-iphone Unknown[602] <Error>: 

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: Platform: iPhone / iPhone5,2 / 8.3 / PowerVR SGX 543 / OpenGL ES 2.0 IMGSGX543-115.5 / 2015.2625

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: type=rewardedVideo

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: Runtime error

attempt to concatenate a function value

stack traceback:

C: in function ‘print’

?: in function <?:20>

?: in main chunk

C: in function ‘require’

?: in function ‘require’

?: in main chunk

May 31 08:34:16 Maxs-iphone Spin[602] <Warning>: type=rewardedVideoindex a string value=nil

May 31 08:34:16 Maxs-iphone ReportCrash[603] <Error>: task_set_exception_ports(B07, 400, D03, 0, 0) failed with error (4: (os/kern) invalid argument)

May 31 08:34:16 Maxs-iphone ReportCrash[603] <Notice>: ReportCrash acting against PID 602

May 31 08:34:17 Maxs-iphone ReportCrash[603] <Notice>: Formulating crash report for process Spin[602]

May 31 08:34:17 Maxs-iphone SpringBoard[43] <Warning>: BSXPCMessage received error for message: Connection invalid

May 31 08:34:17 Maxs-iphone com.apple.xpc.launchd[1] (UIKitApplication:com.gegelgames.spin[0xa7cb][602]) <Notice>: Service exited due to signal: Segmentation fault: 11

May 31 08:34:17 Maxs-iphone wifid[70] <Notice>: WiFi:[454768457.141870]: BG Application: Not Present, BG Daemon: Present. Daemons: itunesstored networkd apsd 

May 31 08:34:17 Maxs-iphone ReportCrash[603] <Notice>: Saved report to /var/mobile/Library/Logs/CrashReporter/Spin_2015-05-31-083416_Maxs-iphone.ips.beta

May 31 08:34:17 Maxs-iphone SpringBoard[43] <Warning>: Application ‘UIKitApplication:com.gegelgames.spin[0xa7cb]’ crashed.

I don’t know what the stack traceback is telling me in all honesty, but I think that is the cause of the crashing.  

As you can see the log reads, “type = rewardedVideo” and then I get the runtime error.

Thanks for you help already and I can’t wait to figure this out!

-Max

It seems like chartboost is returning values that can’t be printed directly. The chartboost listener in the sample app is *very* basic and doesn’t have any value or type checking as it wasn’t intended to be used elsewhere.

In the mean time, for a quick test, you can replace the whole for loop in the chartboost listener with:
print(event.type)
print(event.response)
print(event.location)
print(event.info)

That should get rid of any crashes and will also give you some output with useful debugging info, but it should be replaced with more meaningful handling before your app goes live.

I’d recommend that you check out the ‘Listener events’ section from the docs to determine which events you want to handle:
https://github.com/swipeware/CoronaChartboostPlugin/blob/modernized/docs/init.markdown