Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
What could be causing this assertion error? — Gideros Forum

What could be causing this assertion error?

AxlFlameAxlFlame Member
edited March 2013 in Bugs and issues
Hey, guys!

So... I stumbled upon an odd error. I use scene manager and I my minigames inside my game are scenes. The problem is, when I try to create a "restart", which would mean a scene change to the same scene. But when I try that it gives me this critical error:

"Assertion Failed!
Program: C:\Program Files (x86)\Gideros\GiderosPlayer.exe
File:..\external\Box2D_v2.2.1\Box2D\C...\b2Dyna...ree.cpp
Line: 127

Expression: m_nodes[proxyId].IsLeaf()"

I did some research and found nothing about it... I mean, I know it's related to the usage of box2D in my minigame, but what could this error mean?

Comments

  • ScouserScouser Guru
    edited March 2013
    It could be related to the way you are restarting/changing the scene.

    I have just looked at that line in the box2d source and it appears box2d is trying to destroy something that doesn't exist.

    I would suspect that your scene has a
    require "box2d"
    which may be causing the problem (although I'm not 100% sure). If this is the case then maybe you should move the require to your init.lua and keep a global reference to it.

    As I said, I'm not 100% sure this is the case (or for that matter how box2d would respond to multiple calls to require but I do suspect this has something to do with your problem).

    Maybe @atilim might be able to shed a little more light on the subject.

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • AxlFlameAxlFlame Member
    edited March 2013
    I do have that line right on the beginning of the code. I tried doing what you suggested, although I'm not sure I understood it all...

    When you say init.lua, that means my main class, right? I ask cause I don't have any init.lua, only a main.lua.
    How can I keep a global reference to it? It's something like this?
    _G.box2d = require "box2d"
    Assuming that's it, it didn't work out... actually when I tried removing the "require" from my minigame, the minigame was working just as before. That mean the issue is not related to that line?
  • You can make a global reference by not putting local or anything in front of it.

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • ar2rsawseenar2rsawseen Maintainer
    simply require box2d somewhere in the global scope like init.lua or main.lua were any file and any class can access it ;)

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • @AxlFlame: As discussed here init.lua is the first file executed in your project. It is usually a good place to add your initialisation code & also implement your plugins etc.

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • Ok, so the issue is not the "require"... I placed it on my main and still got the problem.

    I tried to debug my onExitBegin method because I thought it could be related, as the problem happens when I try to exit my scene and change to the same scene.

    I found out that the Assertion Failed happens right when the method is cycling through the sprites on the scene to destroy them.
    function BonecosDesenho:onExitBegin()
    	for i=self:getNumChildren(),1,-1 do
    		local sprite = self:getChildAt(i)	
    		if sprite.body then
    			b2World:destroyBody(sprite.body)
    	                //HERE
    		end
    	end
     
    	if bridge.body then
    		b2World:destroyBody(bridge.body);
    		bridge.body = nil;
    		bridge.onEnterFrame = nil;
    	end
    	if sceneParent then
    		sceneParent = nil;
    	end
    	this.paused = nil;
    	collectgarbage();
    	self:removeEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
    end
    If I try to print anything beyond that point it doesn't appear at all.
    Is it trying to destroy a body that doesn't exists anymore? If it is, why this problem doesn't happen when I exit my scene to another scene??
    I'm going crazy on this
  • Require will actually make sure a file is not included twice: http://www.lua.org/pil/8.1.html

    Is bridge not a child of your scene already? If it is then aren't you trying to destroy bridge.body twice? That may be related to the problem.

    Likes: AxlFlame

    +1 -1 (+1 / -0 )Share on Facebook
  • AxlFlameAxlFlame Member
    edited March 2013
    The point with the bridge is that it's a child of gestarea (an area where the player is allowed to draw the bridge), which in turn is a child of my game scene.

    Also, the assertion failed happens before my code gets to the "If bridge.body then" part...

    Btw, thanks for the insight on the "require"!
Sign In or Register to comment.