Bug 154183

Summary: WebView public APIs should have thread violation checks.
Product: WebKit Reporter: Mark Lam <mark.lam>
Component: WebKit APIAssignee: Mark Lam <mark.lam>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, ggaren, sam, timothy
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 154204    
Bug Blocks:    
Attachments:
Description Flags
proposed patch.
none
proposed patch 2: revised to use WebCoreThreadViolationCheckRoundThree().
timothy: review-
proposed patch 3: address Tim's feedback. none

Description Mark Lam 2016-02-12 12:22:40 PST
This will help clients of the API detect the violations sooner rather than having to debug mysterious crashes / failures later.
Comment 1 Mark Lam 2016-02-12 12:30:10 PST
Created attachment 271202 [details]
proposed patch.
Comment 2 Geoffrey Garen 2016-02-12 15:49:41 PST
Comment on attachment 271202 [details]
proposed patch.

r=me
Comment 3 WebKit Commit Bot 2016-02-12 16:22:55 PST
Comment on attachment 271202 [details]
proposed patch.

Clearing flags on attachment: 271202

Committed r196527: <http://trac.webkit.org/changeset/196527>
Comment 4 WebKit Commit Bot 2016-02-12 16:22:58 PST
All reviewed patches have been landed.  Closing bug.
Comment 5 Timothy Hatcher 2016-02-12 16:26:57 PST
Comment on attachment 271202 [details]
proposed patch.

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

> Source/WebKit/mac/WebView/WebView.mm:5846
> +    WebCoreThreadViolationCheckRoundTwo();

This should have added a WebCoreThreadViolationCheckRoundThree and corresponding ThreadViolationRoundThree along with tagging the WebKit version these were added with a new WebKitLinkedOnOrAfter check in -[WebFrameView initWithFrame:]. Not doing this is a binary compatibility risk, since old app who might be calling these APIs on other threads will start getting exceptions, when they might have worked fine before.
Comment 6 Mark Lam 2016-02-12 16:28:28 PST
(In reply to comment #5)
> Comment on attachment 271202 [details]
> proposed patch.
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=271202&action=review
> 
> > Source/WebKit/mac/WebView/WebView.mm:5846
> > +    WebCoreThreadViolationCheckRoundTwo();
> 
> This should have added a WebCoreThreadViolationCheckRoundThree and
> corresponding ThreadViolationRoundThree along with tagging the WebKit
> version these were added with a new WebKitLinkedOnOrAfter check in
> -[WebFrameView initWithFrame:]. Not doing this is a binary compatibility
> risk, since old app who might be calling these APIs on other threads will
> start getting exceptions, when they might have worked fine before.

I'll roll out and redo as Round 3.
Comment 7 Mark Lam 2016-02-12 16:58:05 PST
Created attachment 271249 [details]
proposed patch 2: revised to use WebCoreThreadViolationCheckRoundThree().
Comment 8 Timothy Hatcher 2016-02-12 17:02:01 PST
Comment on attachment 271249 [details]
proposed patch 2: revised to use WebCoreThreadViolationCheckRoundThree().

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

You are missing a call to setDefaultThreadViolationBehavior in -[WebFrameView initWithFrame:].

> Source/WebCore/platform/mac/ThreadCheck.mm:39
> +static ThreadViolationBehavior threadViolationBehavior[MaximumThreadViolationRound] =
> +    { RaiseExceptionOnThreadViolation, RaiseExceptionOnThreadViolation, RaiseExceptionOnThreadViolation };

I would not have put this on a newline.
Comment 9 Mark Lam 2016-02-12 17:27:52 PST
Created attachment 271253 [details]
proposed patch 3: address Tim's feedback.
Comment 10 WebKit Commit Bot 2016-02-13 09:41:12 PST
Comment on attachment 271253 [details]
proposed patch 3: address Tim's feedback.

Clearing flags on attachment: 271253

Committed r196551: <http://trac.webkit.org/changeset/196551>
Comment 11 WebKit Commit Bot 2016-02-13 09:41:15 PST
All reviewed patches have been landed.  Closing bug.