WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED INVALID
86483
TimingFunction and TransformOperation refcounting is not thread safe
https://bugs.webkit.org/show_bug.cgi?id=86483
Summary
TimingFunction and TransformOperation refcounting is not thread safe
edbaker
Reported
2012-05-15 07:26:26 PDT
Before dereferencing LayerAnimation from the main WebKit thread the compositing thread needs to dereference first. This requires dispatching from the main WebKit thread onto the compositing thread which is an expensive operation. Making LayerAnimation thread safe would make this unnecessary and improve performance.
Attachments
Patch
(9.46 KB, patch)
2012-05-15 09:02 PDT
,
edbaker
no flags
Details
Formatted Diff
Diff
Patch
(9.63 KB, patch)
2012-05-24 07:14 PDT
,
edbaker
no flags
Details
Formatted Diff
Diff
Patch
(2.95 KB, patch)
2012-08-14 01:39 PDT
,
Arvid Nilsson
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
edbaker
Comment 1
2012-05-15 09:02:55 PDT
Created
attachment 141984
[details]
Patch
Antonio Gomes
Comment 2
2012-05-15 09:30:15 PDT
Comment on
attachment 141984
[details]
Patch It looks good to me. Arvid?
Alexey Proskuryakov
Comment 3
2012-05-16 11:13:39 PDT
It is surprising that making refcounting alone thread safe is sufficient to make using the objects from multiple threads safe.
Alexey Proskuryakov
Comment 4
2012-05-16 11:18:47 PDT
Comment on
attachment 141984
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=141984&action=review
> Source/WebCore/platform/graphics/blackberry/LayerAnimation.h:63 > + if (m_name.isEmpty()) > + return String(""); > + return String(m_name);
What's the purpose of this change? All empty strings share the same StringImpl anyway. Constructing a copy of a string doesn't do anything useful for thread safety either. Please use ChangeLog to explain changes for each function.
Arvid Nilsson
Comment 5
2012-05-16 11:28:52 PDT
(In reply to
comment #3
)
> It is surprising that making refcounting alone thread safe is sufficient to make using the objects from multiple threads safe.
Hi Alexey! Thanks for having a look! I knew from the start this was going to be a tough sell because switching to ThreadSafeRefCounted brings a small performance penalty compared to regular old RefCounted, and no other WebKit port uses these classes the way the BlackBerry port does. We're not in this to make the classes thread safe, instead what we do is treat these as immutable as soon as they enter our accelerated compositing backend. No TransformOperation or TimingFunction data is changed after they're handed off to the BlackBerry accelerated animation implementation (which is pretty much a copy/paste job of the WebKit animation implementation, only running on another thread). However, even if we don't touch any data of these objects, the refcount will still be mutated as we pass these objects around and from one thread to the other. We put this patch up so it can be the subject of early discussion, then perhaps we can discuss if other ports are interested in moving in the direction of making the WebKit animation implementation usable from a secondary thread instead of just the WebKit thread. The Chromium CCLayer thread seems to be moving in this direction, but I'm not sure if they're developing an animation framework from scratch instead of reusing the interpolation implementation in WebKit. For Apple's WebKit port, you have Core Animation, so you already have an animation framework and I guess there's no point for you to make the WebKit animation implementation usable from a secondary thread. Instead you copy over all Keyframe and Timing function information to Core Animation data structure, et voilà, no threading problem.
Simon Fraser (smfr)
Comment 6
2012-05-16 12:43:02 PDT
Comment on
attachment 141984
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=141984&action=review
> Source/WebCore/platform/animation/TimingFunction.h:32 > -class TimingFunction : public RefCounted<TimingFunction> { > +class TimingFunction : public ThreadSafeRefCounted<TimingFunction> {
Why force all platforms to take a perf hit when only BlackBerry needs the thread safety?
> Source/WebCore/platform/graphics/transforms/TransformOperation.h:37 > -class TransformOperation : public RefCounted<TransformOperation> { > +class TransformOperation : public ThreadSafeRefCounted<TransformOperation> {
Ditto.
Alexey Proskuryakov
Comment 7
2012-05-16 15:49:10 PDT
> However, even if we don't touch any data of these objects, the refcount will still be mutated as we pass these objects around and from one thread to the other.
I think that you need to generously sprinkle ASSERT(isMainThread()) checks around this code to document and verify this requirement. Not commenting on whether the performance hit of making these classes ThreadSafeRefCounted.
edbaker
Comment 8
2012-05-24 07:14:31 PDT
Created
attachment 143825
[details]
Patch
Arvid Nilsson
Comment 9
2012-08-12 15:35:17 PDT
Ping, for CSS filters we got away with something like this: #include <wtf/RefCounted.h> #include <wtf/text/WTFString.h> +#if PLATFORM(BLACKBERRY) +#include <wtf/ThreadSafeRefCounted.h> +#endif + // Annoyingly, wingdi.h #defines this. #ifdef PASSTHROUGH #undef PASSTHROUGH @@ -44,7 +48,11 @@ namespace WebCore { // CSS Filters +#if PLATFORM(BLACKBERRY) +class FilterOperation : public ThreadSafeRefCounted<FilterOperation> { +#else class FilterOperation : public RefCounted<FilterOperation> { +#endif public: Maybe Ed can do the same in this instance?
https://bugs.webkit.org/show_bug.cgi?id=92685
Arvid Nilsson
Comment 10
2012-08-12 15:36:26 PDT
Move this to BlackBerry component, with the proposed solution it doesn't impact any other port.
Arvid Nilsson
Comment 11
2012-08-12 15:39:45 PDT
PR #153047
Alexey Proskuryakov
Comment 12
2012-08-12 15:44:27 PDT
[] prefixes are not OK on patches that touch cross-platform files. I find it inappropriate for core classes to have different threading characteristics in different ports.
Arvid Nilsson
Comment 13
2012-08-12 15:50:14 PDT
(In reply to
comment #12
)
> [] prefixes are not OK on patches that touch cross-platform files. > > I find it inappropriate for core classes to have different threading characteristics in different ports.
Thanks Alexey, I didn't know that. But I hope the new component is more appropriate. I think we should upstream the non-controversial bits in a separate, [BlackBerry], patch to avoid merge conflicts in our port-specific files.
Arvid Nilsson
Comment 14
2012-08-14 01:32:43 PDT
I'm gonna remove the noise that is the BlackBerry-specific parts of the patch. The reason the BlackBerry port uses TimingFunction and TransformOperation on multiple threads is that these classes (and subclasses) are immutable - once constructed, their data don't change. An immutable class is typically thread safe. The only mutable property of these classes is the refcount, which we wish to change to be thread safe (but only for the BlackBerry port).
Arvid Nilsson
Comment 15
2012-08-14 01:39:43 PDT
Created
attachment 158259
[details]
Patch
Arvid Nilsson
Comment 16
2012-08-14 01:58:47 PDT
Bug #93946
was created for the BlackBerry-specific bits
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug