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

Fontawesome 5 error randomly on j5 #42611

Closed
trananhmanh89 opened this issue Jan 5, 2024 · 67 comments
Closed

Fontawesome 5 error randomly on j5 #42611

trananhmanh89 opened this issue Jan 5, 2024 · 67 comments

Comments

@trananhmanh89
Copy link
Contributor

trananhmanh89 commented Jan 5, 2024

Steps to reproduce the issue

I can't tell, because it happens randomly, and it's gone after several refreshes.

Expected result

Fontawesome should show fine.

Actual result

Check the image

image

System information (as much as possible)

chrome browser
windows 11
cpu intel i5-8400
nvidia card 1050ti
php82
mysql 80
apache 2.4.52

Additional comments

Does anyone have this issue?

@joeforjoomla
Copy link
Contributor

Confirmed. It happens to me too. After clearing the browser cache and reloading the page, everything is back to normal.

@fgsw
Copy link

fgsw commented Jan 5, 2024

Does anyone have this issue?

Using Joomla5 since 2 month never happened.

System information

PHP Built On Linux lamp302.cloudaccess.net 3.10.0-962.3.2.lve1.5.81.el6h.x86_64 #1 SMP Wed May 31 12:07:35 UTC 2023 x86_64
Database Type mysql
Database Version 8.0.34-cll-lve
Database Collation utf8mb4_general_ci
Database Connection Collation utf8mb4_0900_ai_ci
Database Connection Encryption None
Database Server Supports Connection Encryption Yes
PHP Version 8.1.26
Web Server Apache
WebServer to PHP Interface cgi-fcgi
Joomla! Version Joomla! 5.0.1 Stable [ Kuboresha ] 28-November-2023 16:00 GMT
Joomla Backward Compatibility Plugin Enabled (classes_aliases:"1", es5_assets:"1")
User Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:121.0) Gecko/20100101 Firefox/121.0

@brianteeman
Copy link
Contributor

It happens to me quite often as well. Thought it was just me but obviously not

@richard67 richard67 added the bug label Jan 5, 2024
@richard67
Copy link
Member

Does the network tab of the browser's developer tools show something when this happens, or does the browser's error console?

@richard67
Copy link
Member

@brianteeman Is it also with the Chrome browser in your case? Or also with other browsers?

@trananhmanh89
Copy link
Contributor Author

@brianteeman Is it also with the Chrome browser in your case? Or also with other browsers?

My colleagues are using firefox and do not face this issue till j5 update. Thought might because chrome and nvidia graphic card.

@brianteeman
Copy link
Contributor

@brianteeman Is it also with the Chrome browser in your case? Or also with other browsers?

I only use Chrome on Windows

@richard67
Copy link
Member

Does it also happen with Joomla 4.4.x? Or only with 5?

@brianteeman
Copy link
Contributor

Does it also happen with Joomla 4.4.x? Or only with 5?

For me just in j5

@joeforjoomla
Copy link
Contributor

It seems just in J5

@joeforjoomla
Copy link
Contributor

UPDATE: it also happens on J4

@ssnobben
Copy link

ssnobben commented Jan 6, 2024

Do you have any conflicting Fontawesome installed before updating?

@chmst
Copy link
Contributor

chmst commented Jan 6, 2024

I cannot replicate - win11 with different browsers but always correct icons. A conflict with former versions could explain the effect

@brianteeman
Copy link
Contributor

Completely clean install just now on localhost of current 5.1git.

No console errors and as soon as you hit refresh it works

image

@richard67
Copy link
Member

Maybe the issue is somehow related to the font-display CSS property? Maybe it has something to do with optimizations with Chrome version 83 for handling "font-display: optional" which are mentioned on this page https://web.dev/articles/preload-optional-fonts?hl=en and more detailed handled here: https://bugs.chromium.org/p/chromium/issues/detail?id=1040632 ?

@richard67
Copy link
Member

Unfortunately I can't reproduce it here.

@brianteeman
Copy link
Contributor

I can't reproduce it on demand either. Although lats night I did see it twice on a site that was not one of my own. The link you shared about font-display does sound similar

@Fedik
Copy link
Member

Fedik commented Jan 7, 2024

I cannot reproduce it,
However I suspect it may also be related to file loading or server response. Because of:

... and as soon as you hit refresh it works

That sounds like the initial load went wrong, and cached version works.

