ArgumentOutOfRangeException when calculating character bounds

SyntaxEditor for WPF Forum

Posted 2 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Version: 22.1.1
Platform: .NET 4.8
Environment: Windows 10 (64-bit)
Avatar

Hi,

we received another crash report by a customer, which I don' really understand. The callstack is rather long.

The exception occurrs when the tool is started and opens a specific file. It looks like something goes wrong when calculating the character bounds:

Unhandled Exception:System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentOutOfRangeException: The parameter value must be between '101' and '138'.
Parameter name: cpFirst
at MS.Internal.TextFormatting.TextFormatterImp.VerifyCaretCharacterHit(CharacterHit characterHit, Int32 cpFirst, Int32 cchLength)
at MS.Internal.TextFormatting.SimpleTextLine.GetDistanceFromCharacterHit(CharacterHit characterHit)
at MS.Internal.TextFormatting.SimpleTextLine.GetTextBounds(Int32 firstTextSourceCharacterIndex, Int32 textLength)
at ActiproSoftware.Windows.Controls.Rendering.TextLayoutLine.qrA(TextLine , Int32 , Double )
at ActiproSoftware.Windows.Controls.Rendering.TextLayoutLine.GetCharacterBounds(Int32 characterIndex, Boolean allowVirtualSpace)
at ActiproSoftware.Internal.pTY.GetCharacterBounds(Int32 )
at ActiproSoftware.Internal.pTY.GetCharacterColumn(Int32 )
at ActiproSoftware.Internal.pTY.get_IndentAmount()
at ActiproSoftware.Internal.ATM.OnViewTextAreaLayout(Object sender, TextViewTextAreaLayoutEventArgs e)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at System.Windows.RoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.TextView.umT(TextViewTextAreaLayoutEventArgs )
at ActiproSoftware.Internal.KTg.eMr()
at ActiproSoftware.Internal.RO.ArrangeOverride(Size )
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at ActiproSoftware.Internal.Ik.ArrangeOverride(Size )
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at ActiproSoftware.Internal.IT.ArrangeOverride(Size )
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at ActiproSoftware.Windows.Controls.SyntaxEditor.Primitives.EditorViewHost.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.DockPanel.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at ActiproSoftware.Windows.Controls.Docking.AdvancedTabControl.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at ActiproSoftware.Windows.Controls.Docking.Primitives.SplitContainerPanel.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at ActiproSoftware.Windows.Controls.Docking.Primitives.SplitContainerPanel.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at ActiproSoftware.Windows.Controls.Docking.DockHost.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Controls.Decorator.ArrangeOverride(Size arrangeSize)
at System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.Window.ArrangeOverride(Size arrangeBounds)
at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
at System.Windows.UIElement.Arrange(Rect finalRect)
at System.Windows.ContextLayoutManager.UpdateLayout()
at ActiproSoftware.Windows.Controls.Ribbon.Controls.Primitives.TabStrip.OWJ(Double )
at ActiproSoftware.Windows.Controls.Ribbon.Controls.Primitives.TabStrip.UWC(Object )
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)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext 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, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
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.DispatcherOperation.Wait(TimeSpan timeout)
at Vector.ITE.WpfCommon.Tools.Extensions.WaitForPendingOperations(Dispatcher dispatcher, DispatcherPriority priority)
at Vector.ITE.ViewManagement.ViewManagementServiceProvider.Show(IViewRepresentation view)
at Vector.ITE.ViewManagement.DocumentViewService.TryShow(IDocument document, IDocumentView& documentView)
at Vector.ITE.ViewManagement.DocumentViewService.TryShow(IDocument document)
at Vector.ITE.DocumentManagement.LoadedDocumentService.OpenViewInternal(IDocument document)
at Vector.ITE.DocumentManagement.LoadedDocumentService.OpenView(IDocument document)
at Vector.ITE.DocumentManagement.LoadedDocumentService.Open(IDocument document, String guid)
at Vector.ITE.DocumentManagement.LoadedDocumentService.OpenLoadedDocumentView(ILoadedDocument loadedDocument, String contextGuid)
at Vector.ITE.DocumentManagement.LoadedDocumentService.OpenDocumentInternal(String fullFilePath, IProjectContext context, Boolean unassignContextIfNull, String mainDocument, Boolean bChangeContextMsg)
at Vector.ITE.DocumentManagement.LoadedDocumentService.OpenDocument(String fullFilePath, IProjectContext context, Boolean unassignContextIfNull, String mainDocument, Boolean bChangeContextMsg)
at CAPLBrowser.AppSpecifics.ParBrowFileService.Open(String path)
at CAPLBrowser.App.CommandLineHandler.HandleInternal(String[] args)
at CAPLBrowser.App.CommandLineHandler.Handle(String[] args)
at CAPLBrowser.UI.MainViewModel.ProcessArguments(String[] args)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
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.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
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.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at ActiproSoftware.Windows.Interop.NativeMethods.o9F(IntPtr , UInt32 , dR& , UInt32 )
at ActiproSoftware.Windows.Interop.NativeMethods.o9F(IntPtr , UInt32 , dR& , UInt32 )
at ActiproSoftware.Windows.Interop.NativeMethods.ConfigureNonClientArea(Window window, Boolean isIconVisible, Boolean isTitleVisible)
at ActiproSoftware.Windows.Themes.WindowChromeManager.rXb()
at ActiproSoftware.Windows.Themes.WindowChromeManager.xXp()
at ActiproSoftware.Windows.Themes.WindowChromeManager.zXS(Object , EventArgs )
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Window.OnSourceInitialized(EventArgs e)
at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
at System.Windows.Window.ShowHelper(Object booleanBox)
at System.Windows.Application.<>c.<RunInternal>b__105_0(Object obj)
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)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext 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, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at Vector.ITE.Backbone.Startup.SingleInstanceApp.Run(String[] instanceArgs)
at CAPLBrowser.App.CbrBootstrapper.$_executor_Run(String[] commandLineArgs, Container container)
at CAPLBrowser.App.CbrBootstrapper.Run(String[] commandLineArgs, Container container)
at Vector.ITE.Modularity.BootstrapperBase.RunCore(AssemblyCatalog assemblyCatalog, String cacheFile, ApplicationScope applicationScope, ApplicationMode applicationMode, String[] commandLineArgs)
at CAPLBrowser.App.Program.Main(String[] args)


Best regards, Tobias Lingemann.

Comments (8)

Posted 2 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

Okay, I was able to reproduce the issue with the file from the customer and version 22.1.4.

The problem only occurs if the three options "IsWhitespaceVisible", "AreIndentationGuidesVisible" and "IsWordWrapEnabled" are all enabled. If either "IsWordWrapEnabled" is disabled or the other too, the problem does not occur.

Another factor seems to be that the file contains a lot of generated code blocks. They are collapsed by default, but even if I expand all, the problem persists. Simply creating outlining nodes for them seems to cause the issue.

Update: I have added a partial callstack with the parameter values. I am not sure why "textLength" has the value -118, when you call it with 1.

PresentationCore.dll!MS.Internal.TextFormatting.TextFormatterImp.VerifyCaretCharacterHit(System.Windows.Media.TextFormatting.CharacterHit characterHit, int cpFirst, int cchLength)
PresentationCore.dll!MS.Internal.TextFormatting.SimpleTextLine.GetDistanceFromCharacterHit(System.Windows.Media.TextFormatting.CharacterHit characterHit)
PresentationCore.dll!MS.Internal.TextFormatting.SimpleTextLine.GetTextBounds(int firstTextSourceCharacterIndex = 121, int textLength = -118)
ActiproSoftware.Shared.Wpf.dll!ActiproSoftware.Windows.Controls.Rendering.TextLayoutLine.V7B(System.Windows.Media.TextFormatting.TextLine = {MS.Internal.TextFormatting.SimpleTextLine}, int = 2, double = 29.31999984741211)
ActiproSoftware.Shared.Wpf.dll!ActiproSoftware.Windows.Controls.Rendering.TextLayoutLine.GetCharacterBounds(int characterIndex = 2, bool allowVirtualSpace = false)
ActiproSoftware.SyntaxEditor.Wpf.dll!ActiproSoftware.Internal.o2F.GetCharacterBounds(int = 191)
ActiproSoftware.SyntaxEditor.Wpf.dll!ActiproSoftware.Internal.o2F.GetCharacterColumn(int = 191)
ActiproSoftware.SyntaxEditor.Wpf.dll!ActiproSoftware.Internal.o2F.IndentAmount.get()

