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

Nested Layout causes Unspecified Error Crash #10030

Open
nkovner-v opened this issue Oct 1, 2024 · 2 comments
Open

Nested Layout causes Unspecified Error Crash #10030

nkovner-v opened this issue Oct 1, 2024 · 2 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@nkovner-v
Copy link

Describe the bug

Running WinUI3 applications with deeply nested layout can cause a crash due to "Unspecified Error" with type Microsoft.UI.Xaml.UnhandledExceptionEventArgs.

This occurs in our application intermittently. Using more streamlined layout (for example, Panel types instead of ItemsControl types) has been found to mitigate the issue.

We are able to reproduce the issue easily with a tiny example WinUI3 application with 300 nested Grids. Although this is not a likely real-world scenario, this appears to be the same crash that occurs in our application when a reasonable amount of styled containers are nested within each other.

Faulting application name: winui-crash.exe, version: 1.0.0.0, time stamp: 0x66960000
Faulting module name: Microsoft.UI.Xaml.dll, version: 3.1.6.0, time stamp: 0x90636d10
Exception code: 0xc000027b
Fault offset: 0x00007e41
Faulting process id: 0x0xBA88
Faulting application start time: 0x0x1DB142DC4FE0339
Faulting application path: C:\code\@backup\winui-crash\bin\x86\Debug\net8.0-windows10.0.19041.0\win-x86\AppX\winui-crash.exe
Faulting module path: C:\Program Files\WindowsApps\Microsoft.WindowsAppRuntime.1.6_6000.242.101.0_x86__8wekyb3d8bbwe\Microsoft.UI.Xaml.dll
Report Id: 17170d5d-452f-4306-8a7b-1975a2a849e2
Faulting package full name: 3355c9c5-d1aa-4039-8f5a-b1b535dd91e9_1.0.0.0_x86__5myfa0yag8p68
Faulting package-relative application ID: App

Steps to reproduce the bug

  1. Create a new WinUI3 Solution - Blank App, Packaged (WinUI 3 in Desktop)
  2. Replace MainWindow.xaml and MainWindow.xaml.cs with the following code:

MainWindow.xaml

<Window
    x:Class="winui_crash.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:winui_crash"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Loaded="LayoutRoot_OnLoaded" x:Name="LayoutRoot" />
</Window>

MainWindow.xaml.cs

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;

namespace winui_crash;
public sealed partial class MainWindow : Window
{
    public MainWindow()
    {
        this.InitializeComponent();
    }


    private void LayoutRoot_OnLoaded(object sender, RoutedEventArgs e)
    {
        Grid grid = new Grid();
        Grid parent = null;
        LayoutRoot.Children.Add(grid);
        for (int i = 0; i < 300; i++)
        {
            parent = grid;
            grid = new Grid();
            parent.Children.Add(grid);
        }
    }
}
  1. Run the application.

Expected behavior

This crash occurs well before any noticeable performance hit. When nesting a slightly smaller amount of Grids, the application launches instantly with no measurable performance problem.

Expected that no crash would occur when performance is not stressed.

Screenshots

No response

NuGet package version

WinUI 3 - Windows App SDK 1.6.0: 1.6.240829007

Windows version

Windows 11 (22H2): Build 22621

Additional context

Windows 11 Build 22631.
Microsoft.WindowsAppSDK 1.6.240829007

@nkovner-v nkovner-v added the bug Something isn't working label Oct 1, 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 1, 2024
@AdriaanLarcai
Copy link

Can confirm this is an issue, this was never as much of an issue in version 1.5 of the Windows App SDK. But it could still occur from time to time. Now with 1.6 even the slightest nesting causes this exception to be thrown.

The exact exception message is, with no additional forwarded details:

"The text associated with this error code could not be found.

Layout cycle detected. Layout could not complete."

This is critical for us, as we can have some pretty deeply nested drill-down views to represent nested JSON objects. And to build some form of navigation for this would hamper the user experience.

It feels like with every release more and more regressions occur...

@nkovner-v nkovner-v changed the title Deeply Nested Layout causes Unspecified Error Crash Nested Layout causes Unspecified Error Crash Oct 8, 2024
@nkovner-v
Copy link
Author

This is a hard crash, 3rd party verified as common in end-products, with a reproducible set of simple steps that has been stuck in triage for 30 days. Please move this ticket forward and communicate with us on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

2 participants