Skip to content

Fix intermittent app freeze when toggling fullscreen (F11 / player button)#398

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-full-screen-freeze-issue
Open

Fix intermittent app freeze when toggling fullscreen (F11 / player button)#398
Copilot wants to merge 2 commits intomainfrom
copilot/fix-full-screen-freeze-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Rapid or concurrent fullscreen toggles (F11, Alt+Enter, player button) could send conflicting commands to the window manager before any single transition completed, causing the app to freeze — particularly on Windows with hybrid GPU setups.

Two bugs in AnymexTitleBar (lib/widgets/custom_widgets/anymex_titlebar.dart):

  • Concurrent calls not guarded: multiple in-flight windowManager.setFullScreen() calls could race against each other
  • Stale cached state: toggleFullScreen() read from isFullScreen.value (local cache) instead of the actual OS window state, so any drift caused every subsequent toggle to issue the wrong command

Changes

  • AnymexTitleBar (anymex_titlebar.dart)
    • Added _isTransitioning boolean guard — any call arriving while a transition is in progress is dropped immediately, preventing duplicate/conflicting window manager calls
    • Both setFullScreen() and toggleFullScreen() now call await windowManager.isFullScreen() to read actual OS state rather than the cached value — once before toggling, once after to confirm final state
    • Guard cleared via try/finally to prevent permanent lock on exception
// Before
static Future<void> toggleFullScreen() async {
  await windowManager.setFullScreen(!isFullScreen.value); // stale cache
  isFullScreen.value = !isFullScreen.value;              // assumes success
}

// After
static Future<void> toggleFullScreen() async {
  if (_isTransitioning) return;                          // drop concurrent calls
  _isTransitioning = true;
  try {
    final currentState = await windowManager.isFullScreen(); // actual OS state
    await windowManager.setFullScreen(!currentState);
    isFullScreen.value = await windowManager.isFullScreen(); // confirm result
  } finally {
    _isTransitioning = false;
  }
}

Type of Changes

  • Bug Fix

Testing Notes

Manually verify: rapid F11 presses, clicking the player fullscreen button multiple times in quick succession, and Alt+Enter should no longer freeze the app.

Linked Issue(s)

Additional Context

Most reproducible on Windows with AMD integrated/discrete GPU combos (e.g. AMD Ryzen 5 5500U + Radeon), where the Windows DWM is slower to process fullscreen transitions.

Submission Checklist

  • I have read and followed the project's contributing guidelines
  • My code follows the code style of this project
  • I have tested the changes and ensured they do not break existing functionality
  • I have added or updated documentation as needed
  • I have linked related issues in the description above
  • I have tagged the appropriate reviewers for this pull request

Copilot AI changed the title [WIP] Fix Anymex desktop app freeze when entering full-screen mode Fix intermittent app freeze when toggling fullscreen (F11 / player button) Apr 14, 2026
Copilot AI requested a review from itsmechinmoy April 14, 2026 10:24
@itsmechinmoy itsmechinmoy marked this pull request as ready for review April 14, 2026 10:25
@itsmechinmoy itsmechinmoy requested review from RyanYuuki and Shebyyy and removed request for itsmechinmoy April 14, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anymex desktop app sometimes freezes when switching to full-screen mode or pressing F11, both in the player and the app.

2 participants