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

[Bug] A Windows 11 update broke console hiding #3902

Closed
HebaruSan opened this issue Sep 13, 2023 · 3 comments · Fixed by #4051
Closed

[Bug] A Windows 11 update broke console hiding #3902

HebaruSan opened this issue Sep 13, 2023 · 3 comments · Fixed by #4051
Labels
Bug GUI Issues affecting the interactive GUI Windows Issues specific for Windows

Comments

@HebaruSan
Copy link
Member

HebaruSan commented Sep 13, 2023

Operating System

Windows 11 22H2 or later

CKAN Version

v1.33.3

Game Version

1.12.5

Problem

Multiple users on Discord reported that the terminal window was appearing and not going away on Windows 11 (and the latest one stuck around long enough for us to investigate). Turns out a Windows 11 update broke GUI.Util.HideConsoleWindow by swapping out the default terminal app to one that doesn't support GetConsoleWindow:

Apparently it was deprecated for a while:

https://learn.microsoft.com/en-us/windows/console/getconsolewindow

image
image

ckan.exe is built as a console app because it has command line functionality built-in, so Windows insists on opening a terminal for it. Linux has the ability to launch a console app in the background:

Terminal=false

Steps to reproduce

  • Install Windows 11 22H2 or later
  • Launch ckan.exe
  • The terminal remains visible instead of hiding

Suggestions

  • The user on Discord was satisfied with a shortcut that launches the terminal window minimized. Could we do that by default somehow?
  • Build separate EXEs for GUI and console? Would be a loss of generality that has served CKAN well for many years. More confusion about what to download.
  • Build only the GUI app? Would completely break the metadata validator action and be a big disruption for anyone still using cmdline.
  • Build a GUI app that can still read and write from the terminal if launched from one? Don't know if this is possible, would have to investigate.
@HebaruSan HebaruSan added Bug GUI Issues affecting the interactive GUI Windows Issues specific for Windows labels Sep 13, 2023
@HebaruSan HebaruSan pinned this issue Sep 14, 2023
@jcotton42
Copy link

jcotton42 commented Dec 16, 2023

ckan.exe is built as a console app because it has command line functionality built-in, so Windows insists on opening a terminal for it. Linux has the ability to launch a console app in the background

GUI apps can still take CLI parameters. What might work here is P/Invoking AllocConsole if any CLI parameters that require CLI output work, or always if ckan just always needs that console window. I haven't tested this myself though, and I'm not sure if a GUI that does this will still block the console like a CLI-subsystem app would (my guess is it won't by default, but it's definitely possible since VSCode has that --wait parameter).

@HebaruSan
Copy link
Member Author

The problem isn't the arguments, it's needing to use stdin/stdout. Allocating a console doesn't sound like the right thing to do if someone opens a terminal and types "ckan.exe install Astrogator".

@HebaruSan
Copy link
Member Author

FreeConsole might be a drop-in replacement.

I tested with the old console on Win10, and it worked as expected, with one benefit over the old HideConsoleWindow approach: If I start a terminal myself and run ckan.exe, my terminal window stays open (because my shell process is still attached to it). But double clicking ckan.exe in explorer results in the window closing shortly after it appears (because no other process was attached).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug GUI Issues affecting the interactive GUI Windows Issues specific for Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants