Mysterious sudden invasion of Wait

Hello !

In my current project, I load and unload levels. For some reason, when I load any level for the second time, the game suddenly starts lagging a lot.

PStats reveals that after the second load, most of the time is spent on Wait/Flip/End.

This bug only happens when I use a directional light in the level. The node from this light is indeed removed at the level destruction (and PStats confirms that no node or geoms remain after a level destruction). However it is true that models look different after each load, like each time they’re being enlightened one more time over.

Any clue about what might be happening ?
Thanks !

Are you perhaps keeping a reference/pointer to the original light somewhere? It could be that the light is being removed from the scene graph, but is then later re-applied via a reference or pointer in your code somewhere.

Perhaps it might help to set to “null” any objects that might point to your old light.

I didn’t have any other pointer to the light, but following that lead I searched for something else that could’ve retained data about the light.

Since it was applied on the render node, I had to do:


So, the lights now look ok, there’s no more residue from other loadings.
However, the Wait/Flip/End issue is still there.

It is related indeed, since instantiating the sunlight twice will cause the issue to appear. I don’t know how the issues are related though.

Time spent in Wait:Flip:End is time waiting for your graphics card to perform the “flip” operation. Usually this means your graphics card is still drawing the frame.

Why your graphics card takes longer to draw the same scene after you have loaded it a second time is unclear. Maybe you still have the previous copy of the scene also parented to render, so now you have two copies of the scene being rendered at once?

Check the “Vertices” and “Geoms” counts also reported by PStats. This may provide some insight.


The amount of geom and vertices is the same after the first loading and after the second one.

For the record, we’re two different person working on this project.

On my computer, I managed to fix the issue by never creating a light again. Instead of removing the old one, I just clear it, put it aside, and reattach it to render when needed.

On the other guy’s computer it didn’t fix the issue. The only thing that make him not lag is completely disabling lights.

Can we use these informations to find the issue ?

No, what you’re reporting doesn’t make any sense to me, sorry. There must be something else you haven’t discovered yet.