Bug 1394654 - Remove OS X opengl workaround from Mozilla bug 603134. r=mstange
authorJosh Aas <jaas@kflag.net>
Sat, 02 Sep 2017 14:24:00 -0400
changeset 428493 10a488d8110e2c2fd293978e3886ebe793bec1ba
parent 428492 8bc120c1cd3378b76ff3e1978e4e75c5497cd182
child 428494 47b2e91b1060844712405ab8566c1cb359cd5958
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1394654, 603134
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394654 - Remove OS X opengl workaround from Mozilla bug 603134. r=mstange
widget/cocoa/nsChildView.h
widget/cocoa/nsChildView.mm
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -188,17 +188,16 @@ class WidgetRenderingContext;
     eGestureState_None,
     eGestureState_StartGesture,
     eGestureState_MagnifyGesture,
     eGestureState_RotateGesture
   } mGestureState;
   float mCumulativeMagnification;
   float mCumulativeRotation;
 
-  BOOL mDidForceRefreshOpenGL;
   BOOL mWaitingForPaint;
 
 #ifdef __LP64__
   // Support for fluid swipe tracking.
   BOOL* mCancelSwipeAnimation;
 #endif
 
   // Whether this uses off-main-thread compositing.
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -161,17 +161,16 @@ static uint32_t sUniqueKeyEventId = 0;
 
 static NSMutableDictionary* sNativeKeyEventsMap =
   [NSMutableDictionary dictionary];
 
 @interface ChildView(Private)
 
 // sets up our view, attaching it to its owning gecko view
 - (id)initWithFrame:(NSRect)inFrame geckoChild:(nsChildView*)inChild;
-- (void)forceRefreshOpenGL;
 
 // set up a gecko mouse event based on a cocoa mouse event
 - (void) convertCocoaMouseWheelEvent:(NSEvent*)aMouseEvent
                         toGeckoEvent:(WidgetWheelEvent*)outWheelEvent;
 - (void) convertCocoaMouseEvent:(NSEvent*)aMouseEvent
                    toGeckoEvent:(WidgetInputEvent*)outGeckoEvent;
 - (void) convertCocoaTabletPointerEvent:(NSEvent*)aMouseEvent
                            toGeckoEvent:(WidgetMouseEvent*)outGeckoEvent;
@@ -3328,22 +3327,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
     mLastKeyDownEvent = nil;
     mClickThroughMouseDownEvent = nil;
     mDragService = nullptr;
 
     mGestureState = eGestureState_None;
     mCumulativeMagnification = 0.0;
     mCumulativeRotation = 0.0;
 
-    // We can't call forceRefreshOpenGL here because, in order to work around
-    // the bug, it seems we need to have a draw already happening. Therefore,
-    // we call it in drawRect:inContext:, when we know that a draw is in
-    // progress.
-    mDidForceRefreshOpenGL = NO;
-
     mNeedsGLUpdate = NO;
 
     [self setFocusRingType:NSFocusRingTypeNone];
 
 #ifdef __LP64__
     mCancelSwipeAnimation = nil;
 #endif
 
@@ -3415,35 +3408,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
   mTextInputHandler = aHandler;
 }
 
 - (void)uninstallTextInputHandler
 {
   mTextInputHandler = nullptr;
 }
 
-// Work around bug 603134.
-// OS X has a bug that causes new OpenGL windows to only paint once or twice,
-// then stop painting altogether. By clearing the drawable from the GL context,
-// and then resetting the view to ourselves, we convince OS X to start updating
-// again.
-// This can cause a flash in new windows - bug 631339 - but it's very hard to
-// fix that while maintaining this workaround.
-- (void)forceRefreshOpenGL
-{
-  NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
-
-  [mGLContext clearDrawable];
-  CGLLockContext((CGLContextObj)[mGLContext CGLContextObj]);
-  [self updateGLContext];
-  CGLUnlockContext((CGLContextObj)[mGLContext CGLContextObj]);
-
-  NS_OBJC_END_TRY_ABORT_BLOCK;
-}
-
 - (bool)preRender:(NSOpenGLContext *)aGLContext
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   if (![self window] ||
       ([[self window] isKindOfClass:[BaseWindow class]] &&
        ![(BaseWindow*)[self window] isVisibleOrBeingShown])) {
     // Before the window is shown, our GL context's front FBO is not
@@ -3897,23 +3871,16 @@ NSEvent* gLastDragMouseDownEvent = nil;
     return;
 
   mWaitingForPaint = NO;
 
   LayoutDeviceIntRect geckoBounds = mGeckoChild->GetBounds();
   LayoutDeviceIntRegion region(geckoBounds);
 
   mGeckoChild->PaintWindow(region);
-
-  // Force OpenGL to refresh the very first time we draw. This works around a
-  // Mac OS X bug that stops windows updating on OS X when we use OpenGL.
-  if (!mDidForceRefreshOpenGL) {
-    [self performSelector:@selector(forceRefreshOpenGL) withObject:nil afterDelay:0];
-    mDidForceRefreshOpenGL = YES;
-  }
 }
 
 // Called asynchronously after setNeedsDisplay in order to avoid entering the
 // normal drawing machinery.
 - (void)drawUsingOpenGLCallback
 {
   if (mWaitingForPaint) {
     [self drawUsingOpenGL];