Strange lag in menu [SOLVED]

Hi all,

I’ve got a menu class and selection works fine.

Strangly when running the game after several seconds it starts lagging like hell.

I’m cleaning and destroying the object.

the problem should be in here somewhere perhaps any of you can give a glance at it.

Thanks in advance,

Formatwizard

from pandac.PandaModules import *
from direct.showbase.DirectObject import DirectObject
from direct.gui.OnscreenImage import OnscreenImage
from direct.task.Task import Task
import time

class Menu(DirectObject):
    
    def __init__(self):
        wp = WindowProperties()
        wp.setCursorHidden(True)

        base.win.requestProperties(wp)

        self.player1snd = loader.loadSfx("audio/fx/singleplayer.wav")
        self.player2snd = loader.loadSfx("audio/fx/multiplayer.wav")

       
        self.txture = loader.loadTexture("menu/bckgrnd.avi")
        self.onePlayerImage = OnscreenImage("menu/1player.png", pos = Point3(-0.5, 0, 0), scale = Vec3( 0.18,0,0.3 ) )
        self.onePlayerImage.setTransparency(TransparencyAttrib.MAlpha)
        
        
        self.twoPlayerImage = OnscreenImage("menu/2players.png", pos = Point3(0.5, 0, 0), scale = 0.3 )
        self.twoPlayerImage.setTransparency(TransparencyAttrib.MAlpha)


        self.cursor = OnscreenImage("cursor/glove.png", pos = Point3(-1.25,0,0), scale = Vec3(0.08,0.1,0.08))
        self.cursor.setTransparency(TransparencyAttrib.MAlpha)

        self.p1Time = 0
        self.p2Time = 0
        
        self.txture.setLoop(False)
        
        #CREATE CARDMAKER OBJECT IN cm VARIABLE
        cm = CardMaker("");
        cm.setFrameFullscreenQuad()
        cm.setUvRange(self.txture)
        #CREATE movieNode AND GENERATE CARDMAKER
        self.mNode = NodePath(cm.generate())
        self.mNode.reparentTo(render2d)
        #SET TEXTURE TO MOVIENODE (MOVIE)
        self.mNode.setTexture(self.txture)

        self.snd = loader.loadSfx("audio/fx/cargoby.wav")
        #SYNC SOUND TO MOVIEFILE
        
        #self.snd.play()

        
    def mouseEvent(self, task):

        if base.mouseWatcherNode.hasMouse():

            x=base.mouseWatcherNode.getMouseX()
            y=base.mouseWatcherNode.getMouseY()

            self.cursor.setPos( x, 0 , y )

            if ( (x >= -0.5699) and (x <= -0.3549) and (y >= -0.3166) and (y <= 0.1733) ):

                if ( self.p1Time != 1) and (self.player1snd.status() -1 == 0):

                    self.player1snd.play()
                    self.p1Time = 1
                    self.p2Time = 0

                if ( base.mouseWatcherNode.isButtonDown( MouseButton.one( ) ) ):

                    self.setChoice("singlePlayer")
                    self.destroy()
                    
                    return task.done
    
            elif ( (x >= 0.2800) and (x <= 0.8100) and (y >= -0.3166) and (y <= 0.1733) ):
            
                if ( self.p2Time != 1) and (self.player2snd.status() -1 == 0):

                    self.player2snd.play()
                    self.p2Time = 1
                    self.p1Time = 0

                if ( base.mouseWatcherNode.isButtonDown( MouseButton.one( ) ) ):

                    self.setChoice("multiPlayer")
                    self.destroy()
                    
                    return task.done


        return task.cont

    def setChoice(self, choice):

        self.choice = choice

    def getChoice(self):

        return self.choice

    def destroy(self):

        self.mNode.remove()
        self.txture.stop()
        self.onePlayerImage.destroy()
        self.twoPlayerImage.destroy()
        self.cursor.destroy()
        self.player1snd.stop()
        self.player2snd.stop()
        self.snd.stop()
        self.ignoreAll()

havent looked too deep into it. but can it be that you spawn tasks. but dont delete them at all?

Hi Thomas,

First of all thanks for your reply,

I’m spawning the task once from the main .py file, i do this with the following code

self.menu = Menu()
taskMgr.add(self.menu.mouseEvent, "mouseEventCatcher", uponDeath=self.continueLoadProcess)        

in the self.continueLoadProcess i retreive the selection made from within the menu.

and then directly afterwards i do

del self.menu

just thought. cause i did simmilar things and my task keept on running. so i thought it might be worth to check the taskmanager

Will check that out first :slight_smile:

If I find something i’ll keep you posted.

Well took a look at the running tasks but it seems to stop nicely.

Will dig in deeper

Are you sure that the movie texture you’re playing is small enough to play with a reasonable frame rate? You can view it in pview to make sure.

Other than that seat-of-my-pants guess, your best bet is to use PStats to see where your frame’s time is being spent. It will tell you whether you should be looking for leaking tasks, or strange render artifacts, or too many nodes, or whatever weird thing might be going on.

David

David,

The movie texture i’m running is a 839kByte “large” .wmf,

It’s mainly looping. that shouldn’t be the problem.

I used pstat before and i’ll post the image here in a couple of minutes.

If found the source of the strange lag somehow it comes from the wave files (28 and 29kBytes) i’ve commented them and it works without lag :S

So i’m going to find out wheter it keeps running (even if i specificly stop the sound).

will keep you guys posted.

Formatwizard

Problem is in the openAL audio manager after switching to Fmod audio manager it works like a charm.

thnx to all that gave idea’s

I found openAL sound manager to be slug slow too.