NaN布局测量崩溃 [英] NaN Layout Measurement Crash

查看:112
本文介绍了NaN布局测量崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们相当复杂的应用程序中,我们遇到了布局管理崩溃的情况.

In our reasonably complex application, we are getting layout management crashes.

这些似乎不是特定于一段代码的.它们在不同的时间发生在不同的控件上,导致应用程序崩溃.在特定的硬件上,问题似乎更加明显.

These don't seem to be specific to one piece of code.  They happen on different controls at different times, crashing the application.  The problem seems to be more apparent on particular hardware.


一个示例堆栈如下:


One example stack looks like:

System.InvalidOperationException:元素"System.Windows.Controls.CheckBox"的布局度量替代不应返回NaN值作为其DesiredSize. ---> System.InvalidOperationException:元素"System.Windows.Controls.CheckBox"的布局测量覆盖 不应返回NaN值作为其DesiredSize.
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.Controls.Grid.MeasureCell(Int32单元格,Boolean forceInfinityV)
  在System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead,Size referenceSize,布尔ignoreDesiredSizeU,布尔forceInfinityV)
  在System.Windows.Controls.Grid.MeasureOverride(大小约束)下
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在MS.Internal.Helper.MeasureElementWithSingleChild(UIElement元素,大小约束)
  在System.Windows.Controls.ContentPresenter.MeasureOverride(大小限制)上
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.Controls.TextBlock.MeasureChild(InlineObject inlineObject)
  在MS.Internal.Text.InlineObject.Format(Double leftParagraphWidth)
  在MS.Internal.TextFormatting.TextStore.FormatTextObject(TextEmbeddedObject textObject,Int32 cpFirst,Int32 currentPosition,Int32 rightMargin)
  在MS.Internal.TextFormatting.LineServicesCallbacks.InlineFormat(IntPtr pols,Plsrun plsrun,Int32 lscpInline,Int32 currentPosition,Int32 rightMargin,ObjDim& pobjDim,Int32& fFirstRealOnLine,Int32& fPenPositionUse break之前,LsBrkCond& breakAfter)
   ---内部异常堆栈跟踪的结尾---
  在MS.Internal.TextFormatting.TextMetrics.FullTextLine.FormatLine(FullTextState fullText,Int32 cpFirst,Int32 lineLength,Int32 formatWidth,Int32 finiteFormatWidth,Int32段落宽度,LineFlags lineFlags,FormattedTextSymbols collapsingSymbol)
  在MS.Internal.TextFormatting.TextMetrics.FullTextLine..ctor中(FormatSettings设置,Int32 cpFirst,Int32 lineLength,Int32段落宽度,LineFlags lineFlags)
  在MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal处(TextSource textSource,Int32 firstCharIndex,Int32 lineLength,双段落宽度,TextParagraphProperties段落属性,TextLineBreak previousLineBreak,TextRunCache textRunCache)
  在MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource,Int32 firstCharIndex,Double段落宽度,TextParagraphProperties段落属性,TextLineBreak previousLineBreak,TextRunCache textRunCache)处
  在System.Windows.Controls.TextBlock.MeasureOverride(大小限制)下
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.Controls.Border.MeasureOverride(大小限制)上
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.Controls.DockPanel.MeasureOverride(大小限制)
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.Controls.Control.MeasureOverride(大小限制)上
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(大小限制)上
  在System.Windows.FrameworkElement.MeasureCore(Size availableSize)
  在System.Windows.UIElement.Measure(Size availableSize)
  在System.Windows.ContextLayoutManager.UpdateLayout()处
  在System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)处
  在System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
  在System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
  在System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
  在System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
  在System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate回调,Object args,Boolean isSingleParameter)
  在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象args,布尔值isSingleParameter,委托catchHandler)
  在System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,布尔值isSingleParameter,委托catchHandler)
  在System.Windows.Threading.DispatcherOperation.InvokeImpl()
  在System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(对象状态)
  在System.Threading.ExecutionContext.runTryCode(Object userData)
  在System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode代码,CleanupCode backoutCode,对象userData)
  在System.Threading.ExecutionContext.RunInternal处(ExecutionContext执行上下文,ContextCallback回调,对象状态)
  在System.Threading.ExecutionContext.Run(ExecutionContext执行上下文,ContextCallback回调,对象状态)下
  在System.Windows.Threading.DispatcherOperation.Invoke()处
  在System.Windows.Threading.Dispatcher.ProcessQueue()处
  在System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,布尔值和已处理)
  在MS.Win32.HwndWrapper.WndProc中(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam,布尔值和已处理)
  在MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
  在System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate回调,Object args,Boolean isSingleParameter)
  在System.Windows.Threading.ExceptionWrapper.TryCatchWhen(对象源,委托回调,对象args,布尔值isSingleParameter,委托catchHandler)
  在System.Windows.Threading.Dispatcher.WrappedInvoke(委托回调,对象参数,布尔值isSingleParameter,委托catchHandler)
  在System.Windows.Threading.Dispatcher.InvokeImpl中(DispatcherPriority优先级,TimeSpan超时,Delegate方法,对象参数,布尔值isSingleParameter)
  在System.Windows.Threading.Dispatcher.Invoke处(DispatcherPriority优先级,Delegate方法,对象arg)
  在MS.Win32.HwndSubclass.SubclassWndProc处(IntPtr hwnd,Int32 msg,IntPtr wParam,IntPtr lParam)
  在MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
  在System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)处
  在System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame框架)处
  在System.Windows.Threading.Dispatcher.Run()处
  在System.Windows.Application.RunDispatcher(对象忽略)上
  在System.Windows.Application.RunInternal(窗口窗口)
  在System.Windows.Application.Run(窗口窗口)中
  在System.Windows.Application.Run()
  在Rim.Desktop.Shell.App.Main()

