Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextFormatter port issues #243

Open
Gillibald opened this issue Aug 2, 2022 · 21 comments
Open

TextFormatter port issues #243

Gillibald opened this issue Aug 2, 2022 · 21 comments

Comments

@Gillibald
Copy link
Contributor

Gillibald commented Aug 2, 2022

The TextFormatter port aka Avalonia 11.0 support can be tested via: https://github.com/AvaloniaUI/AvaloniaEdit/tree/dev

Post your issues here if you find any. Our fork now follows more closely the original project's source.

@Gillibald Gillibald changed the title TextFormatter rework issues TextFormatter port issues Aug 2, 2022
@Gillibald
Copy link
Contributor Author

Gillibald commented Aug 2, 2022

@danipen

  • Long lines support is broken again. Editing/selection/going home-end in very long line is super slow. You can find a test file

@Gillibald
Copy link
Contributor Author

Gillibald commented Aug 2, 2022

  • Slow performance scrolling a file on macOS

@danipen
Copy link
Collaborator

danipen commented Aug 6, 2022

  • We're leaking thousands of ForegroundTextTransformations when scrolling a document.
    image

@Gillibald
Copy link
Contributor Author

Are we leaking TextLines as well?

@danipen
Copy link
Collaborator

danipen commented Aug 6, 2022

No. It seems we're only leaking ForegroundTextTransformation objects in some kind of cycle.
image

@HendrikMennen
Copy link
Contributor

HendrikMennen commented Sep 5, 2022

Just tried this, most things work.
One thing I noticed is folding is broken:

 Specified argument was out of the range of valid values.
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
   at Avalonia.Media.TextFormatting.Unicode.Codepoint.ReadAt(ReadOnlySlice`1 text, Int32 index, Int32& count) in /_/src/Avalonia.Base/Media/TextFormatting/Unicode/Codepoint.cs:line 170
   at Avalonia.Media.TextFormatting.Unicode.LineBreakEnumerator.NextCharClass() in /_/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreakEnumerator.cs:line 295
   at Avalonia.Media.TextFormatting.Unicode.LineBreakEnumerator.MoveNext() in /_/src/Avalonia.Base/Media/TextFormatting/Unicode/LineBreakEnumerator.cs:line 57
   at Avalonia.Media.TextFormatting.TextFormatterImpl.TryGetLineBreak(TextRun textRun, LineBreak& lineBreak) in /_/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs:line 454
   at Avalonia.Media.TextFormatting.TextFormatterImpl.FetchTextRuns(ITextSource textSource, Int32 firstTextSourceIndex, TextEndOfLine& endOfLine, Int32& textSourceLength) in /_/src/Avalonia.Base/Media/TextFormatting/TextFormatterImpl.cs:line 407
   at Avalonia.Media.TextFormatting.TextFormatterImpl.FormatLine(ITextSource textSource, Int32 firstTextSourceIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak) in /_/src/Avalonia.Base/Media/TextFormatting/T
extFormatterImpl.cs:line 62
   at AvaloniaEdit.Rendering.TextView.BuildVisualLine(DocumentLine documentLine, TextRunProperties globalTextRunProperties, VisualLineTextParagraphProperties paragraphProperties, VisualLineElementGenerator[] elementGeneratorsArray, IVisualLineTransformer[] lineTra
nsformersArray, Size availableSize) in C:\Users\hmenn\source\repos\VHDP\AvaloniaEdit\src\AvaloniaEdit\Rendering\TextView.cs:line 1122
   at AvaloniaEdit.Rendering.TextView.CreateAndMeasureVisualLines(Size availableSize) in C:\Users\hmenn\source\repos\VHDP\AvaloniaEdit\src\AvaloniaEdit\Rendering\TextView.cs:line 1011
   at AvaloniaEdit.Rendering.TextView.MeasureOverride(Size availableSize) in C:\Users\hmenn\source\repos\VHDP\AvaloniaEdit\src\AvaloniaEdit\Rendering\TextView.cs:line 941
   at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) in /_/src/Avalonia.Base/Layout/Layoutable.cs:line 520
   at Avalonia.Layout.Layoutable.Measure(Size availableSize) in /_/src/Avalonia.Base/Layout/Layoutable.cs:line 385
   at Avalonia.Layout.LayoutManager.Measure(ILayoutable control) in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 274
   at Avalonia.Layout.LayoutManager.ExecuteMeasurePass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 250
   at Avalonia.Layout.LayoutManager.InnerLayoutPass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 232
   at Avalonia.Layout.LayoutManager.ExecuteLayoutPass() in /_/src/Avalonia.Base/Layout/LayoutManager.cs:line 145
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) in /_/src/Avalonia.Base/Threading/JobRunner.cs:line 38
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 287
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) in /_/src/Windows/Avalonia.Win32/Win32Platform.cs:line 214
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) in /_/src/Avalonia.Base/Threading/Dispatcher.cs:line 61
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 120
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 209
   at VHDPlus.Program.Main(String[] args) in C:\Users\hmenn\source\repos\VHDP\VHDPlus\Program.cs:line 95

@Gillibald
Copy link
Contributor Author

Could you provide the actual text you tried to display?

@HendrikMennen
Copy link
Contributor

The text is not relevant here I guess.
It's simply the folding feature that does not work yet:
image

@Gillibald
Copy link
Contributor Author

As long it is simply reproducible for me this should be simple to fix

@danipen
Copy link
Collaborator

danipen commented Sep 5, 2022

BTW @Gillibald this one is fixed with Avalonia 11:

Slow performance scrolling a file on macOS

So feel free to mark it as completed (checked).

@HendrikMennen
Copy link
Contributor

image

@Gillibald Is there a setting to prevent this from happening? For Code I prefer <=

@Gillibald
Copy link
Contributor Author

Currently not out of the box. There are plans to introduce an API that allows to enable / disable certain font features like liga etc.

If you don't want ligatures at all you need to register a custom text shaper that disables this feature or use a font that does not have this ligature.

@HendrikMennen
Copy link
Contributor

Thank you I just changed to a different font.
One more thing I noticed is the flickering in this version.
Seems like before providing a new frame, the old frame is cleared first.
Here a gif a 0.5x speed:
ezgif-4-963b4f8429

@danipen
Copy link
Collaborator

danipen commented Sep 7, 2022

Yes. That flickering is new in Avalonia 11.

Probably related (or same issue) to this: AvaloniaUI/Avalonia#8830

@danipen
Copy link
Collaborator

danipen commented Sep 8, 2022

The IBeam mouse pointer is lost when hovering text:
mouse-pointer-lost

@danipen
Copy link
Collaborator

danipen commented Sep 8, 2022

Unfortunately the following PR doesn't fix the flickering issue while selecting text: AvaloniaUI/Avalonia#8918

@Gillibald any idea of what's going on there? This didn't happen on the stable 0.10.x
blinking

@Gillibald
Copy link
Contributor Author

Will have a look next week. Probably some issue with the way VisualLine is being rendered.

@Gillibald
Copy link
Contributor Author

@HendrikMennen I can't repro the folding issue with AvaloniaEdit.Demo I need a repro to fix your issue

@Gillibald
Copy link
Contributor Author

@danipen #252

@HendrikMennen
Copy link
Contributor

Its quite weird: For testing I used this folding strategy: https://github.com/icsharpcode/AvalonEdit/blob/master/ICSharpCode.AvalonEdit.Sample/BraceFoldingStrategy.cs

This works:
image
These examples crash:
image
image
image

I guess you used the builtin XmlFoldingStrategy to reproduce?
In that case use this xml code:

<Project Sdk="Microsoft.NET.Sdk">

  CRASH here ! <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <WarningsNotAsErrors>0612,0618</WarningsNotAsErrors>
	<PackageId>Avalonia.AvaloniaEdit</PackageId>
  </PropertyGroup>

</Project>

@Gillibald
Copy link
Contributor Author

Y I was using the XmlFoldingStrategy. Let me try your implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants