Bug 109750

Summary: StartTagScanner should be thread-safe
Product: WebKit Reporter: Adam Barth <abarth>
Component: New BugsAssignee: Adam Barth <abarth>
Status: RESOLVED FIXED    
Severity: Normal CC: eric, ojan.autocc, tonyg, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 106127    
Attachments:
Description Flags
Patch
none
Patch for landing none

Description Adam Barth 2013-02-13 14:34:16 PST
StartTagScanner should be thread-safe
Comment 1 Adam Barth 2013-02-13 14:39:06 PST
Created attachment 188186 [details]
Patch
Comment 2 Eric Seidel (no email) 2013-02-13 15:00:14 PST
Comment on attachment 188186 [details]
Patch

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

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:109
> +        if (m_tagId == UnknownTagId)
>              return;

I think this is very clever.  It's not clear to me that the HTMLTagIdentifier stuff needs to leak out of this class at all.  It could just be private to StartTagScanner?  I assume it's part of a larger plan you have for world domination, hence being separate?

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:112
>              AtomicString attributeName(iter->name);

I believe this will crash on the background thread, no?  It looks like you don't even use it as Atomic, but making it Atomic does prevent a copy in teh common case on the main thread.
Comment 3 Adam Barth 2013-02-13 15:04:02 PST
(In reply to comment #2)
> (From update of attachment 188186 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=188186&action=review
> 
> > Source/WebCore/html/parser/HTMLPreloadScanner.cpp:109
> > +        if (m_tagId == UnknownTagId)
> >              return;
> 
> I think this is very clever.  It's not clear to me that the HTMLTagIdentifier stuff needs to leak out of this class at all.  It could just be private to StartTagScanner?  I assume it's part of a larger plan you have for world domination, hence being separate?

It's going to leak out of the class, but hopefully not out of the file.  For example, I plan to use it in processPossibleStyleTag as well.

> > Source/WebCore/html/parser/HTMLPreloadScanner.cpp:112
> >              AtomicString attributeName(iter->name);
> 
> I believe this will crash on the background thread, no?  It looks like you don't even use it as Atomic, but making it Atomic does prevent a copy in teh common case on the main thread.

Yeah, processAttributes(const HTMLToken::AttributeList& attributes) is going to be main thread only.  I plan to add a processAttributes that takes a CompactHTMLToken::AttributeList or whatever the actual type is called.  I can add an ASSERT(isMainThread()) to this function if that would be helpful.
Comment 4 Adam Barth 2013-02-13 16:09:40 PST
Review ping.  This patch is blocking this stack of patches.  :)
Comment 5 Eric Seidel (no email) 2013-02-13 16:21:12 PST
Comment on attachment 188186 [details]
Patch

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

LGTM.

>>> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:112
>>>              AtomicString attributeName(iter->name);
>> 
>> I believe this will crash on the background thread, no?  It looks like you don't even use it as Atomic, but making it Atomic does prevent a copy in teh common case on the main thread.
> 
> Yeah, processAttributes(const HTMLToken::AttributeList& attributes) is going to be main thread only.  I plan to add a processAttributes that takes a CompactHTMLToken::AttributeList or whatever the actual type is called.  I can add an ASSERT(isMainThread()) to this function if that would be helpful.

I think ASSERTing when we should be on the main thread is helpful, yes.
Comment 6 Adam Barth 2013-02-13 18:02:09 PST
Created attachment 188243 [details]
Patch for landing
Comment 7 Adam Barth 2013-02-13 18:17:53 PST
Comment on attachment 188243 [details]
Patch for landing

Clearing flags on attachment: 188243

Committed r142840: <http://trac.webkit.org/changeset/142840>
Comment 8 Adam Barth 2013-02-13 18:17:55 PST
All reviewed patches have been landed.  Closing bug.