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

Control Typography memory usage #107

Open
charlesroddie opened this issue Jan 26, 2020 · 12 comments
Open

Control Typography memory usage #107

charlesroddie opened this issue Jan 26, 2020 · 12 comments
Labels
Status/2. Awaiting dependency This issue is a problem of an underlying dependency which has yet to fix this issue. Type/Enhancement

Comments

@charlesroddie
Copy link
Collaborator

charlesroddie commented Jan 26, 2020

CSharpMath uses a lot of memory via Typography:

image

Possible improvements would be some combination of loading glyphs lazily and storing them more efficiently.

Can this be improved from within CSharpMath or should this be an issue in https://github.com/LayoutFarm/Typography ?

@Happypig375
Copy link
Collaborator

Currently CSharpMath stores Typeface objects in memory which is basically an entire otf file parsed into table objects. latinmodern-math.otf weighs 717KiB, and AMS-Capital-Blackboard-Bold.otf weighs 8.51KiB. However, the inclusive size shown is an order of magnitude larger than the size of the source files.

@charlesroddie
Copy link
Collaborator Author

Presumably the issue involves:

  1. Loading an entire font at a time rather than characters lazily
  2. A memory-inefficient representation of a character

Are both of these issues for the typography repo, or is there anything that can be improved here?

@Happypig375
Copy link
Collaborator

@prepare Thoughts?

@prepare
Copy link

prepare commented Feb 1, 2020

I think some objects could be unloaded/dispose
eg.

  1. List<Type2Instruction> could be unload after you create a glyph outline from it.
  2. Unload many openfont tables that are not need by user

but this I have to test it first

@Happypig375 Happypig375 added the Status/2. Awaiting dependency This issue is a problem of an underlying dependency which has yet to fix this issue. label Feb 1, 2020
@prepare
Copy link

prepare commented Jun 28, 2020

please visit and test 'Trimmable features' again, see=> LayoutFarm/Typography#187

@Happypig375
Copy link
Collaborator

So there are two ways forward with the Typography submodule:

@prepare @charlesroddie Thoughts?

@charlesroddie
Copy link
Collaborator Author

I don't believe CSharpMath is affected much by the NRT PR LayoutFarm/Typography#192. That PR makes it easier for Typography to control NRE bugs and to do further development without having to worry about NREs. However it's not worth forking Typography just for that. If the @prepare prefers to do more work to implement features safely that is up to him!

CSharpMath should depend on Typography master branch if possible, through the submodule for now, and through a nuget package when Typography stabilizes.

Note that it can't use the current state of Typography master as UWP support is broken by the netstandard2.1 change.

@prepare
Copy link

prepare commented Jun 30, 2020

Hello

Note that it can't use the current state of Typography master as UWP support is broken by the netstandard2.1 change.

I move back to netstandard 2.0, please check again :)

LayoutFarm/Typography@0899ddf

@Happypig375
Copy link
Collaborator

Happypig375 commented Jun 30, 2020

@charlesroddie How the NRT PR affects CSharpMath can be seen through the difference between using null-oblivious and null-explicit APIs. By dropping the current submodule reference to LayoutFarm/Typography#192, all Typography APIs currently is use will start ignoring accidental nulls during compile-time, leaving bugs to be caught run-time.

@Happypig375
Copy link
Collaborator

@prepare @charlesroddie Seems that LayoutFarm/Typography#192 will never be merged. Should we drop it and update or should we resolve merge conflicts?

@charlesroddie
Copy link
Collaborator Author

That is a shame if true. @prepare it would be good to have your thoughts on that PR even if in an initial form. Maintaining a branch or fork of typography for use in CSharpMath would require a lot of work on @Happypig375 's part, and is unfeasible to maintain indefinitely IMO. So if it will really never be merged then dropping and accepting a less safe typography library for use in CSharpMath is inevitable.

@prepare
Copy link

prepare commented Jul 14, 2020

@Happypig375 👍

I want to confirm that the LayoutFarm/Typography#192 is NOT your waste time.

But I can't merge it directly now because of this LayoutFarm/Typography#192 (comment) too.


By the way,
The Typography (TextServices, TextSpanPrinter etc.) is now under refactoring-code-arrangement phase again,

It will be released this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status/2. Awaiting dependency This issue is a problem of an underlying dependency which has yet to fix this issue. Type/Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants