Title: [196527] trunk/Source/WebKit/mac
Revision
196527
Author
[email protected]
Date
2016-02-12 16:22:53 -0800 (Fri, 12 Feb 2016)

Log Message

Add thread violation checks to WebView public APIs.
https://bugs.webkit.org/show_bug.cgi?id=154183

Reviewed by Geoffrey Garen.

This will help clients of the API detect the violations sooner rather than
having to debug mysterious crashes / failures later.

To that end, I've added thread violation checks to the following functions
because ...

* WebView/WebView.mm:
(-[WebView setCustomTextEncodingName:]):
- Uses the FrameLoader (which is for the main thread only).

(-[WebView stringByEvaluatingJavaScriptFromString:]):
- Invokes _javascript_ (which is for the main thread only).

(-[WebView windowScriptObject]):
- Invokes ScriptController::windowScriptObject() which requires the JSLock.

(-[WebView setGroupName:]):
- Manipulates the PageGroup and Page (which is for the main thread only).

(-[WebView setMainFrameURL:]):
- Uses the FrameLoader (which is for the main thread only).

(-[WebView mainFrameTitle]):
- Uses the FrameLoader::documentLoader() (via [WebFrame _dataSource]) which
  is RefPtr, and therefore not safe for other threads to access.

(-[WebView mainFrameIcon]):
- Uses the FrameLoader::documentLoader() (via [WebFrame _dataSource]) which
  is RefPtr, and therefore not safe for other threads to access.
- Uses [WebIconDatabase sharedIconDatabase] which does a singleton
  instantiation but is not protected by a lock.

(-[WebView setDrawsBackground:]):
- Potentially manipulates a RenderView (via FrameView::setBaseBackgroundColor,
  via [WebFrame _updateBackgroundAndUpdatesWhileOffscreen]), and RenderView
  is for main thread only use.

(-[WebView setShouldUpdateWhileOffscreen:]):
- Uses [WebFrame _updateBackgroundAndUpdatesWhileOffscreen].  Hence, for the
  main thread only.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (196526 => 196527)


--- trunk/Source/WebKit/mac/ChangeLog	2016-02-13 00:18:40 UTC (rev 196526)
+++ trunk/Source/WebKit/mac/ChangeLog	2016-02-13 00:22:53 UTC (rev 196527)
@@ -1,3 +1,51 @@
+2016-02-12  Mark Lam  <[email protected]>
+
+        Add thread violation checks to WebView public APIs.
+        https://bugs.webkit.org/show_bug.cgi?id=154183
+
+        Reviewed by Geoffrey Garen.
+
+        This will help clients of the API detect the violations sooner rather than
+        having to debug mysterious crashes / failures later.
+
+        To that end, I've added thread violation checks to the following functions
+        because ...
+
+        * WebView/WebView.mm:
+        (-[WebView setCustomTextEncodingName:]):
+        - Uses the FrameLoader (which is for the main thread only).
+
+        (-[WebView stringByEvaluatingJavaScriptFromString:]):
+        - Invokes _javascript_ (which is for the main thread only).
+
+        (-[WebView windowScriptObject]):
+        - Invokes ScriptController::windowScriptObject() which requires the JSLock.
+
+        (-[WebView setGroupName:]):
+        - Manipulates the PageGroup and Page (which is for the main thread only).
+
+        (-[WebView setMainFrameURL:]):
+        - Uses the FrameLoader (which is for the main thread only).
+
+        (-[WebView mainFrameTitle]):
+        - Uses the FrameLoader::documentLoader() (via [WebFrame _dataSource]) which
+          is RefPtr, and therefore not safe for other threads to access.
+
+        (-[WebView mainFrameIcon]):
+        - Uses the FrameLoader::documentLoader() (via [WebFrame _dataSource]) which
+          is RefPtr, and therefore not safe for other threads to access.
+        - Uses [WebIconDatabase sharedIconDatabase] which does a singleton
+          instantiation but is not protected by a lock.
+
+        (-[WebView setDrawsBackground:]):
+        - Potentially manipulates a RenderView (via FrameView::setBaseBackgroundColor,
+          via [WebFrame _updateBackgroundAndUpdatesWhileOffscreen]), and RenderView
+          is for main thread only use.
+
+        (-[WebView setShouldUpdateWhileOffscreen:]):
+        - Uses [WebFrame _updateBackgroundAndUpdatesWhileOffscreen].  Hence, for the
+          main thread only.
+
 2016-02-12  Sukolsak Sakshuwong  <[email protected]>
 
         Update ICU header files to version 52

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (196526 => 196527)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2016-02-13 00:18:40 UTC (rev 196526)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2016-02-13 00:22:53 UTC (rev 196527)
@@ -5843,6 +5843,8 @@
 
 - (void)setCustomTextEncodingName:(NSString *)encoding
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     NSString *oldEncoding = [self customTextEncodingName];
     if (encoding == oldEncoding || [encoding isEqualToString:oldEncoding])
         return;
@@ -5867,6 +5869,8 @@
 
 - (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
 #if !PLATFORM(IOS)
     // Return statements are only valid in a function but some applications pass in scripts
     // prefixed with return (<rdar://problems/5103720&4616860>) since older WebKit versions
@@ -5889,6 +5893,8 @@
 
 - (WebScriptObject *)windowScriptObject
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     Frame* coreFrame = [self _mainCoreFrame];
     if (!coreFrame)
         return nil;
@@ -6154,6 +6160,8 @@
 
 - (void)setGroupName:(NSString *)groupName
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     if (_private->group)
         _private->group->removeWebView(self);
 
@@ -6244,6 +6252,8 @@
 
 - (void)setMainFrameURL:(NSString *)URLString
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     NSURL *url;
     if ([URLString hasPrefix:@"/"])
         url = "" fileURLWithPath:URLString];
@@ -6270,6 +6280,8 @@
 
 - (NSString *)mainFrameTitle
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     NSString *mainFrameTitle = [[[self mainFrame] _dataSource] pageTitle];
     return (mainFrameTitle != nil) ? mainFrameTitle : (NSString *)@"";
 }
@@ -6277,6 +6289,8 @@
 #if !PLATFORM(IOS)
 - (NSImage *)mainFrameIcon
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     return [[WebIconDatabase sharedIconDatabase] iconForURL:[[[[self mainFrame] _dataSource] _URL] _web_originalDataAsString] withSize:WebIconSmallSize];
 }
 #else
@@ -6303,6 +6317,8 @@
 
 - (void)setDrawsBackground:(BOOL)drawsBackground
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     if (_private->drawsBackground == drawsBackground)
         return;
     _private->drawsBackground = drawsBackground;
@@ -6318,6 +6334,8 @@
 
 - (void)setShouldUpdateWhileOffscreen:(BOOL)updateWhileOffscreen
 {
+    WebCoreThreadViolationCheckRoundTwo();
+
     if (_private->shouldUpdateWhileOffscreen == updateWhileOffscreen)
         return;
     _private->shouldUpdateWhileOffscreen = updateWhileOffscreen;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to