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 script-related crashes on exiting a domain #1251

Merged
merged 2 commits into from
Nov 23, 2024

Conversation

ksuprynowicz
Copy link
Member

Crashes were caused by script engine getting deleted while the invoke call was waiting to be processed. Capturing shared_ptr with lambda prevents that and pointer gets released after the lambda gets processed.
Fixes #1245

@ksuprynowicz ksuprynowicz added bug Something isn't working fix before release labels Nov 22, 2024
blockingCall ? Qt::BlockingQueuedConnection : Qt::QueuedConnection);
// Lambda is necessary there to keep shared_ptr counter above zero
QMetaObject::invokeMethod(this, [=, manager = shared_from_this()]{
manager->unloadAllEntityScripts(blockingCall ? Qt::BlockingQueuedConnection : Qt::QueuedConnection);
Copy link
Member

Choose a reason for hiding this comment

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

this takes in a bool, should it just pass blockingCall?

Copy link
Member

Choose a reason for hiding this comment

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

actually I guess to get the same behavior, the invoke needs to be blocking or not

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for spotting this! I'll have a fix soon.
I'll also take a look how it's used, since blocking call invoked from main thread often means a deadlock. I might add an assert or warning there too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed :)

@HifiExperiments HifiExperiments added the CR approved This pull request has been successfully code reviewed label Nov 23, 2024
@ksuprynowicz ksuprynowicz merged commit 4e5eda5 into master Nov 23, 2024
5 checks passed
@ksuprynowicz ksuprynowicz deleted the fix/entity_shutdown_crash branch November 23, 2024 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CR approved This pull request has been successfully code reviewed fix before release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash on exiting domain with callEntityScriptMethod
3 participants