-
-
Notifications
You must be signed in to change notification settings - Fork 22k
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
Prevent error at creating Control nodes in threads #77766
Conversation
I don't think it's appropriate to allow creating incorrectly initialized GUI nodes under specific conditions. As far as I understand Juan, Control nodes are not supported outside of the main thread. So adding workarounds here just to suppress valid errors is wrong. It's also completely hidden from the user.
They are, from the project theme and from the default theme. |
I mean they are not accessible from the thread, because you will get the error that this PR prevents. The problem was that the blocked methods were called automatically, beyond user control. |
It's a part of the initialization logic, it's not supposed to be within user's control. It's there to ensure that nodes are correct and can be used. Same thing can happen with any other methods of GUI nodes during the initialization step. If GUI API is not supported in threads, then we should not expect the creation of such nodes to be allowed either.
That said, I don't see why this shouldn't work from threads in principle. |
I think that's accurate.
The problem is that the |
Hmm, I see. Yes, theme property getters have a cache and can write to it in some cases. So these operations would need to be remade with MT in mind, and then calling As far as I understand, the biggest concern with threads in controls is computing sizing, and these methods aren't related to that. |
That's right. However, my take is to keep GUI single-threaded for the time being, since, as you can see, otherwise the implications can start to grow big and we're not even done with adapting the elements that need it for the main use to MT. I'm pretty sure @reduz's design choice also matches this idea. |
Closing in favor of #78000 |
This PR makes the Control skip theme cache initialization if it's created in a thread. The theme properties are not accessible anyway, so I think it's fine if they are not correct. We could maybe document that accessing theme in thread is not possible (but other properties should be fine).
Fixes #77764