Skip to content

[GEN][ZH] Fixed crash when alt-tabbing out of the game #801

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

aliendroid1
Copy link

As noted in the original comment, the game was intended to switch to windowed mode when alt-tabbing out. However, the code mistakenly passed the current window mode instead, resulting in no actual change.

This update corrects the parameter to 1, explicitly enabling windowed mode and preventing the crash.

Closes #28

As noted in the original comment, the game was intended to switch
to windowed mode when alt-tabbing out. However, the code mistakenly
passed the current window mode instead, resulting in no actual change.

This update corrects the parameter to 1, explicitly enabling windowed
mode and preventing the crash.
@Mauller
Copy link

Mauller commented May 3, 2025

Did you test this with the game set to the same resolution as the desktop?

@aliendroid1
Copy link
Author

Did you test this with the game set to the same resolution as the desktop?

Same and different both for both full screen mode and -win shortcut. Is it still crashing for you?

@Mauller
Copy link

Mauller commented May 3, 2025

Same and different both for both full screen mode and -win shortcut. Is it still crashing for you?

No it didn't crash when i tested it, but i heard that the problem happens primarily when the game and desktop resolution match.

The game would pause when i alt+tab and continue again once i brought it back into focus.

It only crashed on me due to a different problem while debugging.

@aliendroid1
Copy link
Author

Same and different both for both full screen mode and -win shortcut. Is it still crashing for you?

No it didn't crash when i tested it, but i heard that the problem happens primarily when the game and desktop resolution match.

The game would pause when i alt+tab and continue again once i brought it back into focus.

It only crashed on me due to a different problem while debugging.

Before the change, for me on window 11 it would always crash regardless of the resolution. It would sometimes be fine the first time I switched focus out of the game using alt-tab or the windows key and I'd still be focus back on to the game but it always crashed if I switched focus after this.

@Mauller
Copy link

Mauller commented May 3, 2025

Before the change, for me on window 11...

Ah im running 10 still, so i might not as easily see the issue occur.

@Mauller Mauller added Minor Severity: Minor < Major < Critical < Blocker Generals Related Generals only ZeroHour Relates to Zero Hour Fix Is fixing something labels May 3, 2025
@aliendroid1
Copy link
Author

Before the change, for me on window 11...

Ah im running 10 still, so i might not as easily see the issue occur.

Did you try without the Genpatcher fixes?

@Mauller
Copy link

Mauller commented May 3, 2025

Before the change, for me on window 11...

Ah im running 10 still, so i might not as easily see the issue occur.

Did you try without the Genpatcher fixes?

I don't run gentool or genpatcher stuff, just our code from the repo.

@xezon
Copy link

xezon commented May 5, 2025

Unclear if this fix is correct. We need to understand what exactly crashes first, then decide on fix. Start with posting crash callstack and observations in #28.

@aliendroid1
Copy link
Author

Unclear if this fix is correct. We need to understand what exactly crashes first, then decide on fix. Start with posting crash callstack and observations in #28.

Done. I'm certain this fix is correct and I've shared the evidence. You can test for yourself

@xezon
Copy link

xezon commented May 6, 2025

It would be nice to see what code paths are avoided that originally would cause crashing. And why fullscreen is meant to be treated as windowed mode. Perhaps that variable is incorrectly named? What does it do exactly?

@aliendroid1
Copy link
Author

It would be nice to see what code paths are avoided that originally would cause crashing. And why fullscreen is meant to be treated as windowed mode. Perhaps that variable is incorrectly named? What does it do exactly?

I posted it in #28 like you had requested. Which variable are you asking about being incorrectly named?

@helmutbuhler
Copy link

I can confirm that this fixes the crash (on Windows 10).
When I set my fullscreen resolution to my native resolution, I have 100% crash rate without this PR and 0% with the PR.

Regarding the cause of the crash: This is quite likely a Windows issue. MS stopped caring about real fullscreen mode for some time now and all new games just use windowed mode for fullscreen. In my opinion we don't need to investigate it further.

I would also prefer to always set windowed to true in WW3D::Set_Render_Device. At least when the resolution matches the desktop resolution. Then we don't have to minimize the game everytime it loses focus and Alt-Tabbing will be much faster. But we can do that later in another PR.

@aliendroid1
Copy link
Author

I can confirm that this fixes the crash (on Windows 10). When I set my fullscreen resolution to my native resolution, I have 100% crash rate without this PR and 0% with the PR.

Regarding the cause of the crash: This is quite likely a Windows issue. MS stopped caring about real fullscreen mode for some time now and all new games just use windowed mode for fullscreen. In my opinion we don't need to investigate it further.

I would also prefer to always set windowed to true in WW3D::Set_Render_Device. At least when the resolution matches the desktop resolution. Then we don't have to minimize the game everytime it loses focus and Alt-Tabbing will be much faster. But we can do that later in another PR.

Will need to check if setting it to windowed mode always would prevent edge scrolling or if it affects any other behavior. Alt tabbing seems to be pretty fast on my end when the resolution matches the screen resolution. I think the delay might have to do with the last argument to the function that determines if textures should be reloaded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Is fixing something Generals Related Generals only Minor Severity: Minor < Major < Critical < Blocker ZeroHour Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows 10: Game crashes on ALT+Tab
4 participants