-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Move jumplist creation to background thread #7978
Conversation
@leonMSFT would like your thoughts on this in case there's something I've missed/overlooked! |
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, thanks! 😄
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.
Wow! Does it actually work? I know the shell APIs can be very picky about how they're called.
Are you getting any logged messages in the output window? If you make a change to your profiles, do they actually get reflected in the jumplist?
I tested with adding a new profile to my settings file (while the app was running) and yes, the jumplist got updated! |
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.
If it works fine, I'm good with it.
@@ -118,8 +118,9 @@ static std::wstring_view _getExePath() | |||
// - settings - The settings object to update the jumplist with. | |||
// Return Value: | |||
// - <none> | |||
HRESULT Jumplist::UpdateJumplist(const CascadiaSettings& settings) noexcept | |||
winrt::fire_and_forget Jumplist::UpdateJumplist(const CascadiaSettings& settings) noexcept | |||
{ |
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.
we might want to grab a copy of settings
and operate on it inside the coroutine ... otherwise, this reference will 100% be invalid by the time we resume the thread.
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.
Fixed
// make sure to copy the settings _before_ the co_await | ||
const auto settingsCopy = settings.Copy(); | ||
|
||
co_await winrt::resume_background(); | ||
|
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.
whoa boy sorry, hold up
we don't need to copy the settings. I apologize for my confusing wording.
We just need a non-reference by-value capture of settings. A "Copy", in the C++ sense, of the value of settings
. When you that with a C++/WinRT type, it increments the reference count and makes sure the reference count stays incremented until your local version is out of scope.
const auto strongSettings = settings;
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.
Ah. Thank you for the clarification, will remove the call to Copy()
.
I'm going to leave the ActionAndArgs copy fix in there though - I think that's a bug
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.
removed the copy fix to make a new PR for it
🎉 Handy links: |
🎉 Handy links: |
Summary of the Pull Request
Move jumplist creation to a background thread, it does not need to be on the main thread
Reference
#7791
PR Checklist
Detailed Description of the Pull Request / Additional comments
We were not using the
HRESULT
return value ofUpdateJumplist
anywhere, so I changed its return type towinrt::fire_and_forget
instead. Also replaced allRETURN_IF_FAILED
calls in the function toTHROW_IF_FAILED
to accommodate the change in return type.Validation Steps Performed
Tracing with a release build: