KirillOsenkov / MSBuildStructuredLog

A logger for MSBuild that records a structured representation of executed targets, tasks, property and item values.
MIT License
1.44k stars 190 forks source link

WPF: ArgumentNullException in VisualTreeUtils.AsNonNullVisual #570

Open kant2002 opened 2 years ago

kant2002 commented 2 years ago
System.ArgumentNullException: Value cannot be null.
Parameter name: element
   at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
   at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)
   at System.Windows.Controls.VirtualizingStackPanel.FindScrollOffset(Visual v)
   at System.Windows.Controls.VirtualizingStackPanel.OnAnchorOperation(Boolean isAnchorOperationPending)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

You have the latest version: 2.1.627

It maybe issue with WPF

KirillOsenkov commented 2 years ago

does this happen for any binlog or for a specific one? could you email me the problematic binlog? to my first name dot last name at microsoft. Did you try on another computer? did you try on https://live.msbuildlog.com

kant2002 commented 2 years ago

I did try on different computer. No luck. Forget about live viewing. Will check tomorrow. Also, observation. I open file, it start scrolling and probably expanding nodes. Then exception, and then I was able to browse and seems to be no issues with content.

KirillOsenkov commented 2 years ago

@sambent anything jump at you from the stack above?

KirillOsenkov commented 2 years ago

@kant2002 can you open your PresentationFramework.dll in ILSpy and tell me the version of the file mentioned in the attributes? should be something like 4455 or 4470.

kant2002 commented 2 years ago

[assembly: AssemblyInformationalVersion("4.8.4470.0")]

kant2002 commented 2 years ago

Also I experience very similar, but slightly different exception with same file, and same conditions

System.ArgumentNullException: Value cannot be null.
Parameter name: element
   at MS.Internal.Media.VisualTreeUtils.AsNonNullVisual(DependencyObject element, Visual& visual, Visual3D& visual3D)
   at System.Windows.Media.VisualTreeHelper.GetParent(DependencyObject reference)
   at System.Windows.Controls.VirtualizingStackPanel.FindScrollOffset(Visual v)
   at System.Windows.Controls.VirtualizingStackPanel.OnAnchorOperation(Boolean isAnchorOperationPending)
   at System.Windows.Controls.VirtualizingStackPanel.SetAnchorInformation(Boolean isHorizontalOffset)
   at System.Windows.Controls.VirtualizingStackPanel.<>c__DisplayClass94_0.<InitializeViewport>b__0()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

That exception happens when I click on the tree, when it is expanding and before tree finish it's expansion.

SamBent commented 2 years ago

I haven't seen this before. OnAnchorOperation calls FindScrollOffest twice - once for the (deepest) TreeViewItem at the top of the viewport before the scroll, and once for the topmost element after the scroll. One of these is null, but neither is supposed to be. The TreeView layout is getting confused somehow, but I'd need more evidence to figure out how. A callstack, and even a crash dump, is not enough - as usual the problem is likely to have occurred long before the crash. In order of preference: A reliable repro, a time-travel trace, or an STF trace (with matching crash dump).

KirillOsenkov commented 2 years ago

@kant2002 if you go to Start Page in the binlog viewer, and disable tree view virtualization, I expect the problems to go away. Could you confirm it?

Also, could you send me that binlog file if possible?

What is the screen DPI of that monitor? More than 100%? How many monitors do you have and what’s the screen resolution?

kant2002 commented 2 years ago

@kant2002 if you go to Start Page in the binlog viewer, and disable tree view virtualization, I expect the problems to go away. Could you confirm it?

@KirillOsenkov I confirm that issue goes away.

Also, could you send me that binlog file if possible?

Unless your email has one L instead of two, or youg github handle does not reflect your name, you should have email with file attached.

What is the screen DPI of that monitor? More than 100%? How many monitors do you have and what’s the screen resolution?

One external monitor attached to laptop. DPI = 100% (I assume this is Scale And Layout in the Home -> Display section in the System Settings), resolution 1920x1080

KirillOsenkov commented 2 years ago

I got the binlog, thanks! Unfortunately it works just fine on my machine. I'll try a few other things too.

Meanwhile, if you have time, could you please try to record scrollTrace.stf as described here: https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/21#issuecomment-514701904

We had a couple similar issues: https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/407 https://github.com/KirillOsenkov/MSBuildStructuredLog/issues/21

kant2002 commented 2 years ago

Send STF file to same location. Anything else what I can do?