verybadcat / CSharpMath

LaTeX. in C#. (ported from the wonderful iosMath project).
MIT License
384 stars 64 forks source link

Performance for real time applications #165

Open conicgames opened 4 years ago

conicgames commented 4 years ago

Hello!

I'm using CSharpMath for my Android game (Exponential Idle) and I really love it. However, when I use it to display many elements that changes every frame (~100ms), then game can get quite laggy. To avoid this issue, I started using a workaround where I split my LaTeX elements into 2 parts, a static part that doesn't change every frame, and the dynamic part. For the dynamic part, whenever I can, I create a native label using custom font with Computer Modern font characters (a mix of Italic and Regular), to get the same appearance as your library. It works quite well, but I find this solution to be really messy.

My question: Is there any way I can improve re-rendering performance in this context so I can continue only using your library? Text elements that change every frame usually look like "x_1 = 1.234e50", where the right side is dynamic.

Thanks!

Happypig375 commented 4 years ago

I think this can be improved by removing the unnecessary ToString -> reparse steps by the BindableProperties in MathView, mentioned at https://github.com/verybadcat/CSharpMath/pull/141#issuecomment-650753746. However, this is necessary for Content and LaTeX bindable properties of MathView to sync up. This is hard to solve. Any ideas?

(Btw, can you share how do you promote your game? I'd like CSharpMath to reach a larger audience too)

charlesroddie commented 3 years ago

Are you using CSharpMath.Forms or CSharpMath.SkiaSharp? Are you making sure to avoid the BindableProperties and generating TextPainters manually?

CSharpMath/LayoutFarm.Typography should have some performance, but tweaks getting some simple dynamically changing tex at 60fps should be very easy.

We get some performance issues on layout and resizing of larger documents but that operation is much more intensive.