Bug 185752 - Lazily create WebCore::Timer for WebCore::Image
Summary: Lazily create WebCore::Timer for WebCore::Image
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on:
Blocks: 185330
  Show dependency treegraph
 
Reported: 2018-05-17 15:49 PDT by David Kilzer (:ddkilzer)
Modified: 2018-05-17 20:30 PDT (History)
9 users (show)

See Also:


Attachments
Patch v1 (3.27 KB, patch)
2018-05-17 15:54 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>