Freeze when using tkinter with multithreading

I’ve been pouring over the ShowBase implementation, the panda3d docs, google, and these forums, and I’ve been unable to figure out what’s going on here. I’ve distilled the issue to simply using tkinter with threading-model set to anything other than single-threaded.

I can produce the freeze with the following snippit:

from panda3d.core import ConfigVariableBool, ConfigVariableString
from direct.showbase.ShowBase import ShowBase

ConfigVariableBool("want-tk").setValue(True)
ConfigVariableString("threading-model").setValue("Cull/Draw")

ShowBase().run()

An empty, fully functional tk window is created, and an 800x600, frozen, native panda3d window is created. It doesn’t matter whether I put tkinter in charge of the main loop or not either. Is there something I’m missing?

For reference, I’m using:
AMD 64bit Python 3.8.0 on Windows 10
v1.10.13 of Panda3d
v8.6.9 of Tk

Welcome to the community!

Maybe it has something to do with the message loop not being handled. Panda and tkinter both have one so Panda disables its own message loop but they might be bound to different threads. Try editing ShowBase.py and changing the value of the disable-message-loop to False.

Same result, regardless of doing either of these:

ConfigVariableBool("disable-message-loop").setValue(True)
ConfigVariableBool("disable-message-loop").setValue(False)

My end goal here is using Panda3d to serve as the engine for a level/asset previewer/editor for Gauntlet Dark Legacy. I’ve got enough implemented that it’s starting to bog things down, even with optimizations, so I’m looking to parallelize some of the per-frame stuff. It’s designed to load the assets from the xbox, ps2, and gamecube versions of the game and convert them at runtime to p3d types. I’ve yet to tackle animation, but it’s coming sooner than I’d like.

A few examples of what I’ve managed so far in a few months:
https://cdn.discordapp.com/attachments/1073500419508154438/1090461671950139463/image.png
https://cdn.discordapp.com/attachments/1040820763617415239/1089766802390794290/image.png
https://cdn.discordapp.com/attachments/1073500419508154438/1090312283156135966/image.png
https://cdn.discordapp.com/attachments/1040820763617415239/1083207916108124200/image.png

1 Like

Please file a bug report on the GitHub issue tracker for Panda3D so this doesn’t get forgotten.

I’ll file a bug report, but from the sound of it it seems like there’s nothing else to try? Am I just gonna have to hope the bug report gets addressed soon and just leave the threading optimization alone for now?

I think someone needs to take a look using a C++ debugger to find out where Panda is stuck. If you’re able to do so yourself, please feel free. But in any case, file an issue so that one of the developers can investigate the issue, possibly suggest a workaround, and implement a fix for Panda3D 1.10.14.

If you want to use a debugger, you need to have Visual Studio and have installed the debug symbols for the Panda3D build (downloadable as a separate zip file). In Visual Studio you can attach the debugger to a running process and hit pause to get a stack trace to figure out where it is stuck. This will give a lot of information to determine the cause of the problem.

Please post a link to the issue here when you’ve created it.

I already have:

As for the debugger, I could, but I’ve been taking a break from my personal projects for a bit. Work has been ramping up, and designing on 2 separate large projects and maintaining legacy code for another team is burning me out. Waiting for things to settle down before I pick this back up.

No worries, thanks for filing! I’ll see if I can take a look at it sometime soon and I’ll report back on the GitHub issue. :slight_smile:

Hope you manage to rest and recover!