Jump to content

Silent crash


Alienhead
 Share

Recommended Posts

I've got a strange thing happening,  here's the code :

-- iterate:
    for i, m in pairs(mf) do 
        m.size = m.size - 5
        m.ent:SetScale(m.size, m.size, m.size)
        if m.size <0 then
            m.ent:Release()
            m=nil
            table.remove( mf, i )
        end
    end    

At random times, no reason whatsoever, this  line m.ent:SetScale(m.size, m.size, m.size) will crash me to desktop ( no errors or anything in the debugger as far as errors or warnings), I've rem'd it out and no crashes,  I then replaced the line with m.ent:Point(camera) and at random times for no reason it crashes the same way.

The entity is not being touched anywhere else whatsoever.  It's really been bothering me for a few days now.

 

Not so SILIENT afterall..  Change the order of the function up a little bit and was able to get this in debug mode - 

"Asset map value is different"

OK..   now..  WtF is that ? lol.

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Never had a problem removing while looping, it's  continuing to the next entry anyways..   Just to test it I removed the :

       if m.size <0 then
            m.ent:Release()
            m=nil
            table.remove( mf, i )
        end

from the function and it still randomly crashes.  It seems to happen mostly after a physic collision detection.

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Something new - 

Possible reference count error for asset "c:/__ukr/materials/effects/default.mat"

I havent done any manual reference asserting, not sure why this even came up.   Haven't even used this mat, unless the engine loads it for some other purposes.

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites


---------------------------------------------------------------------------------------------------------------
function Monitor_Muzzleflashes()

-- iterate:
    for i, m in pairs(mf) do 
        if m.size <0 then
            m.enti:Release()
            m=nil
            table.remove( mf, i )
            return
        end
        m.size = m.size - 10
        m.enti:SetScale(m.size, m.size, m.size)
    end    
 

 

I've spent the last 3 hours moving my muzzle effects out of code an into a prefab'ed-scripted pivot created in the editor. It serves the exact same purpose but only no freeze up or shutdowns when I run it. :)

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

After following up on your advice, I restructured most my infrastructure to reuse the same prefabs/emitters etc..  Not only have I noticed a nice 20% increase in framerates and overall game smoothness - but I am no longer randomly crashing everywhere either.

As far as the other error/warnings I was getting :Possible reference count error for asset  ::,  this was directly caused by creating a CacheWorld() I was using.

I created a seperate world on game startup :  

cache=World:Create()
World:SetCurrent(cache)

Then I loaded up tons of models I was using throughout all my maps. ( to keep them in memory for faster duplicating in the main code ). But somewhere over the development-span of this project the ref numbers got thrown off,  once  I restructured my main code to handle it's own caching and instancing I no longer needed 'cacheworld' so I ripped it out... Lo and behold - my assert warnings and errors vanished. ;)

 

So all is good in toon-land again, the show must go on !

 

 

  • Like 1

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

I do however have one question that has arose since restructuring has been done - I have several prefabs that work on timers.  They eventually Release() themselves once their lifespan has expired.   

Question being, how would one go about pre-loading these type of prefabs for later Instancing:: in code ?

The only thing I have come up with so far would be to set the prefab script to inactive on cache-load,  then when making instances of the prefab in real-time turn the instance copy to active.  Not sure this would work however and it'll be a major overall to even test it out.

 

Here's a example; this is a prefab consisting of a model and a script :

function Script:Start()
    self.size = 80
    self.active = false
end

function Script:UpdatePhysics()
    if self.active == true then
        self.size = self.size - 10
        self.entity:SetScale(self.size, self.size, self.size)
        if self.size < 0 then self.entity:Release() ; end
    end
end

 

I turn the script off by setting self.active to false.  Now I can load this prefab and hide it for later Instancing.

Question being is once I instance this prefab and pop it into game play, how would I set the self.active to true from the calling function that originally creates the instance copy ...

To further explain . 

flash= Prefab:Load("Prefabs/Effects/sprite_muzzleflash.pfb") -- this is called in my pre-mapload ,  it is the main copy I will instance off of.

now later down the line in real time ....  I may call this in some function - 

trail = tolua.cast(flash:Instance(),"Entity")

Now since I have the active set to false in the main prefab, I need to set the active variable to true in the instanced version so it can do it's thing.

How would I set a variable in that script from outside of that script ?

 

 

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

25 minutes ago, Alienhead said:

Question being is once I instance this prefab and pop it into game play, how would I set the self.active to true from the calling function that originally creates the prefab ...

You can access the variable of your prefab/instance script with something like trail.script.active. Script is a member of the entity class. Just make sure you check to see if the script member is not nil. I also ran into issues instancing entity's and the script doesn't carry over. In this case, you would use SetScript to correct it.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

Moving my entire main logic loop over to c++,  I've stumbled upon this little error I've not seen before - mind you it's not crippling the game flow at all but I just hate seeing red in the console widow. :)

Error states :  Error: Texture can't be reloaded because it is currently bound to a buffer.

As I mentioned, it's not  causing any problems as far as I can tell with the game flow, no crashes or anything.. Just puzzles me because I want to fix it but I have little to nothing to go on. 

 

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Well the code base is rather large and as I stated earlier I had no idea where the problem was even occurring from.  But good news! The only new media I added to the project this week was a skybox skin,  I quickly pulled it out of the project and haven't see the error since.

I do appreciate your willingness to help however.

I'm only happy when I'm coding, I'm only coding when I'm happy.

Link to comment
Share on other sites

Is it possible one of the entities is a child of another, so the parent is getting released, releasing the child, and then you try to release an invalid object?

You might want to just hide the entity instead of deleting it. A hidden entity doesn't really take up any processing and doesn't hurt anything.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...