-
-
Notifications
You must be signed in to change notification settings - Fork 699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronization between renderer and handlers doesn't work #1985
Comments
I've fixed this in my local copy by making Unfortunately not all code paths are protected by the mutex. Even with the To be on the safe side, I've also added (locally) sync via the same mutex:
There might be other areas that still need proper synchronization. |
Since you submitted a PR for this -- thanks again for all the PR's -- I'm closing the bug report. You are really putting DPG to the test! What are you building? |
Like I said in one of the tickets, I cannot tell much about the project I'm using DPG for. But yeah, its GUI is quite complicated, and sometimes reveals unexpected things in DPG. I'm used to analyzing code written by other people, and often try to sort it out myself. |
Alright, well, if you can share at any point in future that would be great. Thanks for the contributions! |
Version of Dear PyGui
Version: 1.8.0
Operating System: Windows 10
My Issue/Question
I'm creating a lot of UI widgets from within a handler, and I've noticed that my application crashes or hangs up from time to time when the UI is being created. After setting up a series of experiments, I've found that the mutex used for synchronization between the renderer thread and the handlers thread doesn't work the intended way. In particular, I was getting random crashes in
RenderItemRegistry()
when it was going throughthemeRegistryRoots
and at the same time the other thread was adding one more theme tothemeRegistryRoots
(which of course invalidated the iterator inRenderItemRegistry()
). These two things are not supposed to happen simultaneously; the mutex should have "serialized" them.The following piece of code is used in most API functions and is supposed to lock the mutex:
However, it also unlocks the mutex immediately after acquiring it. It becomes easier to see it if one adds curly braces like this:
lock_guard
's scope is theif
statement, so it locks the mutex and unlocks it right away.To Reproduce
I've no idea how to reproduce it other than re-running the same application many times. With a relatively simple example (below), I could not get a reliable crash even with 100,000 themes being added in a loop. However, once in a while it does crash, so I'd suggest to run it in a loop from a script. Or maybe if the app also deletes themes it has just created, and repeat this in an infinite loop, it will eventually crash - I haven't tried that.
Expected behavior
No random crashes. Access to common data must be synchronized properly.
Screenshots/Video
Standalone, minimal, complete and verifiable example
The text was updated successfully, but these errors were encountered: