Bug 185752

Summary: Lazily create WebCore::Timer for WebCore::Image
Product: WebKit Reporter: David Kilzer (:ddkilzer) <ddkilzer>
Component: WebCore Misc.Assignee: David Kilzer (:ddkilzer) <ddkilzer>
Status: RESOLVED FIXED    
Severity: Normal CC: cgarcia, dino, jonlee, koivisto, sabouhallawa, simon.fraser, thorton, webkit-bug-importer, zan
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 185330    
Attachments:
Description Flags
Patch v1 none

Description David Kilzer (:ddkilzer) 2018-05-17 15:49:38 PDT
Not every image is an animated image, so lazily creating m_animationStartTimer saves 56 bytes per instance of WebCore::Image.
Comment 1 David Kilzer (:ddkilzer) 2018-05-17 15:54:03 PDT
Created attachment 340663 [details]
Patch v1
Comment 2 Radar WebKit Bug Importer 2018-05-17 16:02:37 PDT
<rdar://problem/40348570>
Comment 3 David Kilzer (:ddkilzer) 2018-05-17 16:10:30 PDT
This bug improves the safety of using WebCore::Image in the UI Process since current uses do not include animated images.

It also prevents a WebCore::Timer from being allocated for a nullImage.
Comment 4 Simon Fraser (smfr) 2018-05-17 16:20:38 PDT
Comment on attachment 340663 [details]
Patch v1

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

> Source/WebCore/platform/graphics/Image.cpp:351
> +    std::call_once(onceFlag, [this] {

Don't need call_once. Just if (!m_animationStartTimer)

> Source/WebCore/platform/graphics/Image.h:203
> +    std::once_flag onceFlag;

Don't need this here.
Comment 5 David Kilzer (:ddkilzer) 2018-05-17 19:39:28 PDT
Comment on attachment 340663 [details]
Patch v1

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

>> Source/WebCore/platform/graphics/Image.cpp:351
>> +    std::call_once(onceFlag, [this] {
> 
> Don't need call_once. Just if (!m_animationStartTimer)

So we can assume Image::startAnimationAsynchronously() and Image::animationPending() are always called on the main thread?

>> Source/WebCore/platform/graphics/Image.h:203
>> +    std::once_flag onceFlag;
> 
> Don't need this here.

Saves another 8 bytes.  WebCore::Image goes down from 104 bytes to just 40 bytes with this change.
Comment 6 David Kilzer (:ddkilzer) 2018-05-17 20:29:43 PDT
Committed r231940: <https://trac.webkit.org/changeset/231940>