Bug 115131 - REGRESSION (r146544): Once a custom font is cached to disk, it starts failing to render until the page is refreshed.
Summary: REGRESSION (r146544): Once a custom font is cached to disk, it starts failing...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac Unspecified
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-04-24 15:09 PDT by Brady Eidson
Modified: 2013-04-24 17:12 PDT (History)
5 users (show)

See Also:


Attachments
Patch v1 - Don't replace encoded data for a CachedFont that has ever created a FontCustomPlatformData object (4.32 KB, patch)
2013-04-24 15:15 PDT, Brady Eidson
ap: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brady Eidson 2013-04-24 15:09:56 PDT
REGRESSION (r146544): Once a custom font is cached to disk, it starts failing to render until the page is refreshed.

One example of a WebFont user in the wild is http://www.okemo.com/activities/snowsports/ticketing/deals/onlinedeals.asp

We can't do the CachedResource::tryReplaceEncodedData trick for CachedFonts on CG platforms because the CGFont object is directly reliant on the original encoded data from the original SharedBuffer.

This patch will introduce the concept of a CachedResource saying it doesn't support being swapped out.

In radar as <rdar://problem/13622998>
Comment 1 Brady Eidson 2013-04-24 15:15:31 PDT
Created attachment 199521 [details]
Patch v1 - Don't replace encoded data for a CachedFont that has ever created a FontCustomPlatformData object
Comment 2 Alexey Proskuryakov 2013-04-24 15:25:04 PDT
Comment on attachment 199521 [details]
Patch v1 - Don't replace encoded data for a CachedFont that has ever created a FontCustomPlatformData object

View in context: https://bugs.webkit.org/attachment.cgi?id=199521&action=review

> Source/WebCore/loader/cache/CachedFont.h:67
> +    virtual bool shouldTryReplaceEncodedData() const;

I think that it's a "may", not "should".

> Source/WebCore/loader/cache/CachedResource.h:299
>      virtual PurgePriority purgePriority() const { return PurgeDefault; }
> +    virtual bool shouldTryReplaceEncodedData() const { return true; }

OVERRIDE
Comment 3 Brady Eidson 2013-04-24 15:25:58 PDT
(In reply to comment #2)
> (From update of attachment 199521 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=199521&action=review
> 
> > Source/WebCore/loader/cache/CachedFont.h:67
> > +    virtual bool shouldTryReplaceEncodedData() const;
> 
> I think that it's a "may", not "should".

Fair enough.
> 
> > Source/WebCore/loader/cache/CachedResource.h:299
> >      virtual PurgePriority purgePriority() const { return PurgeDefault; }
> > +    virtual bool shouldTryReplaceEncodedData() const { return true; }
> 
> OVERRIDE

Duh.

Thanks!
Comment 4 Brady Eidson 2013-04-24 15:34:49 PDT
http://trac.webkit.org/changeset/149070
Comment 5 mitz 2013-04-24 15:43:36 PDT
Comment on attachment 199521 [details]
Patch v1 - Don't replace encoded data for a CachedFont that has ever created a FontCustomPlatformData object

View in context: https://bugs.webkit.org/attachment.cgi?id=199521&action=review

>>> Source/WebCore/loader/cache/CachedResource.h:299
>>> +    virtual bool shouldTryReplaceEncodedData() const { return true; }
>> 
>> OVERRIDE
> 
> Duh.
> 
> Thanks!

I’m surprised that the default is true!
Comment 6 Brady Eidson 2013-04-24 16:00:41 PDT
(In reply to comment #5)
> (From update of attachment 199521 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=199521&action=review
> 
> >>> Source/WebCore/loader/cache/CachedResource.h:299
> >>> +    virtual bool shouldTryReplaceEncodedData() const { return true; }
> >> 
> >> OVERRIDE
> > 
> > Duh.
> > 
> > Thanks!
> 
> I’m surprised that the default is true!

Why?  Only certain CachedFonts are known to misbehave with the replacement.  All other CachedResources still get it.
Comment 7 mitz 2013-04-24 16:06:01 PDT
(In reply to comment #6)
> (In reply to comment #5)
> > (From update of attachment 199521 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=199521&action=review
> > 
> > >>> Source/WebCore/loader/cache/CachedResource.h:299
> > >>> +    virtual bool shouldTryReplaceEncodedData() const { return true; }
> > >> 
> > >> OVERRIDE
> > > 
> > > Duh.
> > > 
> > > Thanks!
> > 
> > I’m surprised that the default is true!
> 
> Why?  Only certain CachedFonts are known to misbehave with the replacement.  All other CachedResources still get it.

Because if you’re writing a new CachedResource derived class, you should inherit safe behavior by default, and make a conscious choice to opt into unsafe behavior if you know that you can handle it.
Comment 8 Brady Eidson 2013-04-24 16:08:42 PDT
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > (From update of attachment 199521 [details] [details] [details])
> > > View in context: https://bugs.webkit.org/attachment.cgi?id=199521&action=review
> > > 
> > > >>> Source/WebCore/loader/cache/CachedResource.h:299
> > > >>> +    virtual bool shouldTryReplaceEncodedData() const { return true; }
> > > >> 
> > > 
> > > I’m surprised that the default is true!
> > 
> > Why?  Only certain CachedFonts are known to misbehave with the replacement.  All other CachedResources still get it.
> 
> Because if you’re writing a new CachedResource derived class, you should inherit safe behavior by default, and make a conscious choice to opt into unsafe behavior if you know that you can handle it.

Oh, you and your good points.  :P
Comment 9 Brady Eidson 2013-04-24 16:10:53 PDT
But on that note, I think it should probably be pure virtual so you're forced to consider it.
Comment 10 Alexey Proskuryakov 2013-04-24 16:31:22 PDT
I would note that "safe" behavior is the one that doesn't kill performance. From this point of view, the current default is actually safe.
Comment 11 mitz 2013-04-24 16:56:33 PDT
(In reply to comment #10)
> I would note that "safe" behavior is the one that doesn't kill performance. From this point of view, the current default is actually safe.

When I used the word “safe”, I didn’t mean “doesn’t kill performance”. Maybe there’s another word for “doesn’t kill performance”, or maybe there should be, but the word “safe” already means something different, as in the sentence “when shouldTryReplaceEncodedData() returns false, it is not safe to hang on to the pointer to the encoded data beyond the end of the current iteration of the run loop”.
Comment 12 mitz 2013-04-24 16:58:56 PDT
(In reply to comment #11)
> (In reply to comment #10)
> > I would note that "safe" behavior is the one that doesn't kill performance. From this point of view, the current default is actually safe.
> 
> When I used the word “safe”, I didn’t mean “doesn’t kill performance”. Maybe there’s another word for “doesn’t kill performance”, or maybe there should be, but the word “safe” already means something different, as in the sentence “when shouldTryReplaceEncodedData() returns false, it is not safe to hang on to the pointer to the encoded data beyond the end of the current iteration of the run loop”.

s/false/true/ :-\
Comment 13 Brady Eidson 2013-04-24 17:12:27 PDT
This whole mechanism is a memory optimization for process-per-tab mode.  Not doing it does not "kill performance", and *all* resources will still get the file backed memory on the next load after it was cached.