System.InvalidOperationException: Layout measurement override of element 'System.Windows.Controls.CheckBox' should not return NaN values as its DesiredSize. ---> System.InvalidOperationException: Layout measurement override of element 'System.Windows.Controls.CheckBox' should not return NaN values as its DesiredSize.
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Grid.MeasureCell(Int32 cell, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Size referenceSize, Boolean ignoreDesiredSizeU, Boolean forceInfinityV)
   at System.Windows.Controls.Grid.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at MS.Internal.Helper.MeasureElementWithSingleChild(UIElement element, Size constraint)
   at System.Windows.Controls.ContentPresenter.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.TextBlock.MeasureChild(InlineObject inlineObject)
   at MS.Internal.Text.InlineObject.Format(Double remainingParagraphWidth)
   at MS.Internal.TextFormatting.TextStore.FormatTextObject(TextEmbeddedObject textObject, Int32 cpFirst, Int32 currentPosition, Int32 rightMargin)
   at MS.Internal.TextFormatting.LineServicesCallbacks.InlineFormat(IntPtr pols, Plsrun plsrun, Int32 lscpInline, Int32 currentPosition, Int32 rightMargin, ObjDim& pobjDim, Int32& fFirstRealOnLine, Int32& fPenPositionUsed, LsBrkCond& breakBefore, LsBrkCond& breakAfter)
   --- End of inner exception stack trace ---
   at MS.Internal.TextFormatting.TextMetrics.FullTextLine.FormatLine(FullTextState fullText, Int32 cpFirst, Int32 lineLength, Int32 formatWidth, Int32 finiteFormatWidth, Int32 paragraphWidth, LineFlags lineFlags, FormattedTextSymbols collapsingSymbol)
   at MS.Internal.TextFormatting.TextMetrics.FullTextLine..ctor(FormatSettings settings, Int32 cpFirst, Int32 lineLength, Int32 paragraphWidth, LineFlags lineFlags)
   at MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
   at MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache)
   at System.Windows.Controls.TextBlock.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Border.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.DockPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.Control.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.Controls.VirtualizingStackPanel.MeasureOverride(Size constraint)
   at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
   at System.Windows.UIElement.Measure(Size availableSize)
   at System.Windows.ContextLayoutManager.UpdateLayout()
   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.Run()
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at Rim.Desktop.Shell.App.Main()

我无法在一个简单的应用程序中解决此问题.

I haven't been able to repo this problem in a simple application.

有人有运气来应对这些情况吗?

Has anyone had any luck dealing with these situations?

 

推荐答案

请确保您所有的度量替代程序函数都只保留正值.而不是任何负,nan或负无穷大值.
make sure that all your measure overrider functions returens only positive values. and not any negative, nan or negative infinite values.


这篇关于NaN布局测量崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