Skip to content

fix(windows): sync Flutter render surface after SetBounds - #582

Closed
kaes1a wants to merge 1 commit into
leanflutter:mainfrom
kaes1a:fix/windows-viewport-sync-on-resize
Closed

kaes1a wants to merge 1 commit into
leanflutter:mainfrom
kaes1a:fix/windows-viewport-sync-on-resize

Conversation

@kaes1a

@kaes1a kaes1a commented Jan 21, 2026

Copy link
Copy Markdown

Call ForceChildRefresh() after SetWindowPos() in SetBounds() to ensure the Flutter render surface is properly synchronized with the new window size.

Problem:
When using setSize() or setBounds() to resize the window during app startup, Flutter's render surface may not sync correctly with the new window dimensions. This causes visual artifacts including:

  • Black areas appearing at window edges
  • UI elements rendered at incorrect positions
  • Click events working correctly while visuals are misaligned

Root cause:
SetWindowPos() triggers WM_SIZE which updates Flutter's logical coordinate system, but the physical render surface viewport may not update in time before the next frame is rendered.

Solution:
ForceChildRefresh() uses the +1px/-1px resize trick to force the Flutter view child window to fully synchronize its render surface. This is the same mechanism already used for WM_DPICHANGED and leave-full-screen scenarios.

Call ForceChildRefresh() after SetWindowPos() in SetBounds() to ensure
the Flutter render surface is properly synchronized with the new window
size.

Problem:
When using setSize() or setBounds() to resize the window during app
startup, Flutter's render surface may not sync correctly with the new
window dimensions. This causes visual artifacts including:
- Black areas appearing at window edges
- UI elements rendered at incorrect positions
- Click events working correctly while visuals are misaligned

Root cause:
SetWindowPos() triggers WM_SIZE which updates Flutter's logical
coordinate system, but the physical render surface viewport may not
update in time before the next frame is rendered.

Solution:
ForceChildRefresh() uses the +1px/-1px resize trick to force the
Flutter view child window to fully synchronize its render surface.
This is the same mechanism already used for WM_DPICHANGED and
leave-full-screen scenarios.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: kaes1a <leehncg@gmail.com>
@lijy91

lijy91 commented Sep 21, 2026

Copy link
Copy Markdown
Member

Thank you for the PR, and sorry it sat here so long. window_manager 0.5.x is no longer maintained: from 0.6.0 window_manager is rebuilt on nativeapi (Flutter package: nativeapi), and the platform code in this repo's main branch goes away, so I'm closing PRs against it.

The startup case this describes (render surface not matching the window size after an early setSize/setBounds) matches a Flutter engine bug where OnEmptyFrameGenerated transposed width and height. That was fixed in flutter/flutter#187954 and ships in Flutter 3.47 stable. If you still see it with nativeapi's Window.bounds / size on Flutter 3.47+, please open an issue at https://github.com/libnativeapi/nativeapi-flutter/issues.

@lijy91 lijy91 closed this Sep 21, 2026
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.

2 participants