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

Disallow a window waiting on system() to block DefTerm startup #14195

Merged
3 commits merged into from
Oct 14, 2022

Conversation

DHowett
Copy link
Member

@DHowett DHowett commented Oct 12, 2022

We'll just ping the window and give it a chance to respond before we
bunk with it.

Fixes #14131

@ghost ghost added Area-DefApp Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree. labels Oct 12, 2022
@DHowett
Copy link
Member Author

DHowett commented Oct 12, 2022

I don't know if this is correct. It is at best BODGY, but so was the existing foreground stealing code...

@DHowett DHowett changed the title Don't allow a window waiting on system() to block DefTerm startup Disallow a window waiting on system() to block DefTerm startup Oct 12, 2022
Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Pro tip: hide whitespace changes

@carlos-zamora
Copy link
Member

@msftbot make sure @lhecker signs off on this

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 12, 2022
@ghost
Copy link

ghost commented Oct 12, 2022

Hello @carlos-zamora!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @lhecker

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

// Try first to send a message to the current foreground window. If it's not responding, it may
// be waiting on us to finsh launching. Give it only 50ms--a tiny time slice--so as to not wait
// too long before failing out. SendMessageTimeoutW returns nonzero if it succeeds.
if (0 != SendMessageTimeoutW(oldForegroundWindow, WM_NULL, 0, 0, SMTO_BLOCK | SMTO_ABORTIFHUNG, 50, nullptr))
Copy link
Member

Choose a reason for hiding this comment

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

Is there any specific reason you chose 50? What if the system is currently under heavy load at 100% CPU usage and it takes longer than that to activate the other thread?

Copy link
Member Author

Choose a reason for hiding this comment

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

I admit that this is a very small timeout. I didn't want to block Terminal's startup for a very long time. I don't know what the right choice is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly because of ABORTIFHUNG, we could up it a little bit. We could consider using SMTO_NOTIMEOUTIFNOTHUNG, which indicates that IF THE THREAD CAN RECEIVE MESSAGES, we will wait possibly-forever for it.

Copy link
Member

Choose a reason for hiding this comment

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

I've changed it to 1000 now after all. I've used SendMessageTimeoutToTopLevelWindowClasses as a reference which uses 5000 despite using the same 3 flags.

@DHowett DHowett removed the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 14, 2022
src/cascadia/WindowsTerminal/IslandWindow.cpp Outdated Show resolved Hide resolved
@lhecker lhecker added the AutoMerge Marked for automatic merge by the bot when requirements are met label Oct 14, 2022
@ghost
Copy link

ghost commented Oct 14, 2022

Hello @lhecker!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@DHowett
Copy link
Member Author

DHowett commented Oct 14, 2022

@msftgot forget everything I told you

@DHowett
Copy link
Member Author

DHowett commented Oct 14, 2022

@msftbot forget everything I told you

@ghost
Copy link

ghost commented Oct 14, 2022

Hello @DHowett!

Because you've told me to reset the custom auto-merge settings, I'll use the configured settings for this repository when I'm merging this pull request.

@ghost ghost merged commit ab04067 into main Oct 14, 2022
@ghost ghost deleted the dev/duhowett/ra_ra_ra_and_apophis branch October 14, 2022 21:50
DHowett added a commit that referenced this pull request Oct 14, 2022
We'll just ping the window and give it a chance to respond before we
bunk with it.

Fixes #14131

(cherry picked from commit ab04067)
Service-Card-Id: 86230024
Service-Version: 1.16
DHowett added a commit that referenced this pull request Oct 14, 2022
We'll just ping the window and give it a chance to respond before we
bunk with it.

Fixes #14131

(cherry picked from commit ab04067)
Service-Card-Id: 86230023
Service-Version: 1.15
@ghost
Copy link

ghost commented Oct 18, 2022

🎉Windows Terminal v1.15.2874 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented Dec 14, 2022

🎉Windows Terminal Preview v1.16.3463.0 and v1.16.3464.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-DefApp AutoMerge Marked for automatic merge by the bot when requirements are met Priority-1 A description (P1) Product-Terminal The new Windows Terminal. Severity-Blocking We won't ship a release like this! No-siree.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DefTerm] Some invocations can cause deadlocks in terminal + another GUI application in Attach mode
3 participants