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

[Regression] Closing a window from an AppBarButton in overflow inside a CommandBar crashes the app #10115

Closed
DCorrBECare opened this issue Oct 29, 2024 · 4 comments
Labels
area-Commanding AppBar, UICommand, MVVM, etc bug Something isn't working

Comments

@DCorrBECare
Copy link

Describe the bug

If the AppBarButton click event closes the window it's located in, the whole app crashes.
This is a regression bug from the 1.5.241001000 version.

This is the error I get from the windows event viewer:

Faulting application name: -, version: 1.0.0.0, time stamp: 0x66960000
Faulting module name: Microsoft.UI.Input.dll, version: 10.0.26107.1011, time stamp: 0xda8f9ffb
Exception code: 0xc0000409
Fault offset: 0x0000000000023df8
Faulting process id: 0x0x49DC
Faulting application start time: 0x0x1DB2A0B70F25DF7
Faulting application path: C:\Program Files\WindowsApps\-.exe
Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.6_6000.266.2241.0_x64__8wekyb3d8bbwe\Microsoft.UI.Input.dll
Report Id: 50544f47-67ed-4e87-b55c-43841b68043b
Faulting package full name: -
Faulting package-relative application ID: App

Steps to reproduce the bug

Run the attached repo and click a few times on the command bar button until the app crashes (1-5 times).
https://github.com/user-attachments/assets/e93c0b4c-346f-4897-944a-5ad120c7cd98

Expected behavior

The app doesn't crash.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

Windows version

Windows 11 (22H2): Build 22621

Additional context

No response

@DCorrBECare DCorrBECare added the bug Something isn't working label Oct 29, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Oct 29, 2024
@karkarl karkarl added area-Commanding AppBar, UICommand, MVVM, etc and removed needs-triage Issue needs to be triaged by the area owners labels Nov 7, 2024
@karkarl
Copy link
Contributor

karkarl commented Nov 7, 2024

Would you be able to provide a call stack?

@DCorrBECare
Copy link
Author

@karkarl How can I give you the call stack? Visual Studio doesn't manage this exception.
The only way I can get infos is through the Event Viewer of Windows.

@danielgruethling
Copy link

danielgruethling commented Jan 10, 2025

I can reproduce this also when I have a menubar with a flyout and create a new window from it while closing the old one.

Image

Here is my repro project:

CrashRepro.zip

This error does not happen with 1.5.241107002. It got introduced by 1.6.xxxxx

For the case that you don't want to open the project here are the steps to reproduce:

  • create a new winui3 packaged project using the template for an empty application, packaged
  • replace MainWindow.xaml with this:
<?xml version="1.0" encoding="utf-8" ?>
<Window
    x:Class="CrashRepro.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="using:CrashRepro"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="CrashRepro"
    mc:Ignorable="d">

    <StackPanel
        HorizontalAlignment="Center"
        VerticalAlignment="Center"
        Orientation="Horizontal">
        <MenuBar Name="MbMenu">
            <MenuBarItem Title="File">
                <MenuFlyoutItem Click="myButton_Click" Text="NewWindow" />
            </MenuBarItem>
        </MenuBar>
    </StackPanel>
</Window>
  • replace MainWindow.xaml.cs with this:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Navigation;
using Windows.Foundation;
using Windows.Foundation.Collections;

// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.

namespace CrashRepro
{
	/// <summary>
	/// An empty window that can be used on its own or navigated to within a Frame.
	/// </summary>
	public sealed partial class MainWindow : Window
	{
		public MainWindow()
		{
			this.InitializeComponent();
		}

		private void myButton_Click(object sender, RoutedEventArgs e)
		{
			MainWindow mw = new();
			mw.Activate();
			Close();
		}
	}
}
  • build and run
  • click the NewWindow flyout item a few times (the error does not happen every time but often enough)

@llongley
Copy link
Member

I was able to repro the issue. It looks like the same callstack as the one in this issue: #10127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Commanding AppBar, UICommand, MVVM, etc bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants