Skip to content

[BUG] Package adds unnecessary unused fonts to resources in web #773

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

Closed
antdementyev opened this issue Jul 24, 2021 · 8 comments
Closed
Labels
bug Something isn't working

Comments

@antdementyev
Copy link

Describe the bug:

Using of the package adds unnecessary KaTeX fonts from flutter_math_fork to built resources in web. It increases the size and delays the loading of the Webapp.

HTML to reproduce the issue:

Reference flutter_html in dependencies:

dependencies:
  flutter_html: ^2.1.0

Use it somewhere in code, e.g. in simple Hello-World created by Android-Studio

@override
Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("any")),
      body: Html(data: "something",),        <----  simple using of package
    );
}

Build web project

flutter build web

Built web contains a lot of KaTeX fonts with 660 kB even if they are nowhere used or referenced:

$ ls build/web/assets/packages/flutter_math_fork/lib/katex_fonts/fonts/ 
KaTeX_AMS-Regular.ttf           KaTeX_Fraktur-Bold.ttf          KaTeX_Main-BoldItalic.ttf       KaTeX_Math-BoldItalic.ttf       KaTeX_SansSerif-Italic.ttf      KaTeX_Size1-Regular.ttf         KaTeX_Size4-Regular.ttf
KaTeX_Caligraphic-Bold.ttf      KaTeX_Fraktur-Regular.ttf       KaTeX_Main-Italic.ttf           KaTeX_Math-Italic.ttf           KaTeX_SansSerif-Regular.ttf     KaTeX_Size2-Regular.ttf         KaTeX_Typewriter-Regular.ttf
KaTeX_Caligraphic-Regular.ttf   KaTeX_Main-Bold.ttf             KaTeX_Main-Regular.ttf          KaTeX_SansSerif-Bold.ttf        KaTeX_Script-Regular.ttf        KaTeX_Size3-Regular.ttf
$ du -sh build/web/assets/packages/flutter_math_fork/lib/katex_fonts/fonts/
660K    build/web/assets/packages/flutter_math_fork/lib/katex_fonts/fonts/

and they all are added to built build/web/assets/FontManifest.json

Html widget configuration:
See example above

Expected behavior:

No unused fonts and other resources should be added to built resources

Device details and Flutter/Dart/flutter_html versions:

Flutter 2.2.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision d79295af24 (6 weeks ago) • 2021-06-11 08:56:01 -0700
Engine • revision 91c9fc8fe0
Tools • Dart 2.13.3
@antdementyev antdementyev added the bug Something isn't working label Jul 24, 2021
@tneotia
Copy link
Contributor

tneotia commented Jul 24, 2021

This is just because we have the plugin bundled in. See #661 which would allow users to opt-in to all packages used, thereby removing unnecessary bloat for users who don't want features like these and instead want basic HTML rendering.

@antdementyev
Copy link
Author

antdementyev commented Jul 24, 2021

Open since May... Until it is done, is there only one way for the issue: just accept it?

@tneotia
Copy link
Contributor

tneotia commented Jul 24, 2021

Currently yes, unless you wish to clone it and remove the dependency by hand, and finally point your pubspec to the path of the cloned package.

Because it is such a massive change it has been open for that long, and plus the maintainers of the package (@erickok and/or @ryan-berger) have been pretty busy recently, they have not had time to review those big PRs. Apologies for the inconvenience but we don't really have control over what things our dependencies load, and plus there is not much alternatives to show LaTeX content in Flutter at the moment.

@antdementyev
Copy link
Author

ok, thanks for a quick reply

@erickok
Copy link
Contributor

erickok commented Jul 24, 2021

I'm sorry I haven't been able to work much on the package. It will get much better mid August.

A workaround is to override and remove this dependency.

@devrobbey
Copy link

Did you have a chance to take a look on this issue @erickok ? Reducing payload could really help making web loading time faster!!

@erickok
Copy link
Contributor

erickok commented Sep 1, 2021

It's connected to the modularisation of the library, which is big but the most important thing we are (slowly) working on.

@tneotia
Copy link
Contributor

tneotia commented Jan 6, 2022

Modularization is now complete with v3.0.0-alpha.2!

@tneotia tneotia closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants