Panda3D slow startup?

Hi, I’m new to Panda and so far it seems promising, its major selling points being the liberal license to me and the ongoing project to target npapi/activex. The reliance of python annoys me (if there was more focus on c++ panda would be the most popular open source engine, imho) but it seems you can do anything on c++, so I’m gonna give it a try.

The major problem I’ve found so far is the slow startup of a panda app. A hello world in Irrlicht, for example, starts up in 0.1 seconds aprox, instantenously. And this is with the loading of an animated model. On the other hand, a Panda3d hello world (that is just an empty gray screen) takes 1.5 seconds to load! Now you may think this is nitpicking but it’s a show-stopper for me. No reason to use Panda if Irrlicht gives me an instant startup, which increases user satisfaction very noticeably, specially for casual games. Also, if it takes so long to load needlessly, it says very bad things abot the engine in general.

So, I’m asking the regulars here, is there any way to fix this? Even though I’m using c++, is python the culprit here? If so, any way of get completely rid of it? (Having to rebuild Panda3d is ok with me).

not really an answer, but more a sidenote:
i’m coding only in python, but even here on my crappy computer an unoptimized panda python script needs 1,2 seconds to start and quit instantly.

Huh, I never thought about it before. Now that you mention it, a second or so is a bit slow for startup.

Looking closer, it looks like most of that time is in the WinGraphicsPipe constructor, where it’s attempting to measure the CPU speed, strictly for the purpose of putting it in the log. For whatever reason, measuring the CPU speed appears to take a second or two.

Clearly, we don’t need to make every Panda user query their CPU speed at application startup time. I’ll wrap that code in a condition based on a config variable.

If you don’t want to wait for 1.7, you can download the Panda code from CVS and build it yourself to pick up the fix.


Thanks! I’ll try that and report back. And by the way, 1 second is not really that slow, for example the Ogre engine is even slower than Panda, I’m just spoiled by the fast start I get when using Irrlicht or pure DirectX. Now, I have more questions but I guess I’ll use new threads for clarity.

Ok. I commented out everything in the constructor from “// determine CPU frequency” to the end of the function and now Panda starts up instantaneously!

There are still two issues; now, this is actually nitpicking but since I’m at it I’m curious how much can I improve it. Startup is now lightning fast on a hot start, but on a cold start (meaning: first startup in a while) it’s still slow (couple of seconds). I’m assuming this is because it has to load all those DLL’s, and since the second time they are cached, the app is started instantaneously.

I know that the google chrome devs, for example, make cold starts really fast by putting all the dynamic code in the same dll, so you have a small exe and a huge 10MB dll, they insist they do this to improve startup time, that’s an idea for you. If it’s not a lot of work it would be nice to have an option to build all of Panda into one dll, it would greatly improve the apparent speed.

I’m also thinking that static linking would probably have the same effect, is it possible to link all of Panda3D statically? If so, how?

The second issue is that when the hello world example starts the screen is black for aprox. 0.2 seconds, then it turns gray as expected. I’m curious about what is the engine doing in those 0.2 seconds (I don’t hear HD activity so it’s suspicious) and whether it could be optimized or not.

Also, could you explain what are the consequences of removing the CPU measuring-related code that I’ve removed? Is it used for game loop fps control or something?

I’m gonna now continue development with the stock SDK anyway, since you said you’d add this in 1.7. I definitely appreciate this!

Edit: Btw, I tested this against the 1.6.2 source code tarball.

Well, that’s actually a bit of a pain, because it’s a multiplatform project with multiple different build scripts. It’s doable, but I’ll admit it’s not high on my priority list right now. :slight_smile:

This, however, is easy, if you’re willing to use the ppremake build system. You can configure:


in your Config.pp and build away. You’ll get a static pview.exe (and static libpanda.lib, etc.).

I suppose it’s parsing the egg files, or decoding the textures, or otherwise interpreting the models. It’s probably also loading the vertex buffers and textures to video memory.

It could very likely be optimized; if nothing else, it could paint a splash image into the frame immediately after opening the window, and before doing anything else. This is the approach I’m taking with the browser plugin system.

No, it just gets written to the log, and that’s all. A Disney engineer added this code last year to help us isolate the causes of certain reported frame rate issues.


Yeah, forget about it, linking statically is an easy solution for people like me. I’ll post to report if it improves the cold startup performance.

But my test program consists of:

  framework.open_framework(argc, argv);
  framework.set_window_title("My Panda3D Window");
  WindowFramework *window = framework.open_window();
  return (0);

So it’s no loading models or textures, or am I missing something? The splash screen solution is a good one though but will I be able to actually load a splash screen before that black screen? We are talking of 0.2 seconds, just a flicker if you aren’t paying attention, it’s not a big deal but I’m asking out of curiosity since we are at it and it seems avoidable :slight_smile:

Uh, sorry for double posting. It seems it only happens with opengl. tinydisplay immediately shows the gray screen. Haven’t tried with directx yet.

Well, maybe it’s just the graphics context firing itself up, then.


Yeah it seems that way. I hadn’t notices because I always uses D3D but Irrlicht has the exact same delay when initializing OpenGL, so I bet starting up with DirectX in Panda is instantaneous too (wanted to try before posting back but I wasn’t able to build panda with it last night).