Try disable cache:

  • Open Dev Tools Network tab
  • Check "Disable cache" checkbox
  • Reload the page. Now every reload will be without cache while Dev Tools is opened.

Do you able to reproduce it every time now?
Addittinaly try "Network throttling".

If you able to reproduce then also please look for a response headers for fa-solid-900.woff2 does it font/woff2 or something else?

@brianteeman
Copy link
Contributor

I just observed this on a developers website
image

When I checked with chrome inspector it did show the woff2 files as loaded
It did NOT show joomla-fontawesome.min.css as loaded
It did not show any errors

@trananhmanh89
Copy link
Contributor Author

trananhmanh89 commented Jan 11, 2024

when the icon get error, chrome didn't load any css from joomla

image

And this is when no icon issue

image

fact: open new tab with same url, the issue will gone
fact2: i even faced this issue when using a site that behind cloudflare cdn

@brianteeman
Copy link
Contributor

I strongly suspect that this is caused by something related to #32141

// Defer fontawesome for increased performance. Once the page is loaded javascript changes it to a stylesheet.

@richard67
Copy link
Member

I strongly suspect that this is caused by something related to #32141

// Defer fontawesome for increased performance. Once the page is loaded javascript changes it to a stylesheet.

@brianteeman Yes, I have the same thing in mind. On my private website I have disabled that lazy loading of the fonteawesome fonts in my child template.

@Fedik
Copy link
Member

Fedik commented Jan 13, 2024

Nope, that PR affecting only frontend, and the issue about admin side.

@trananhmanh89
Copy link
Contributor Author

Update: chrome on ubuntu also got this issue.

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Jan 18, 2024

It’s either:

  • the server (mime types, etc)
  • Some plugin doing something stupid
  • Wrong CSP configuration

@Fedik
Copy link
Member

Fedik commented Jan 18, 2024

Another thing I would probably try is to use the preload header for the fonts for admin.
In j4 FA font files size ~160kb
in j5 FA font files size ~260kb

@dgrammatiko
Copy link
Contributor

At the time we were doing those optimizations preload wasn’t supported across the board but now should be done, no questions asked

@brianteeman
Copy link
Contributor

It’s either:

  • the server (mime types, etc)
  • Some plugin doing something stupid
  • Wrong CSP configuration

At least in my case I have observed this with clean joomla installs so that would rule out the plugin or csp and if it works on reload it cant be the mime types

@Fedik

This comment was marked as outdated.

@Fedik
Copy link
Member

Fedik commented Feb 22, 2024

Please try following, edit Fontawesome css, manualy and place:

@charset "utf-8";

at top of each file .css and .min.css:

media/templates/administrator/atum/css/vendor/fontawesome-free/fontawesome.css
media/templates/administrator/atum/css/vendor/fontawesome-free/fontawesome.min.css

it looks like Browser get confused with content encoding, randomly.

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Feb 22, 2024

@Fedik what's unfortunate here is that when we had Postcss, the @charset was always appended...

Basically if it's a lightningcss issue (ie: parcel-bundler/lightningcss#310) someone could enable debug and check if the problem occurs there as well (the non minified css file is not passed through lightningcss iirc)

@brianteeman
Copy link
Contributor

The description in this comment exactly matches my own observations FortAwesome/Font-Awesome#10842 (comment)

@Fedik
Copy link
Member

Fedik commented Feb 23, 2024

@dgrammatiko it more about sass compiler (or probably both sass and lightning css), this potato removes @charset when detect UTF8, even with charset: true.
Only way I see is to prepend it manualy

@trananhmanh89
Copy link
Contributor Author

trananhmanh89 commented Feb 23, 2024

@dgrammatiko it more about sass compiler (or probably both sass and lightning css), this potato removes @charset when detect UTF8, even with charset: true. Only way I see is to prepend it manualy

Hi,
I've compiled font awesome of atum template by using dart-sass, and the result is very different. Could you check?
The left is mine, the right is from joomla atum
image

@Fedik
Copy link
Member

Fedik commented Feb 23, 2024

Your with escaped symbols, and joomla with non-escaped.
Techicaly both should work the same, but somehow non-escaped seems not always as good as should.

@dgrammatiko
Copy link
Contributor

Isn’t sass and dart-sass the same package?

@trananhmanh89
Copy link
Contributor Author

