Skip to content

Conversation

@workbysaran
Copy link
Contributor

@workbysaran workbysaran commented Nov 21, 2025

Resolved / Related Issues
Fixed a crash (DivideByZeroException) that occurred when resizing the window with multiple panes split vertically.

Closes #17739

Steps used to test these changes

  1. Open Files with dual pane (vertical split)
  2. Resize the window to smaller sizes
  3. Verify no crash occurs

@yaira2 yaira2 added the changes requested Changes are needed for this pull request label Nov 23, 2025
@yaira2
Copy link
Member

yaira2 commented Nov 23, 2025

Thank you for the PR. Can you please provide some details on why you went with this approach? Ideally the minimum size wouldn't have to change, and we would instead fix the underlying cause.

@workbysaran
Copy link
Contributor Author

@yaira2
The application was crashing with a System.DivideByZeroException in Microsoft's WinUI framework when the window was resized too small with multiple panes displayed vertically. The crash occurs in WinUI's internal layout engine(FrameworkElement.MeasureOverride) when the available window space becomes insufficient to handle the grid's minimum height and width constraints.

In fact, the same issue happens even when using a single pane but the crash threshold is much lower (nearly 0px) compared to the original default size set by the code (316×416). With dual panes, the crash occurs around 700-850px width. So setting MinWidth = 850 and MinHeight = 646 on the main window itself prevents users from resizing below the threshold before WinUI's layout engine runs, avoiding the crash condition entirely.

If you don't want to set the size explicitly, we need to spend more time on research to find out why the internal Microsoft component fails, find out if there is a way to handle the validation ourselves, and confirm whether it's a Microsoft bug and report it accordingly.

Furthermore, we can enhance my previous fix to set the minimum size dynamically based on whether multiple panes are enabled.

Please let me know how you’d like to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes requested Changes are needed for this pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Resizing window in Dual Pane mode causes crash

2 participants