Isolate Font Cache by OriginAttributes
Categories
(Core :: Layout: Text and Fonts, task, P3)
Tracking
()
People
(Reporter: tjr, Unassigned)
References
(Blocks 3 open bugs)
Details
(Whiteboard: [tor])
Attachments
(1 file)
(deleted),
patch
|
Details | Diff | Splinter Review |
There is a pref gfx.downloadable_fonts.disable_cache which disables the font cache. Ideally we would isolate this cache by Origin Attributes.
Currently we isolate it with a hash key here: https://searchfox.org/mozilla-central/rev/c0ca77697c6868482f30af873ec8069f2c080a34/gfx/thebes/gfxUserFontSet.h#398-410
But the principal does not, as far as I can tell, take into account OriginAttributes. Isolating by OriginAttributes would also remove the need for the Private Browsing ID
Reporter | ||
Updated•5 years ago
|
Comment 1•5 years ago
|
||
Comment 2•5 years ago
|
||
Can you provide a testcase for this? (This really isn't an area I know much about.) It looks like we could easily add an OriginAttributes comparison to gfxFontSrcPrincipal::Equals to make them compare as unequal if the attrs differ; would that resolve this issue?
Updated•5 years ago
|
Updated•5 years ago
|
Updated•5 years ago
|
Comment 4•5 years ago
|
||
Actually, gfxFontSrcPrincipal::Equals() already checks OAs. See here, we use BasePrincipal::FastEquals() to check equality and it also checks the originSuffix, which is the OAs. However, the hash doesn't take the OAs into account because this hash is generated by nsIPrincipal::GetHashValue() and it only respects the domain of the principal.
So, I think we also need to change the hash to include the OAs for isolating the font cache.
Comment 5•4 years ago
|
||
(In reply to Jonathan Kew (:jfkthame) from comment #2)
Can you provide a testcase for this? (This really isn't an area I know much about.) It looks like we could easily add an OriginAttributes comparison to gfxFontSrcPrincipal::Equals to make them compare as unequal if the attrs differ; would that resolve this issue?
I have a simple WIP patch of this, but I don't know much about how to test it under gfx's world.
My idea is creating a page http://foo.com/custom_font.html containing a custom font embedded by both http://a.com/test_font_cache.html and http://b.com/test_font_cache.html.
The font should be isolated in different cache.
Jonathan, could you give me some idea how to write a test on fonts' side? Is there any existing test for font cache?
Comment 6•4 years ago
|
||
I don't remember in detail exactly what it's doing, but you might be able to use ideas from layout/style/test/test_redundant_font_download.html, which uses a custom .sjs server to provide a webfont resource and keep track of what requests have been made. That sort of technique should allow you to check whether a resource is being used from cache or requested separately for each origin, I think.
Updated•4 years ago
|
Comment 7•4 years ago
|
||
This is my (WIP) patch of adding origin attributes to the hash for the UserFontCache
, but I don't have a working test. Anyone is welcome to continue the work.
We're going to isolate network cache of font on bug 1647732.
Comment 8•4 years ago
|
||
The patch has landed in bug 1647732.
Reporter | ||
Comment 9•4 years ago
|
||
In bug 1647732, I don't see any reference to first party isolation; nor a test for it. When FPI is enabled, is the Font Cache isolated; or is it only when dFPI is enabled?
Comment 10•4 years ago
|
||
The test was added in here. And it tests originAttributes in general. So, I believe it works for both FPI and dFPI.
Description
•