Isn’t sass and dart-sass the same package?

If you use this command to install sass

npm install -g sass

so it's dart-sass.

https://www.npmjs.com/package/sass

@Fedik
Copy link
Member

Fedik commented Feb 23, 2024

Btw, we use sass-embedded wich is dart-sass, version 1.67

@trananhmanh89
Copy link
Contributor Author

Btw, we use sass-embedded wich is dart-sass, version 1.67

I noticed that in the package.json file, but I'm not sure why my compiled CSS is significantly different from Joomla's.

@Fedik
Copy link
Member

Fedik commented Feb 23, 2024

Okay, it clearly sass LightningCSS and browser issue.
Sass (dart-sass) stopped escaping non ASCII symbols, and the Browser may interpret the file with this symbols incorrectly (randomly, due to network or enabled gzip/deflate on server), unlles the file have defined @charset 'utf-8' (which sass also deleting successfully)

Another links:

@trananhmanh89 what version of sass did you use?

@trananhmanh89
Copy link
Contributor Author

@Fedik I'm using Dart Sass 1.71.1 on my windows.

@Fedik
Copy link
Member

Fedik commented Feb 27, 2024

Sorry, it is not Scss (it works fine, and keep the icons escaped) (I have edited my previous comment)
It is LightningCSS which is transforming escaped UTF8 to raw :)

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Mar 2, 2024

Possible fix: #42938

Please test it

@Quy
Copy link
Contributor

Quy commented Apr 3, 2024

I am going to assume this is fixed with #42938. If not, this can be reopened. Thanks for the report.

@Quy Quy closed this as completed Apr 3, 2024
@trananhmanh89
Copy link
Contributor Author

trananhmanh89 commented Apr 3, 2024

I am going to assume this is fixed with #42938. If not, this can be reopened. Thanks for the report.

No, it's not resolved yet. Please do not use raw utf8 for fontawesome. This causes font issue on chrome.

image

@Quy Quy reopened this Apr 3, 2024
@Fedik
Copy link
Member

Fedik commented Apr 3, 2024

No, it's not resolved yet.

@trananhmanh89 how did you tested it? (recent changes)
The fix only will be in upcoming 4.4.4 and 5.1 release.

Also, do not trust what browser dev tool shows you, it is not able to render every simbol in dev console.

@trananhmanh89
Copy link
Contributor Author

trananhmanh89 commented Apr 3, 2024

@trananhmanh89 how did you tested it? (recent changes) The fix only will be in upcoming 4.4.4 and 5.1 release.

Also, do not trust what browser dev tool shows you, it is not able to render every simbol in dev console.

Hi,
This issue happens randomly, and only on chrome. How can I make sure that this won't happend again?

I thought the solution would be using escaped utf8 string instead of raw utf8 to avoid browser issue...

@Fedik
Copy link
Member

Fedik commented Apr 3, 2024

I just wanted to be sure whether you tested on dev branch of 5.1-dev or not.

I thought the solution would be using escaped utf8

It one of possible solutions.
Another one is to prepend encoding to the CSS file, that what was done in #42938

So if you able to test on latest 5.1 RC, that would be nice.
https://github.com/joomla/joomla-cms/releases/tag/5.1.0-rc1

@trananhmanh89
Copy link
Contributor Author

trananhmanh89 commented Apr 3, 2024

Ok, I asume that adding @charset rule could fix the icon error. But why don't I see @charset rule in file fontawesome.css of atum template?

Checked on package Joomla_5.1.0-rc1-Release_Candidate-Full_Package.zip

@dgrammatiko
Copy link
Contributor

dgrammatiko commented Apr 3, 2024

But why don't I see @charset rule in file fontawesome.css of atum template?

Confirmed. Someone needs to check why (caching, something else?) The npm tools code seems to have the required changes...

FWIW J4 is correct:
Screenshot 2024-04-03 at 7 31 19 PM

So maybe the release leader didn't start on a lean branch and didn't run npm install

@bembelimen
Copy link
Contributor

This is an issue of the build script, three persons tested now with a clean and fresh checkout. If we run normal npm install, it's included, if we do a php build/build.php the charset is not included.

So the build script is broken and the mentioned fix did not fix it.

@dgrammatiko
Copy link
Contributor

This can be close since #43207 is merged

@alikon alikon closed this as completed Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests