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

DOMException: A network error occurred while loading sans-serif font face #284

Closed
suresh-gangumalla opened this issue May 30, 2024 · 9 comments · Fixed by #344
Closed

DOMException: A network error occurred while loading sans-serif font face #284

suresh-gangumalla opened this issue May 30, 2024 · 9 comments · Fixed by #344
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@suresh-gangumalla
Copy link
Contributor

Observed an exception while loading sans-serif as default font face.
renderer-sans-serfi-error

https://github.com/lightning-js/renderer/blob/main/src/core/text-rendering/renderers/CanvasTextRenderer.ts#L148

@uguraslan
Copy link

It appears that the variable fontUrlWithoutParentheses, as defined here, is assigned an empty string when using the default sans-serif font. So the fontFace.load() method, called here, tries to load a font from this URL, resulting in a failure since the URL is an empty string.

The FontFace constructor requires the source parameter to be either a valid URL or binary font face data.

@frank-weindel frank-weindel added good first issue Good for newcomers help wanted Extra attention is needed labels Jun 26, 2024
@wouterlucas
Copy link
Contributor

Need to retest if this still happens with #319

@suresh-gangumalla
Copy link
Contributor Author

@wouterlucas
the issue is still reproducing. I have verified this against latest dev branch, 1.0.0-rc.3.

font-1

@elsassph
Copy link
Contributor

elsassph commented Jul 11, 2024

@wouterlucas I was investigating it and indeed as @suresh-gangumalla pointed out, the CanvasTextRenderer "loads" a default sans-serif font using WebTrFontFace, but the DOM FontFace will throw this error when the URL is empty.

It is harmless in itself but unnecessary. I presume we could avoid calling FontFace.load and just flag it as loaded.

Also regarding system fonts in general, L3 has a copy of some L2 code which include a bug/limitation fixed since in L2: rdkcentral/Lightning#539

@elsassph
Copy link
Contributor

elsassph commented Jul 11, 2024

Generally canvas font loading needs to be revisited: the systematic call to globalFontSet.load looks problematic IMHO as it makes all text metrics/rendering asynchronous, even when fonts have been long loaded.

@frank-weindel
Copy link
Collaborator

@elsassph One of the #322 canvas experiments addresses that and provides a path for loading the texture completely synchronously if the font is already loaded.

@wouterlucas
Copy link
Contributor

Let's do a temp fix on the current code base until #322 is mature enough to move along.

@elsassph
Copy link
Contributor

I'm concerned about whether #322 will progress while Frank is away. Some improvements should be extracted into granular PRs.

@wouterlucas
Copy link
Contributor

It will, I just want a stopgap solution in there so that the error is gone and so we can do our due diligence on #322

Agree that chopping it up in smaller PRs is a good idea.

@Drulokia Drulokia linked a pull request Jul 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants