2011-05-29 Darin Adler <darin@apple.com>
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 May 2011 00:19:45 +0000 (00:19 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 30 May 2011 00:19:45 +0000 (00:19 +0000)
        Reviewed by Dan Bernstein.

        Race condition in full screen controller, which leads to problem when web process crashes
        https://bugs.webkit.org/show_bug.cgi?id=61707

        Second try at this. First try could lead to a WKView leak.

        * UIProcess/mac/WKFullScreenWindowController.h: Added _isExitingAcceleratedCompositingMode.
        Needed to track whether we have retained so we don't leak if the page goes away before
        we get the callback.

        * UIProcess/mac/WKFullScreenWindowController.mm:
        (-[WKFullScreenWindowController exitAcceleratedCompositingMode]): Added code to set
        the new variable to YES.
        (-[WKFullScreenWindowController exitCompositedModeRepaintCompleted]): Added code to
        deal with the new boolean and to release.
        (exitCompositedModeRepaintCompleted): Removed the release that was here.
        (-[WKFullScreenWindowController close]): Added a call to exitCompositedModeRepaintCompleted
        here. We're as complete as we'll ever be when we're closed; we can't get the callback
        after that point.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@87656 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.h
Source/WebKit2/UIProcess/mac/WKFullScreenWindowController.mm

index c9cf7a9..53ce772 100644 (file)
@@ -1,3 +1,26 @@
+2011-05-29  Darin Adler  <darin@apple.com>
+
+        Reviewed by Dan Bernstein.
+
+        Race condition in full screen controller, which leads to problem when web process crashes
+        https://bugs.webkit.org/show_bug.cgi?id=61707
+
+        Second try at this. First try could lead to a WKView leak.
+
+        * UIProcess/mac/WKFullScreenWindowController.h: Added _isExitingAcceleratedCompositingMode.
+        Needed to track whether we have retained so we don't leak if the page goes away before
+        we get the callback.
+
+        * UIProcess/mac/WKFullScreenWindowController.mm:
+        (-[WKFullScreenWindowController exitAcceleratedCompositingMode]): Added code to set
+        the new variable to YES.
+        (-[WKFullScreenWindowController exitCompositedModeRepaintCompleted]): Added code to
+        deal with the new boolean and to release.
+        (exitCompositedModeRepaintCompleted): Removed the release that was here.
+        (-[WKFullScreenWindowController close]): Added a call to exitCompositedModeRepaintCompleted
+        here. We're as complete as we'll ever be when we're closed; we can't get the callback
+        after that point.
+
 2011-05-29  Sam Weinig  <sam@webkit.org>
 
         Reviewed by Anders Carlsson.
index 6ab7219..18cde45 100644 (file)
@@ -51,6 +51,7 @@ class IntRect;
     BOOL _isWindowLoaded;
     BOOL _forceDisableAnimation;
     BOOL _isPlaying;
+    BOOL _isExitingAcceleratedCompositingMode;
     CGRect _initialFrame;    
     uint32_t _idleDisplaySleepAssertion;
     uint32_t _idleSystemSleepAssertion;
index 6d4e376..a53634d 100644 (file)
@@ -394,13 +394,23 @@ static void exitCompositedModeRepaintCompleted(WKErrorRef, void* context);
     if (!_layerHostingView)
         return;
 
-    NSDisableScreenUpdates();
+    ASSERT(!_isExitingAcceleratedCompositingMode);
+    if (_isExitingAcceleratedCompositingMode)
+        return;
+
     [self retain]; // Balanced by release in exitCompositedModeRepaintCompleted below.
+    _isExitingAcceleratedCompositingMode = YES;
+
+    NSDisableScreenUpdates();
     [self _page]->forceRepaint(VoidCallback::create(self, exitCompositedModeRepaintCompleted));
 }
 
 - (void)exitCompositedModeRepaintCompleted
-{    
+{
+    ASSERT(_isExitingAcceleratedCompositingMode);
+    if (!_isExitingAcceleratedCompositingMode)
+        return;
+
     [CATransaction begin];
     [CATransaction setDisableActions:YES];
     [_layerHostingView.get() removeFromSuperview];
@@ -411,13 +421,14 @@ static void exitCompositedModeRepaintCompleted(WKErrorRef, void* context);
     
     _layerHostingView = 0;
     NSEnableScreenUpdates();
+
+    _isExitingAcceleratedCompositingMode = NO;
+    [self release]; // Balanced by retain in exitAcceleratedCompositingMode above.
 }
 
 static void exitCompositedModeRepaintCompleted(WKErrorRef, void* context)
 {
-    WKFullScreenWindowController *controller = static_cast<WKFullScreenWindowController *>(context);
-    [controller exitCompositedModeRepaintCompleted];
-    [controller release]; // Balanced by retain in exitAcceleratedCompositingMode above.
+    [static_cast<WKFullScreenWindowController *>(context) exitCompositedModeRepaintCompleted];
 }
 
 - (WebCore::IntRect)getFullScreenRect
@@ -439,6 +450,9 @@ static void exitCompositedModeRepaintCompleted(WKErrorRef, void* context)
     if (_isExitingFullScreen)
         [self finishedExitFullScreenAnimation:YES];
 
+    if (_isExitingAcceleratedCompositingMode)
+        [self exitCompositedModeRepaintCompleted];
+
     [super close];
 }