tildearrow / furnace

a multi-system chiptune tracker compatible with DefleMask modules
GNU General Public License v2.0
2.65k stars 209 forks source link

[Bug] Console mode is broken on Windows #643

Closed aquamarine-axo closed 1 year ago

aquamarine-axo commented 2 years ago

Console mode appears to be broken again on Windows. It worked at some point between dev70 and dev90 as I remember testing it within that timespan but console mode simply just exits immediately when started, with no error or startup message.

Just as a form of idiot-checking, the syntax used on the command line was as follows:

>furnace -console -view commands solstice.fur

I also think that having it use -console instead of -c and --console for the short and long forms respectively is a little bit odd compared to how most command line apps work on Linux systems. perhaps this should be changed to what I suggested at the start of the last sentence?

tildearrow commented 2 years ago

Fixing this will be difficult because there isn't any way to detect a console and use it reliably.

The subsystem can only be set to either Console or Windows (for a Windows application). Setting it to Console yields the following behavior:

However, we want this behavior:

AttachConsole() is not reliable as it still detaches from it as soon as it is started...

I don't want to use FreeConsole() as it will still pop a console up for a millisecond when started from Explorer...

Furthermore, setting the subsystem to Console will forgo WinMain, which I want to use...

tildearrow commented 2 years ago

Can't remove WinMain as something calls it:

/usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld: /usr/lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/lib/../lib/libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main':
/build/mingw-w64-crt/src/mingw-w64-v9.0.0/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain'
tildearrow commented 1 year ago

Please test with git master.

aquamarine-axo commented 1 year ago

It did not make any difference, the behavior is the same as the previous commit.

aquamarine-axo commented 1 year ago

Please see my remarks on Discord.

tildearrow commented 1 year ago

Did

tildearrow commented 1 year ago

Test again with git master - somebody confirmed it working.

Don't close the issue though because there's MinGW left to test (which I will enable later).

tildearrow commented 1 year ago

Current state of console mode:

Windows 10

Windows 11

djtuBIG-MaliceX commented 1 year ago

Starting with Windows 11, it uses Windows Terminal as the default conhost client. There was a related discussion on this issue: https://github.com/microsoft/terminal/issues/12570

Looking into a workaround specifically for handling the Windows Terminal use case that does not involve packing in a separate EXE and launching a new process on entrypoint like various other programs. Not looking good on the grapevine though.

https://github.com/Ryujinx/Ryujinx/issues/3779 https://github.com/koishijs/koishi-desktop/issues/63#issuecomment-1279802746

djtuBIG-MaliceX commented 1 year ago

For now this is resolved by #998 with the caveat that it has glitches, and identical to opening firefox in a Linux Terminal (eg: Ubuntu), where the CLI prompt is accessible with stdout noise pouring in.

Should a better workaround be made available, contributors are welcome to raise a PR.

tildearrow commented 1 year ago

Marking as not fixable. Windows issue.