Open Bug 1247669 Opened 8 years ago Updated 2 years ago

"remote" fonts reload and flash when adding new CSSStyleRule and Cache is disabled

Categories

(Core :: Layout: Text and Fonts, defect)

43 Branch
defect

Tracking

()

UNCONFIRMED

People

(Reporter: tobias.boehmer, Unassigned)

References

Details

User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0
Build ID: 20160210004006

Steps to reproduce:

1.) have a page with an included webfont, such as Roboto, that is NOT installed on your system, so it has to be loaded from the server
2.) have text on the page that uses this font
3.) disable caching (DevTools > DevTools-Settings > check "Disable cache (when toolbox is open)")
4a.) have a style element (CSSStyleSheet) on the page, empty or with rules (doesn't matter) and add a CSSStyleRule to it
4b.) insert a CSSStyleRule to an existing CSSStyleSheet
[comment:] it has to be either 4a or 4b
[comment:] it has to be a valid syntax for the style rule


Actual results:

The text on the page "flashes". This means it completely disappears for some frames, but still occupies its space, and than re-appears.
In the Network tab in DevTools you can see that the font is reloaded from the server on every "insertRule" applied.
Sometimes it does not flash, but in the Network tab you can see the font download, what should not happen more than once.

I made a jsfiddle to demonstrate this behavior. Just follow step 3 from my reproduction description, click the button and you can see it.
https://jsfiddle.net/e2c43hjd/2/

Some tickets I found during my research that may be related to this issue:
https://bugzilla.mozilla.org/show_bug.cgi?id=850662
https://bugzilla.mozilla.org/show_bug.cgi?id=1021750
https://bugzilla.mozilla.org/show_bug.cgi?id=1239197


Expected results:

nothing (visible)
Keywords: css3, fonts
Product: Firefox → Core
It's a side-effect of bug 1027579:
https://hg.mozilla.org/integration/mozilla-inbound/pushloghtml?fromchange=d60f93efd7afdcc6bf085dfd4d290e460102f578&tochange=13046b64bc825bd87963c5c69dd60550622e26f8

Dragana, your opinion?
Blocks: 1027579
Component: Untriaged → Networking: Cache
Flags: needinfo?(dd.mozilla)
Keywords: css3, fonts
OS: Unspecified → All
Hardware: Unspecified → All
(In reply to Loic from comment #1)
> It's a side-effect of bug 1027579:
> https://hg.mozilla.org/integration/mozilla-inbound/
> pushloghtml?fromchange=d60f93efd7afdcc6bf085dfd4d290e460102f578&tochange=1304
> 6b64bc825bd87963c5c69dd60550622e26f8
> 
> Dragana, your opinion?

This was way to make disable cache in dev-tools work properly. There are other issues in user-fonts that should be fix there (https://bugzilla.mozilla.org/show_bug.cgi?id=1027579#c40).

I will needinfo :jfkthame, he can give better info about use-font.
Flags: needinfo?(dd.mozilla) → needinfo?(jfkthame)
Component: Networking: Cache → Layout: Text
It's not clear to me what should be different here... if the cache is disabled, then we have to re-fetch and re-load the font, and so some flashing is expected when style rules are added (meaning we need to re-flow the content).

Having said that, I don't actually see any flashing with the jsfiddle example in my nightly....
Flags: needinfo?(jfkthame)
(In reply to Jonathan Kew (:jfkthame) from comment #3)
> Having said that, I don't actually see any flashing with the jsfiddle
> example in my nightly....
As I said, the flashing text does not show every time, but you can see the multiple font loading on the network tab in DevTools.

And my question is: why is it reloading the fonts when there should just happen a style recalculation and whatever happens after that? I don't see any reason to reload the fonts. and at least Google Chrome does not do it. Chrome just does the recalculations, as I expected.
CC'ing jtd to know if it's current behavior in the latest nightly is expected now.
Flags: needinfo?(jd.bugzilla)
(In reply to Loic from comment #4)
> Yes, it's "fixed" by bug 1188802.
> https://hg.mozilla.org/mozilla-central/
> pushloghtml?fromchange=a0d0344ed47a65f5c36802b61b25c0520cec421f&tochange=ac33
> 8559876df7b2e81388f2aac28d2e95ceb5ff

Right, I think the repeated loading of webfonts should be fixed by bug 1188802. But the specifics of this bug seem a bit unusual so could someone try to reproduce this again with latest nightly? Use userfont logging (NSPR_LOG_MODULES set to 'userfonts:5'). This will log repeated attempts to reload already loaded fonts and also indicate when reloads are pulled out of the font cache. For normal pages we shouldn't see multiple loads of the same font resources. However, if @font-face rules are restructured programatically, all bets are off.
Flags: needinfo?(jd.bugzilla)
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.