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

windows: Fix renderer state sync during window minimize/restore #22366

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

Conversation

Cupnfish
Copy link
Contributor

@Cupnfish Cupnfish commented Dec 23, 2024

Description

This PR fixes a Windows-specific issue where restoring the window from a minimized state would cause the application to crash with surface out of date errors. The root cause was improper handling of Windows SIZE_MINIMIZED messages and subsequent renderer state updates.

What's Changed

  • Improved handling of Windows SIZE_MINIMIZED window messages
  • Ensured proper renderer state updates during Windows window state transitions
  • Added correct handling of resize events during minimize/restore on Windows
  • Restructured the Windows window state management code for better clarity

Previous Behavior

On Windows platform, when minimizing the window, the application would crash upon restore with:

[WARN] GPU frame is out of date
[WARN] Acquire failed because the surface is out of date

New Behavior

  • Windows window can be minimized and restored without errors
  • Renderer state remains properly synchronized with Windows window state
  • No crashes or surface out of date errors on window restore

Platform Specific

  • This fix is specific to the Windows platform
  • Issue and fix are related to Windows window message handling (SIZE_MINIMIZED)
  • Other platforms are unaffected by this change

Testing

  • Tested window minimize/restore multiple times on Windows
  • Verified no crashes on window restore on Windows
  • Checked renderer state consistency across state changes
  • Verified no regression on other platforms

Related Issues

Closes #21703

Release Notes:

  • Fixed window renderer crash on Windows when restoring from minimized state

The previous implementation could lead to 'surface out of date' errors on
Windows when restoring from a minimized state, due to improper handling
of SIZE_MINIMIZED messages. This commit:

- Properly handles Windows SIZE_MINIMIZED window messages
- Tracks window minimized state more accurately on Windows platform
- Ensures renderer state is properly updated during minimize/restore cycles
- Maintains renderer state synchronization with Windows window state
- Skips resize callbacks when minimized to prevent potential errors

This fixes the Windows-specific issue where restoring from minimized state
would cause the application to crash with:
    "GPU frame is out of date"
    "Acquire failed because the surface is out of date"
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 23, 2024
@JunkuiZhang
Copy link
Contributor

In PR #21756, @mgsloan chose that approach to prevent the swapchain from being resized to (1,1) when the window is minimized. However, it seems to cause the issue of Acquire failed because the surface is out of date.

To be honest, I am more inclined towards the approach in PR #21703.

@Cupnfish
Copy link
Contributor Author

I also referred to the method in #21703, but the issue on my computer was not fixed in PR #21756.

@maxdeviant maxdeviant changed the title fix(windows): Fix renderer state sync during Windows window minimize/restore windows: Fix renderer state sync during window minimize/restore Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants