Skip to content
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

Fix lambda cross-thread dynamics (reverted) #84659

Merged
merged 1 commit into from
Nov 12, 2023

Conversation

RandomShaper
Copy link
Member

@RandomShaper RandomShaper commented Nov 9, 2023

While reviewing #84616 (which this one supersedes) I found the underlying issue to be more complicated.

This requires #84657 so tasks submitted to the WorkerThreadPool have their thread cleanup run.

Fixes #84046.
Fixes #84190.

TEMP: In draft until I can be sure both issues are really fixed.

UPDATE: In a future iteration, all this thread-local bookeeping may be replaced by heap-allocated items. That would simplify this a lot, but now it's better (I think) to keep the current approach to lower the risk of regressions.

@RandomShaper RandomShaper changed the title Fix lambda cross thread Fix lambda cross-thread dynamics Nov 9, 2023
@adamscott
Copy link
Member

adamscott commented Nov 9, 2023

Got an error while exiting the app for #84046.

image

Here, the loop fails because the element seems to exist in the list, even if the size of the list is 0.

@RandomShaper RandomShaper force-pushed the fix_lambda_cross_thread branch from 837df82 to eff5ee5 Compare November 9, 2023 18:35
@RandomShaper RandomShaper marked this pull request as ready for review November 9, 2023 18:35
@RandomShaper RandomShaper requested a review from a team as a code owner November 9, 2023 18:35
@RandomShaper
Copy link
Member Author

Out of draft! Given the complexity of the fix, any testing is welcome.

@RandomShaper RandomShaper force-pushed the fix_lambda_cross_thread branch from eff5ee5 to 8701499 Compare November 9, 2023 18:38
@adamscott
Copy link
Member

adamscott commented Nov 9, 2023

I tested (at least 10 times) your build (with the said line removed) against MRPs of #84046 and #84190 and it seems to do the trick!

@allenwp
Copy link
Contributor

allenwp commented Nov 9, 2023

870149924abc1b36715cc90e852aa5818446a14b fixes #84046 on my machine!

@RandomShaper RandomShaper force-pushed the fix_lambda_cross_thread branch 2 times, most recently from b729ab2 to 99e8ae4 Compare November 9, 2023 23:01
@RandomShaper RandomShaper force-pushed the fix_lambda_cross_thread branch from 99e8ae4 to 2715117 Compare November 9, 2023 23:05
@akien-mga
Copy link
Member

akien-mga commented Nov 10, 2023

I can't say much about the implementation, but I've been testing this today with a number of projects, some relying a lot on lambdas, and so far I haven't noticed any regression.

I also tested the MRP and confirmed it fixes #84046 for me. The other one seems Windows specific so I didn't test as I'm on Linux right now.

@akien-mga akien-mga requested a review from adamscott November 10, 2023 15:06
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cautiously approving, but TIWAGOS.
I've been using it the whole day and didn't run into any obvious issue.

@akien-mga akien-mga merged commit bc80776 into godotengine:master Nov 12, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga changed the title Fix lambda cross-thread dynamics Fix lambda cross-thread dynamics (reverted) Nov 24, 2023
@akien-mga
Copy link
Member

For the record, this was reverted/superseded by #85248.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants