daily builds after 881 crash all the time on mac

I’m pretty sure it’s something in the collisions, but where i don’t know. i saw the note about isSensor changing relative to collision functions, but i’m not sure if that’s related. i’ll try and dig some more. the lua_pcall only happens sometimes, so i’m not sure if that’s a red herring or not

the crashes seem to happen when my main character interacts with something. and the main character is a ragdoll , so, plenty of places to look. i have

physics.setContinuous(false)  

on, if that matters…
cheers
Andy
[import]uid: 118333 topic_id: 30236 reply_id: 121131[/import]

The Physics library was updated to Box2D 2.2.1 in build 873.
In build 890 there was a change to no longer allows you to set isSensor on an object in a collision event. This was because of changes to Box2d. A new event property was added to handle this (see 890 release notes).

From my experience, if you are getting a runtime Pcall Lua error, your program is doing something wrong. If it’s happening randomly, it’s probably in a collision event.

If you build for developer or debug (instead of adhoc), the runtime error should give you the file and line number of what triggered the error.
[import]uid: 7559 topic_id: 30236 reply_id: 121155[/import]

hey
i don’t doubt it’s something i’m doing, it’s just weird it started happening with the later builds…

i’ve narrowed it down to something specific i think
i precreate some weapons for my hero character like this…

[lua]for i=1,13 do
local asplode = display.newImage(Weapons.dg,“common/blam.png”,-100*i,-100)
asplode.power = 40
physics.addBody( asplode, “dynamic”, { density=1, friction=0, bounce=0 ,radius=explodo,isSensor = true,filter= {categoryBits = 16, maskBits = 269 }} )
–asplode.collision = Weapons.explosion
–asplode:addEventListener(“collision”, asplode)

asplode.id = i
asplode.isVisible = false
asplode.isBodyActive=false
Weapons.asplodes[i]=asplode
end

for i=1,5 do
local ms = display.newImage(Weapons.dg,“missile.png”,-100*i, -100)
physics.addBody(ms, “dynamic”, {friction=0.2,density = 0.50, bounce=0.0,radius = 16,filter = {categoryBits = 16, maskBits = 269 }})

ms.isBullet = true
ms.power = 125
ms.hitCount = 0
ms.isVisible = false
ms.isBodyActive=false
Weapons.missiles[i]=ms
– these are the lines that seem to cause the crash –
ms.collision = Weapons.hitRocket
ms:addEventListener(“collision”, ms)

end [/lua]
if i comment out the two lines relevant to the collision it won’t crash . if the lines are there then it crashes…

i’m a little unclear on the change - can i not use isSensor with a collision function?

cheers
[import]uid: 118333 topic_id: 30236 reply_id: 121191[/import]

Since you didn’t include any of your collision event code (Weapons.explosion), there is no way to say if you are doing something wrong or not.

isSensor is okay to use, but you can’t change it in your collision event code. [import]uid: 7559 topic_id: 30236 reply_id: 121195[/import]

oh yes, that would help

[lua]print(“explosion”)
if (phase == ended) then

local other = event.other
if other ~=nil then
local dx = (other.x - self.x)
local dy = (other.y - self.y)
if dx <= 0 then dx = -1 else dx = 1 end
if dy <= 0 then dy = -1 else dy = 1 end

–print(other)

other:applyLinearImpulse( dx * 50,dy * 50,other.x,other.y)
end
end
return false[/lua]

i don’t get the word ‘explosion’ printed
i’m precreating these objects, then immediately setting them to be inactive until i need them
could that be an issue?

cheers
[import]uid: 118333 topic_id: 30236 reply_id: 121197[/import]

Sorry, but I would need to see the complete event listener to comment. I can’t really help you with only snippets of code. (This is why we ask everyone for a full functional demo project when reporting bugs.)

I would suggest you first figure out which build stopped it from working and then isolate your code to determine what is causing the collision listener to crash. [import]uid: 7559 topic_id: 30236 reply_id: 121198[/import]

well that is the full event listener, minus the function header i accidently snipped off at the top…

the build that it stops working is 890.

883 is fine.

[lua]function Weapons.explosion(self,event)

print(“explosion”)
if (phase == ended) then

local other = event.other
if other ~=nil then
local dx = (other.x - self.x)
local dy = (other.y - self.y)
if dx <= 0 then dx = -1 else dx = 1 end
if dy <= 0 then dy = -1 else dy = 1 end

other:applyLinearImpulse( dx * 50,dy * 50,other.x,other.y)
end
end
return true

end[/lua]

and that is why i haven’t posted a bug yet, i’m trying to isolate the case where it happens.
which isn’t proving that easy as i’m getting no error report other than a segfault, and the call stack just points to code i can’t see.
cheers

[import]uid: 118333 topic_id: 30236 reply_id: 121200[/import]

We would need a complete code sample that fails in order to understand what’s going on. Can you submit a bug report with a simple project that crashes the simulator?

If you keep your objects inactive there will be no collision routine called.

If the simulator crashes right after you start the app, there may be something going on in how your are defining the Weapons table that holds the collision function. Maybe something is clobbering the contents of the table. I don’t know why that would be affected by build 890 changes. [import]uid: 7559 topic_id: 30236 reply_id: 121206[/import]

gah, i think it was some really old button and scene code that was causing a conflict somewhere…
i’ve upgraded to widgets and things seem to be much more stable… sorry for the noise…
[import]uid: 118333 topic_id: 30236 reply_id: 121207[/import]