App Crashes Right away on Device but not in the Simulator!

This is the last print statement before you crash:

May 24 15:56:33 Maxs-iphone Spin[580] <Warning>: create mute icon

What is going on in your code after that print?

Rob

@rob 

Nothing is happening after that print.  Below is my menu.lua file which is my first scene that contains all of my print statements.

[lua]–remove status bar

display.setStatusBar(display.HiddenStatusBar)

–require modules

local storyboard = require “storyboard”

local scene = storyboard.newScene()

local widget = require “widget” 

local easing = require “easing”

local facebook = require “facebook”

local fbAppID = “893514267378337”

local physics = require “physics”

physics.start()

physics.setGravity( 0, 3)

physics.setReportCollisionsInContentCoordinates( true )

–create scene

function scene:createScene( event )

local group = self.view

–menu sound effect

local menuSoundEffect = audio.loadStream(“quirk-tone.mp3”)

audio.play(menuSoundEffect, { loops = -1 } )

print(“adding menu sound effect”)

–create background

local bg = display.newRect( 150, 150, 1220, 840)

bg:setFillColor(.2, .8, 1)

group:insert(bg)

–create circle to be made into wheel

local wheel = display.newCircle(150, 100, 100)

wheel.x = display.contentCenterX; wheel.y = display.contentCenterY

wheel:scale(1.7, 1.7)

group:insert(wheel)

print(“creating circle”)

–initialize kernel to create wheel effect

local kernel = require “kernel_generator_custom_wheel”

graphics.defineEffect( kernel )

–create wheel using effect on circle

wheel.fill.effect = “generator.custom.wheel”

print(“create wheel effect”)

local function wheelAnimation()

wheel.rotation = math.random() * 360

print(“wheel animation started”)

end

timer.performWithDelay( 180, wheelAnimation, -1 )

–make game title

local title = display.newText(“SPIN”, display.contentCenterX, 20, “BebasNeueBold”, 120)

group:insert(title)

–make ‘play’ button

local playBtn = display.newRoundedRect(display.contentCenterX, display.contentCenterY, 150, 150, 20)

group:insert(playBtn)

local playText = display.newText(“PLAY”, display.contentCenterX, display.contentCenterY, “BebasNeueBold”, 70)

playText:setFillColor(0, 0, 0)

group:insert(playText)

print(“add menu objects”)

–make play button work and take user to game

local function startGame(event)

if (event.phase == “began”) then

storyboard.removeScene( “menu” )

storyboard.gotoScene( “game” )

print(“go to ‘game’ to start”)

end

end

playBtn:addEventListener( “touch”, startGame )

–create facebook icon

local facebookIcon = display.newImage( “FB-f-Logo__blue_114.png” )

facebookIcon.x = display.contentCenterX - 100; facebookIcon.y = display.contentCenterY + 235

facebookIcon:scale(.5, .5)

group:insert(facebookIcon)

print(“create facebook icon”)

–make facebook button work

local function facebookBtn(event)

if (event.phase == “began”) then

facebook.login( fbAppID, facebookListener, { “user_friends”, “email” } )

print(“facebook worked!”)

end

end

facebookIcon:addEventListener( “touch”, facebookBtn )

–review app icon

local reviewIcon = display.newRoundedRect(display.contentCenterX, display.contentCenterY + 235, 58, 60, 5) 

reviewIcon:setFillColor(.99, .6, .4)

local star = display.newImage( “imageedit_1_3872267622.gif” )

star.x = display.contentCenterX; star.y = display.contentCenterY + 235

star:scale(.25, .25)

group:insert(reviewIcon)

group:insert(star)

print(“create review app icon”)

–make review button work

local function reveiwBtn(event)

if (event.phase == “began”) then

system.openURL( “itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=XXXXXXXXX” )

–fill in XXXXXXX as app id for review page

print(“review button worked!”)

end

end

reviewIcon:addEventListener( “touch”, reveiwBtn )

–mute button icon

local muteIcon = display.newRoundedRect(display.contentCenterX + 100, display.contentCenterY + 235, 58, 60, 5)

local mute = display.newImage( “imageedit_1_8962693955.gif” )

mute.x = display.contentCenterX + 100; mute.y = display.contentCenterY + 235

mute:scale(.25, .25)

group:insert(muteIcon)

group:insert(mute)

print(“create mute icon”)

–make mute button work

local function muteBtn(event)

if (event.numTaps == 1) then

audio.stop()

elseif (event.numTaps == 2) then

audio.play(menuSoundEffect)

print(“mute worked!”)

end

end

muteIcon:addEventListener( “tap”, muteBtn )

end

–enter scene

function scene:enterScene( event )

local group = self.view

end

–exit scene

function scene:exitScene( event )

local group = self.view

end

–destroy scene

function scene:destroyScene( event )

local group = self.view

end

scene:addEventListener( “createScene”, scene)

scene:addEventListener( “enterScene”, scene)

scene:addEventListener( “exitScene”, scene)

scene:addEventListener( “destroyScene”, scene)

return scene

[/lua]

@rob

Above is my menu.la file where the crash is occurring as it is my first scene.  Thanks in advance for your help! Also, keep in mind the app worked only on the iPhone 6, not the iPhone 5 or iPad mini.

Put some more prints in after line 125, say maybe at 126, 136 and 138.  Also put a print in your enterScene function too.

Though this isn’t the cause, you do need to uncomment the CFBundleURLTypes if you expect Facebook to work on iOS. 

@rob

I added print statements to all the lines you said above…

Each and every statement prints out normally before the error and crash!  I have no idea what is wrong with it because I tested it on my friends iPhone 6 and it runs perfectly opposed to my iPhone 5 and iPad mini!  Thanks for your assistance thus far!

Hope we figure this out!

-Max

So something is happening after createScene finishes.  The only thing I see is your wheel timer.  Do me a favor and comment out the entire wheel code starting with the shader through the random rotation of it.  Perhaps there is a bug in the shader and it doesn’t like being rotated or something.

@rob

You are 100% right! I commented out the shader and rotation code and now the app runs on my devices!  However, when I press play to to go the game scene (which also contains the same shader which the user can drag to rotate it), the app crashes!  There is defiantly something wrong with the shader or the movement of it.  Any suggestions on what I should do?  Someone on the forum helped me make the shader and it works great on the simulator AND iPhone 6 and iPhone 6 plus!  So there is something very wrong here.  Thanks for the help throughout this issue.  Can’t wait to figure this out!

-Max

Yea, I don’t know shaders well at all.  You can break down the problem a bit more by creating the shader but not rotating/moving it and see if that’s okay.  Then create a new thread about the shader and hopefully someone with a lot more experience than I have can answer.

Rob

@rob 

I will do exactly what you said above.

However, I don’t understand why it works fine on an iPhone 6 or iPhone 6 plus!

If you could explain that to me or give me your theory that would be great! Thanks!

@rob  

I followed what you said to do in your latest reply and the app crashes! Something is wrong with the shader that won’t run!

Any suggestions on how to go about fixing this?

You are going to have to ask on one of the shader threads or start a new thread.  

The iPhone 6/6 Plus has more memory and a more advanced GPU which could explain the issue on the older devices, but still the iPhone 5 and iPad Mini 2 are not very old.

Rob

@rob

Nobody is responding to any of my posts about my problem! :frowning:

Any suggestions?  The app works on an iPhone 6 and iPhone 6 plus but nothing lower…

Might I suggest changing the title of your post to something like “Custom shader crashing with segment violation” that better describe your problem.  You can also bump your post ever 24 hours if you don’t get a response.

Rob