Skip to content

Hang when modifying ColumnDefinition.Width #5231

@etvorun

Description

@etvorun

Problem description:
VS XAML Designer - or WpfSurface.exe to be more exact - freezes deep inside WPF while making a very specific change to ColumnDefinition.With. XAML designer team was not able to re-create a stand alone repro.

Minimal repro:
Designer.zip

  1. Open attached project in VS 2019 or VS 2022.
  2. Open MainWindow.xaml and wait for XAML designer to load.
  3. Find ColumnDefinition with x:Name='MyColumn'
    3a. For debugging: start another VS instance and attach to WpfSurface.exe.
  4. Change Width of MyColumn from 2* to 3*.
    IMPORTANT changing MyColumn to other values like 4* or 20 will not repro this issue. Making changes like commenting out Image element or first 5 ColumnDefinition elements, then reopening MainWindow.xaml and then changing MyColumn to 3* will not repro this issue.

Expected behavior:
Use can interact with VS, i.e. it is not frozen

Actual behavior:
VS appears to be frozen, 10s later "designer is busy" dialog pops us. Here is a "freeze" call stack from WpfSurface.exe. At this point ColumnDefinition.Width has been modified and we update layout of Canvas where XAML content for MainWindow.xaml is hosted.

PresentationFramework.dll!System.Windows.Controls.Grid.MinRatioIndexComparer.Compare(object x, object y) Line 3962
System.Private.CoreLib.dll!System.Array.SorterGenericArray.InsertionSort(int lo, int hi) Line 2288
System.Private.CoreLib.dll!System.Array.SorterGenericArray.IntrospectiveSort(int left, int length) Line 2157
System.Private.CoreLib.dll!System.Array.Sort(System.Array keys, System.Array items, int index, int length, System.Collections.IComparer comparer) Line 1747
System.Private.CoreLib.dll!System.Array.Sort(System.Array array, int index, int length, System.Collections.IComparer comparer) Line 1636
PresentationFramework.dll!System.Windows.Controls.Grid.SetFinalSizeMaxDiscrepancy(System.Windows.Controls.DefinitionBase[] definitions, double finalSize, bool columns) Line 2492
PresentationFramework.dll!System.Windows.Controls.Grid.SetFinalSize(System.Windows.Controls.DefinitionBase[] definitions, double finalSize, bool columns) Line 2101
PresentationFramework.dll!System.Windows.Controls.Grid.ArrangeOverride(System.Windows.Size arrangeSize) Line 705
PresentationFramework.dll!System.Windows.FrameworkElement.ArrangeCore(System.Windows.Rect finalRect) Line 4727
PresentationCore.dll!System.Windows.UIElement.Arrange(System.Windows.Rect finalRect) Line 894
PresentationCore.dll!System.Windows.ContextLayoutManager.UpdateLayout() Line 351
Microsoft.VisualStudio.DesignTools.WpfTap.dll!Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.VisualTree.DispatcherVisualTreeContext.UpdateLayout() Line 201
WpfSurface.dll!Microsoft.VisualStudio.XSurface.Wpf.DesignerTapInstanceManager.AfterProcessActions(Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.LiveMarkup.TapInstanceBuilderContext context) Line 235
Microsoft.VisualStudio.DesignTools.WpfTap.dll!Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.LiveMarkup.TapInstanceManager.ProcessCurrentThreadActions(Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.LiveMarkup.TapInstanceBuilderContext context) Line 184
Microsoft.VisualStudio.DesignTools.WpfTap.dll!Microsoft.VisualStudio.DesignTools.WpfTap.WpfVisualTreeService.LiveMarkup.TapInstanceManager.UpdateInstances.AnonymousMethod__0() Line 145
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeDelegateCore() Line 555
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeImpl() Line 529
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(object state) Line 489
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(object obj) Line 215
System.Private.CoreLib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 186
System.Private.CoreLib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 146
WindowsBase.dll!MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Line 172
WindowsBase.dll!System.Windows.Threading.DispatcherOperation.Invoke() Line 412
WindowsBase.dll!System.Windows.Threading.Dispatcher.ProcessQueue() Line 2087
WindowsBase.dll!System.Windows.Threading.Dispatcher.WndProcHook(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 2296
WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) Line 295
WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) Line 429
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate callback, object args, int numArgs) Line 103
WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.TryCatchWhen(object source, System.Delegate callback, object args, int numArgs, System.Delegate catchHandler) Line 36
WindowsBase.dll!System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) Line 1329
WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) Line 341
[Native to Managed Transition]
user32.dll!00007ffee4b1e858()
user32.dll!00007ffee4b1e299()
[Managed to Native Transition]
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame frame) Line 2135
WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame frame) Line 329
WindowsBase.dll!System.Windows.Threading.Dispatcher.Run() Line 297
PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) Line 2405
PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.Window window) Line 1695
PresentationFramework.dll!System.Windows.Application.Run() Line 198
WpfSurface.dll!Microsoft.VisualStudio.XSurface.Wpf.WpfSurfaceApp.Main(string[] args) Line 66
[Native to Managed Transition]
hostpolicy.dll!00007ffebd342993()
hostpolicy.dll!00007ffebd342c07()
hostpolicy.dll!00007ffebd34354e()
hostfxr.dll!00007ffecaa1b539()
hostfxr.dll!00007ffecaa1e506()
hostfxr.dll!00007ffecaa20821()
hostfxr.dll!00007ffecaa1eb62()
hostfxr.dll!00007ffecaa182ab()
WpfSurface.exe!00007ff6a72ffa1f()
WpfSurface.exe!00007ff6a72ffdf7()
WpfSurface.exe!00007ff6a7301fa8()
kernel32.dll!00007ffee4007034()
ntdll.dll!00007ffee58c2651()

Metadata

Metadata

Assignees

Labels

BugProduct bug (most likely)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions