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

'Failed to load font' error #560

Open
guidezpl opened this issue Feb 26, 2024 · 7 comments
Open

'Failed to load font' error #560

guidezpl opened this issue Feb 26, 2024 · 7 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request p: google_fonts

Comments

@guidezpl
Copy link
Collaborator

guidezpl commented Feb 26, 2024

Package

google_fonts

Description

If you ran into this error, it means that an attempt was made to fetch a font TTF file from Google Fonts' servers, but failed. For example:

Exception has occurred.
_Exception (Exception: Failed to load font with url https://fonts.gstatic.com/s/a/85fcd167f63837ebb1c310a8e83bf1d5039fbbd5a13ac4812691d52817631161.ttf: Failed host lookup: 'fonts.gstatic.com')

Solution

The most common reason is the device/emulator/simulator doesn't have internet access.

Background

The default behavior for this package is to fetch (and cache) fonts from the Internet at runtime. Including chosen fonts at build time is also supported, instructions for doing this are in the README.

Still need help?

If you ran into this issue and have eliminated all possible causes listed above, please comment with all relevant information (Wi-Fi / mobile network, target device & OS, flutter version -v, etc.)

@offline-first
Copy link

The problem is that despite "catchError" an error is logged in the Firebase console.

For example:

GoogleFonts.pendingFonts([
      GoogleFonts.soraTextTheme(),
    ]).then((value){
      debugPrint("[Theme][fetchFonts] all font fetched!");
    }, onError: (e)async{
      debugPrint("[Theme][fetchFonts] error: $e");
    }).catchError((e){
      debugPrint("[Theme][fetchFonts] catchError: $e");
    });```

@Princewil

This comment was marked as spam.

@Princewil
Copy link

Any fix for this?

@rockeypandit
Copy link

rockeypandit commented May 22, 2024

Any Fix to this ? its been long since the issue is opened

@Tr736
Copy link

Tr736 commented May 24, 2024

Also seeing thousands of these errors thrown in sentry. Please fix

@treeplate
Copy link

read the "solution" part of the OP's comment

@kaboc
Copy link

kaboc commented May 29, 2024

The solutions listed there only help those who have no idea what has caused the errors. In my case, I already know why they are thrown.

Excerpt from the README:

  • HTTP fetching at runtime, ideal for development. Can also be used in production to reduce app size
  • Font file caching, on device file system
  • Font bundling in assets. Matching font files found in assets are prioritized over HTTP fetching. Useful for offline-first apps.

I wouldn't choose HTTP fetching if the document strongly recommended we avoid it, or if fetching should never fail. However, it is clearly stated that it can be used in production, and I think everyone knows that fetching fails if there is no Internet connection or the servers are down. "To reduce app size" is a very common reason we choose it over bundling if the app is not offline-first. I (and probably some others here) have opted in to use HTTP fetching, already knowing connection errors sometimes occur.

In that case, thousands of error logs appearing in an error monitoring tool are just a noise. It is possible to mark those logs as "closed" on Crashlytics to make them hidden, but I've heard that having a large number of errors affects the visibility of the app in the Play Store. (I'm not sure about the App Store and whether errors marked as closed still have a negative impact in the same way.) Shouldn't there be a way to mute such logs on the app side? Or should I manually check the error message to exclude this particular error from the logs sent to Crashlytics?

@guidezpl guidezpl mentioned this issue Jul 2, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request p: google_fonts
Projects
None yet
Development

No branches or pull requests

7 participants