-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
PowerToys Run cache issue #4472
PowerToys Run cache issue #4472
Conversation
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.
-
The cache is not being written unless I launch Powertoys Run atleast once. You can see that there is only one exit log and multiple start-up logs. I don't think that should be a factor in deciding whether we store the cache/json files or not.
2020-06-25.txt -
I noticed that PT Run does not properly dispose and write the cache while exiting runner from VS. The path the code takes then is that it checks if the parent process (settings/runner) is alive or not and if not, it exits. I guess that path has not been taken into consideration.
void terminateProcess() { | ||
DWORD processID = GetProcessId(m_hProcess); | ||
EnumWindows(&requestMainWindowClose, processID); | ||
const DWORD result = WaitForSingleObject(m_hProcess, MAX_WAIT_MILLISEC); |
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.
[clarification] can you specify what signal would be sent when the process is closed? Like we would get a WAIT_TIMEOUT if no signal is sent within 2 seconds.
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.
I don't think we can specify the signal the object can return. WaitForSingleObject
return values are limited as mentioned here : https://docs.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject
I am not entirely sure what might be causing this. If I create a similar scenario and set launcher as startup project, cache is being written. @ryanbodrug-microsoft Will it be fine if we fix this issue later? Alekhya is blocked on #4424 because of this PR. This issue doesn't have any user-facing consequences because user preferences don't change until Powertoys run is launched atleast once.
This was being caused because Environment.Exit function doesn't always terminate process cleanly. So I have modified the codepath to explicitly call |
@divyansh It's okay to go forward with this, as long as you can verify verify that the behavior observed isn't a knock on of this change. Could you perhaps split this PR into seperate PRs for the same issue. @alekhyareddy28 would submitting the pinyin concurrent dictionary issue unblock you or do you need both fixes? |
I just noticed another issue when I pulled the changes from this branch. The Steps to repro -
I observe that the Exit log is logged but the Save functions are not executed. |
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.
As discussed with @somil55, It seems to be happening because of timing out and calling Terminate Process. Maybe we can increase it as I see that the imagecache is not stored sometimes (even without the debugger) because of a timeout before imagecache.save().
The issue is because runner and powerlauncher are different processes and hitting a debugger on one process doesn't stop the execution of the other process. So when you hit a breakpoint in powerlauncher.exe, you cross 2 sec mark on the runner process and it terminates powerlauncher.exe. So when you continue from breakpoint on powerlauncher.exe, it exits and you don't hit further breakpoints. You can set : |
Summary of the Pull Request
This PR fixes cache issue in PowerToys Run
References
PR Checklist
Detailed Description of the Pull Request / Additional comments
Fixed Issue :
TerminateProcess
was used to stop powerlauncher.exe which caused immediate termination of the process and no exit callbacks were being invoked. To fix this, we first send WM_CLOSE signal to process and give it 2sec time to stop itself, otherwise we kill it usingTerminateProcess
.Validation Steps Performed