[Modified 2 months ago]


Best regards, Tobias Lingemann.

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

It appears to be where the TextViewLine.IndentAmount is being requested, which could very well be in IndentationGuideAdornmentManager since you said you have AreIndentationGuidesVisible set.  The IndentAmount method tries to determine the character column, so it passes in the offset of the first non-whitespace character and that translates over to a character index in a layout line.  When the layout line (our code) goes ask the WPF TextLine for the character bounds of the character index, it seems the index is somehow out of bounds for that WPF TextLine.

You said it's some combination of visible whitespace, indentation guides, and word wrap that is triggering the issue.  And possibly generated code blocks that are collapsed by default.  If you do NOT have the code blocks collapsed, do you see the issue?  That would be the first thing I'd look into, especially since collapsing text ranges is a big part of translating offsets to character indices, which seems to be the issue here.

Also, do you have any collapsed code blocks sequentially, one right after the other with no characters in between?

Regarding the WPF SimpleTextLine class, I'm not sure how they store things internally.  Perhaps the negative number is saying that many characters have been collapsed?  But still it's odd that it's not zero or above.

Now that you have an idea of the triggers, if you could create a new simple sample project showing it happen, we could debug with that and really see what's going on.  Please send one to our support address, remove the bin/obj folders from the .zip you send so it doesn't get spam blocked, and reference this thread.  Then we'll dig in and sort it out.  Thank you!


Actipro Software Support

Posted 2 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

I have not yet been able to reproduce the issue with a demo application. I have tried a few things to minimize the differences. I even added a dummy parser. However here are a few things I have noticed:

  • The problem does not occur if 'IsDefaultCollapsed' is disabled.
  • All collapsed code blocks here have at least two characters between them (for example the previous ends with offset 16260 and the next start with 16263).
  • However there are code blocks that have no characters beteween them.
  • The blocks are not added in an sequential order (depending on their start offset), but rather depending of their type (first all function nodes are added, before the generated code blocks are added).
  • The problem does not occur when I react to text changes instead of changes of parse data (however then outlining incomplete or outdated)
  • The OutliningSource is called twice (first for the empty document and then when the document is loaded).


Best regards, Tobias Lingemann.

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Tobias,

In the bullet points, you said all collapsed code blocks have at least two characters between them, and in the next bullet, it says there are some code blocks without any characters between them.  I assume those latter code blocks are NOT collapsed? 

I don't think the order in which code blocks are added would matter since that's all done in a standalone phase from when the view lines are actually generated.


Actipro Software Support

Posted 2 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

I assume those latter code blocks are NOT collapsed? 

Yes. The collapsed code blocks are for generated code and for those 'IsDefaultCollapsed' is enabled. For all other code blocks (functions, regions, etc.) the property is disabled. After the document is loaded we restore the node state (collapsed or expanded) from the previous session. But this doesn't seem to play a role here.


Best regards, Tobias Lingemann.

Posted 2 months ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

I have not yet been able to reproduce the issue within a demo application. Would it be helpful if I just send you a memory dump?


Best regards, Tobias Lingemann.

Posted 2 months ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Unfortunately not.  For things like this, we really need a simple repro project  so we can debug what's going on and walk through the state of everything.  That also lets us test that any code changes we make resolve the issue.


Actipro Software Support

The latest build of this product (v23.1.0) was released 2 months ago, which was before the next post in this thread.
Posted 25 days ago by Tobias Lingemann - Software Devolpment Engineer, Vector Informatik GmbH
Avatar

I finally was able to create a demo project and have send it to your support address.

The final missing piece was that my demo parser needs to include a little Thread.Sleep(). I have no idea how this correlates with the problem. But when I remove the sleep or make it longer, the problem does not occur.


Best regards, Tobias Lingemann.

Add Comment

Please log in to a validated account to post comments.