summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2022-06-04 17:13:45 -0500
committerBrian Smith <brian@dbsoft.org>2022-06-04 17:13:45 -0500
commite65f15fb4c7dc697063fb031184b71cb8cd97173 (patch)
tree62849b31d96c613d36c0b7ae6b9c392f29fd28b6
parent9c395967cc6726158cf34c977f6c4da4cce742d1 (diff)
downloaduxp-e65f15fb4c7dc697063fb031184b71cb8cd97173.tar.gz
Issue #1905 - Part 2c - Fix OpenGL crash caused by calling [NSOpenGLContext setView:] on the Compositor thread.
Starting with SDK 10.14 I believe, many functions have main thread checks, including setView: and update. So we now move the code in the updateGLContext method into doDrawRect which runs on the main thread.
-rw-r--r--widget/cocoa/nsChildView.h1
-rw-r--r--widget/cocoa/nsChildView.mm20
2 files changed, 8 insertions, 13 deletions
diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h
index 2817c8d415..7b998a6c5c 100644
--- a/widget/cocoa/nsChildView.h
+++ b/widget/cocoa/nsChildView.h
@@ -224,7 +224,6 @@ class WidgetRenderingContext;
enter:(BOOL)aEnter
exitFrom:(mozilla::WidgetMouseEvent::ExitFrom)aExitFrom;
-- (void)updateGLContext;
- (void)_surfaceNeedsUpdate:(NSNotification*)notification;
- (bool)preRender:(NSOpenGLContext *)aGLContext;
diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm
index e2aa6729e9..a3a3bacbf9 100644
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3309,16 +3309,11 @@ NSEvent* gLastDragMouseDownEvent = nil;
if (!mGLContext) {
mGLContext = aGLContext;
[mGLContext retain];
- mNeedsGLUpdate = true;
+ mNeedsGLUpdate = YES;
}
CGLLockContext((CGLContextObj)[aGLContext CGLContextObj]);
- if (mNeedsGLUpdate) {
- [self updateGLContext];
- mNeedsGLUpdate = NO;
- }
-
return true;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
@@ -3472,12 +3467,6 @@ NSEvent* gLastDragMouseDownEvent = nil;
return YES;
}
--(void)updateGLContext
-{
- [mGLContext setView:mPixelHostingView];
- [mGLContext update];
-}
-
- (void)_surfaceNeedsUpdate:(NSNotification*)notification
{
if (mGLContext) {
@@ -3592,6 +3581,13 @@ NSEvent* gLastDragMouseDownEvent = nil;
LayoutDeviceIntRegion region(geckoBounds);
mGeckoChild->PaintWindow(region);
+
+ if (mNeedsGLUpdate) {
+ [mGLContext setView:mPixelHostingView];
+ [mGLContext update];
+ mNeedsGLUpdate = NO;
+ }
+
return;
}