Skip to content

[Windows] Crash when using AutoLayout with Padding #1278

@Kunal22shah

Description

@Kunal22shah

When using AutoLayout with the Padding set on a page where NavigationCacheMode is Enabled, app crashes.

Current behavior

The application crashes with a Non-negative number required exception when navigating back to that page.

Stack Trace:

Non-negative number required. (Parameter 'height')

at Windows.Foundation.Size..ctor(Single width, Single height)
at Uno.Toolkit.UI.AutoLayout.MeasureOverride(Size availableSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at Microsoft.UI.Xaml.FrameworkElement.MeasureOverride(Size availableSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_MeasureOverride_0(IntPtr thisPtr, Size availableSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at Uno.Toolkit.UI.AutoLayout.InnerArrange(Size& finalSize)
at Uno.Toolkit.UI.AutoLayout.ArrangeOverride(Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at Uno.Toolkit.UI.AutoLayout.InnerArrange(Size& finalSize)
at Uno.Toolkit.UI.AutoLayout.ArrangeOverride(Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverridesMethods.ArrangeOverride(IObjectReference _obj, Size finalSize)
at ABI.Microsoft.UI.Xaml.IFrameworkElementOverrides.Do_Abi_ArrangeOverride_1(IntPtr thisPtr, Size finalSize, Size* result)

Removing the Padding property or setting NavigationCacheMode to Disabled prevents the crash.

Expected behavior

How to reproduce it (as minimally and precisely as possible)

Nuget Package:

Package Version(s):

Affected platform(s):

  • WebAssembly
  • Android
  • iOS
  • macOS (AppKit)
  • Mac Catalyst
  • Skia
    • WPF
    • GTK (Linux)
    • Linux Framebuffer
    • Tizen
  • Windows

IDE:

  • Visual Studio 2022
  • Visual Studio 2019
  • Visual Studio Code
  • Visual Studio for Mac
  • Rider Windows
  • Rider macOS

Relevant plugins:

Anything else we need to know?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions