-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add thread guard for force_draw
and update related documentation
#82953
Add thread guard for force_draw
and update related documentation
#82953
Conversation
force_draw
must be called from main thread
Is documentation enough to solve #79190, which is a crash? Can we add some thread guards like we have in Node methods, or there's no access to that info from servers? CC @RandomShaper |
I believe we should add a thread guard, should I add it to this pr or make another one ? |
9ebe808
to
97e6da9
Compare
I think adding a thread guard in this PR too would make sense. I see examples of it being done this way outside of Nodes (which have their own
Adding an error message like this would also make sense here, it could be something like: ERR_FAIL_COND_MSG(!Thread::is_main_thread(), "Manually triggering the draw step from the RenderingServer can only be done on the main thread. Call this function from the main thread or use call_deferred()."); Needs testing to confirm that it works as expected (errors on thread, works on main thread or when using call_deferred()). |
force_draw
must be called from main threadforce_draw
and update related documentation
I agree with @akien-mga's remarks, but I'd still need clarity on something. Is the compatibility renderer able to run on a thread ( |
If the situation is more complex than it seemed initially, and this might partially be overridden by the RenderingDeviceDriver work, we might want to stick to just adding a note in the docs as done here for 4.2. |
Well, then let's just follow @akien-mga's idea, until everything can be addressed better. |
97e6da9
to
0b4a363
Compare
0b4a363
to
0d95dea
Compare
force_draw must be called from main thread
0d95dea
to
b88b84c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, unless we foresee that this extra check could have a non-negligible performance impact.
Just in case there's a performance impact, I'm deferring this to merge after the 4.2 release, and we can cherry-pick for 4.2.x if we confirm it's a safe approach. |
Thanks! |
Cherry-picked for 4.2.2. |
Closes #79190