Bug 153051 - Mixing Content Blocking of fonts and display:none rules causes battery drain
Summary: Mixing Content Blocking of fonts and display:none rules causes battery drain
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-01-12 17:52 PST by Myles C. Maxfield
Modified: 2016-01-15 17:55 PST (History)
7 users (show)

See Also:


Attachments
Patch (24.86 KB, patch)
2016-01-12 18:40 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-yosemite (734.17 KB, application/zip)
2016-01-12 19:28 PST, Build Bot
no flags Details
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (739.25 KB, application/zip)
2016-01-12 19:33 PST, Build Bot
no flags Details
Archive of layout-test-results from ews114 for mac-yosemite (804.48 KB, application/zip)
2016-01-12 19:36 PST, Build Bot
no flags Details
Patch (25.91 KB, patch)
2016-01-12 19:38 PST, Myles C. Maxfield
mmaxfield: review-
Details | Formatted Diff | Diff
Patch (8.82 KB, patch)
2016-01-14 17:18 PST, Myles C. Maxfield
achristensen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2016-01-12 17:52:50 PST
Mixing Content Blocking of fonts and display:none rules causes battery drain
Comment 1 Myles C. Maxfield 2016-01-12 18:40:59 PST
Created attachment 268835 [details]
Patch
Comment 2 Build Bot 2016-01-12 19:28:31 PST
Comment on attachment 268835 [details]
Patch

Attachment 268835 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/684709

New failing tests:
http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher.html
Comment 3 Build Bot 2016-01-12 19:28:34 PST
Created attachment 268843 [details]
Archive of layout-test-results from ews100 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 4 Build Bot 2016-01-12 19:33:05 PST
Comment on attachment 268835 [details]
Patch

Attachment 268835 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/684713

New failing tests:
http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher.html
Comment 5 Build Bot 2016-01-12 19:33:07 PST
Created attachment 268845 [details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 6 Build Bot 2016-01-12 19:36:51 PST
Comment on attachment 268835 [details]
Patch

Attachment 268835 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/684705

New failing tests:
http/tests/security/contentSecurityPolicy/user-style-sheet-font-crasher.html
Comment 7 Build Bot 2016-01-12 19:36:53 PST
Created attachment 268847 [details]
Archive of layout-test-results from ews114 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews114  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 8 Myles C. Maxfield 2016-01-12 19:38:58 PST
Created attachment 268848 [details]
Patch
Comment 9 Myles C. Maxfield 2016-01-12 20:39:39 PST
<rdar://problem/23187709>
Comment 10 Myles C. Maxfield 2016-01-14 12:00:13 PST
Yeah; it's as I suspected; this patch doesn't actually fix the bug. Any time you clear the style resolver, a layout will occur, which means the font will be used again, which means we will go through content blockers, which means we may clear the style resolver again.
Comment 11 Myles C. Maxfield 2016-01-14 12:02:36 PST
(In reply to comment #10)
> Yeah; it's as I suspected; this patch doesn't actually fix the bug. Any time
> you clear the style resolver, a layout will occur, which means the font will
> be used again, which means we will go through content blockers, which means
> we may clear the style resolver again.

It looks like I'll need some bit of state saying "this font was blocked; don't try again." However, this means that I'll need some way of knowing when content blocker rules change (to clear the state).
Comment 12 Myles C. Maxfield 2016-01-14 12:04:40 PST
(In reply to comment #11)
> (In reply to comment #10)
> > Yeah; it's as I suspected; this patch doesn't actually fix the bug. Any time
> > you clear the style resolver, a layout will occur, which means the font will
> > be used again, which means we will go through content blockers, which means
> > we may clear the style resolver again.
> 
> It looks like I'll need some bit of state saying "this font was blocked;
> don't try again." However, this means that I'll need some way of knowing
> when content blocker rules change (to clear the state).

Maybe the key here is that layout triggers the download, rather than setting a src attribute or something like that (for an image).
Comment 13 Myles C. Maxfield 2016-01-14 17:18:00 PST
Created attachment 269021 [details]
Patch
Comment 14 Alex Christensen 2016-01-14 17:48:09 PST
Comment on attachment 269021 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        If we have applied a rule before, don't apply it again (thereby avoiding a relayout).

If we have applied a rule before and we are not applying it again, don't resolve the style again.

The problem wasn't that we were applying it again, the problem was that we were doing another style resolution when we weren't changing anything, which often led to infinite loops.
Comment 15 Myles C. Maxfield 2016-01-14 19:32:10 PST
Committed r195088: <http://trac.webkit.org/changeset/195088>
Comment 16 Myles C. Maxfield 2016-01-14 21:49:32 PST
Follow-up patch at http://trac.webkit.org/changeset/195089
Comment 17 Myles C. Maxfield 2016-01-15 17:55:18 PST
Committed r195161: <http://trac.webkit.org/changeset/195161>