Diff
Modified: trunk/LayoutTests/ChangeLog (290815 => 290816)
--- trunk/LayoutTests/ChangeLog 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/LayoutTests/ChangeLog 2022-03-04 06:02:52 UTC (rev 290816)
@@ -1,3 +1,12 @@
+2022-03-03 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ WebGL context count is not limited for GPU process
+ https://bugs.webkit.org/show_bug.cgi?id=222411
+
+ Reviewed by Kenneth Russell.
+
+ * platform/ios-wk2/TestExpectations:
+
2022-03-03 Ben Nham <n...@apple.com>
Enforce silent push quota
Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (290815 => 290816)
--- trunk/LayoutTests/platform/ios-wk2/TestExpectations 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations 2022-03-04 06:02:52 UTC (rev 290816)
@@ -2228,13 +2228,7 @@
# Test failures from turning GPU Process on by default
webkit.org/b/234536 webgl/2.0.0/conformance/reading/read-pixels-test.html
-webkit.org/b/234536 webgl/many-contexts-access-after-loss.html
-webkit.org/b/234536 webgl/many-contexts.html
-webkit.org/b/234536 webgl/max-active-contexts-console-warning.html
-webkit.org/b/234536 webgl/max-active-contexts-gc.html
-webkit.org/b/234536 webgl/max-active-contexts-oldest-context-lost.html
webkit.org/b/234536 webxr/high-performance.html
-webkit.org/b/234536 webgl/max-active-contexts-webglcontextlost-prevent-default.html [ Timeout ]
webkit.org/b/234536 webgl/1.0.3/conformance/state/gl-object-get-calls.html [ Timeout ]
# webkit.org/b/237346 REGRESSION(r290539): [ iOS ] 2X http/wpt/webauthn/public-key-credential-create-failure-local (layout-tests) are constant text failures
Modified: trunk/Source/WebCore/ChangeLog (290815 => 290816)
--- trunk/Source/WebCore/ChangeLog 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/ChangeLog 2022-03-04 06:02:52 UTC (rev 290816)
@@ -1,3 +1,60 @@
+2022-03-03 Kimmo Kinnunen <kkinnu...@apple.com>
+
+ WebGL context count is not limited for GPU process
+ https://bugs.webkit.org/show_bug.cgi?id=222411
+
+ Reviewed by Kenneth Russell.
+
+ Move the context limit from the GraphicsContextGL implementation
+ level to WebGLRenderingContext level. This way the limit
+ is applied to the GPUP implementation too.
+
+ Recycle the context with the earliest activity (draw, readpixels)
+ instead of the creation order.
+
+ Stores the WebGL contexts to per-thread set and limits the size of the set.
+ The set is per-thread to support WebGL contexts in DOM as well as
+ offscreen canvas use-cases. Offscreen canvas is not implemented for Cocoa
+ but other ports may enable it.
+
+ Tested by:
+ LayoutTests/webgl/lose-context-after-context-lost.html
+ LayoutTests/webgl/many-contexts-access-after-loss.html
+ LayoutTests/webgl/many-contexts.html
+ LayoutTests/webgl/max-active-contexts-console-warning.html
+ LayoutTests/webgl/max-active-contexts-gc.html
+ LayoutTests/webgl/max-active-contexts-oldest-context-lost.html
+ LayoutTests/webgl/max-active-contexts-webglcontextlost-prevent-default.html
+
+ * Headers.cmake:
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/canvas/WebGLRenderingContextBase.cpp:
+ (WebCore::activeContexts):
+ (WebCore::addActiveContext):
+ (WebCore::removeActiveContext):
+ (WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase):
+ (WebCore::WebGLRenderingContextBase::setGraphicsContextGL):
+ (WebCore::WebGLRenderingContextBase::destroyGraphicsContextGL):
+ (WebCore::WebGLRenderingContextBase::clearIfComposited):
+ (WebCore::WebGLRenderingContextBase::maybeRestoreContext):
+ (WebCore::WebGLRenderingContextBase::updateActiveOrdinal):
+ * html/canvas/WebGLRenderingContextBase.h:
+ (WebCore::WebGLRenderingContextBase::activeOrdinal const):
+ * platform/graphics/angle/GraphicsContextGLANGLE.cpp:
+ * platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
+ (WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
+ * platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm:
+ (WebCore::createWebProcessGraphicsContextGL):
+ * platform/graphics/opengl/GraphicsContextGLOpenGL.cpp:
+ (WebCore::GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL):
+ * platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp: Removed.
+ * platform/graphics/opengl/GraphicsContextGLOpenGLManager.h: Removed.
+ * platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp:
+ (WebCore::createWebProcessGraphicsContextGL):
+ * platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp:
+ (WebCore::GraphicsContextGLANGLE::~GraphicsContextGLANGLE):
+
2022-03-03 Ben Nham <n...@apple.com>
Enforce silent push quota
Modified: trunk/Source/WebCore/Headers.cmake (290815 => 290816)
--- trunk/Source/WebCore/Headers.cmake 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/Headers.cmake 2022-03-04 06:02:52 UTC (rev 290816)
@@ -1660,7 +1660,6 @@
platform/graphics/opengl/ExtensionsGLOpenGLCommon.h
platform/graphics/opengl/ExtensionsGLOpenGLES.h
platform/graphics/opengl/GraphicsContextGLOpenGL.h
- platform/graphics/opengl/GraphicsContextGLOpenGLManager.h
platform/graphics/opengl/TemporaryOpenGLSetting.h
platform/graphics/opentype/OpenTypeMathData.h
Modified: trunk/Source/WebCore/Sources.txt (290815 => 290816)
--- trunk/Source/WebCore/Sources.txt 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/Sources.txt 2022-03-04 06:02:52 UTC (rev 290816)
@@ -2161,7 +2161,6 @@
platform/graphics/iso/ISOSchemeTypeBox.cpp
platform/graphics/iso/ISOTrackEncryptionBox.cpp
platform/graphics/iso/ISOVTTCue.cpp
-platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp
platform/graphics/opentype/OpenTypeMathData.cpp
platform/graphics/transforms/AffineTransform.cpp
platform/graphics/transforms/Matrix3DTransformOperation.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (290815 => 290816)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-03-04 06:02:52 UTC (rev 290816)
@@ -977,7 +977,6 @@
318EAD4D1FA91380008CEF86 /* ImageBitmapRenderingContextSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 318EAD4A1FA91157008CEF86 /* ImageBitmapRenderingContextSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
319848011A1D817B00A13318 /* AnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 319847FF1A1D816700A13318 /* AnimationEvent.h */; };
3198480C1A1E6CE800A13318 /* JSAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 319848041A1E6B5D00A13318 /* JSAnimationEvent.h */; };
- 319A728823C267FE0085353C /* GraphicsContextGLOpenGLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 319A728723C267E70085353C /* GraphicsContextGLOpenGLManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
319AE064142D6B24006563A1 /* StyleFilterData.h in Headers */ = {isa = PBXBuildFile; fileRef = 319AE062142D6B24006563A1 /* StyleFilterData.h */; settings = {ATTRIBUTES = (Private, ); }; };
319FBD5F15D2F464009640A6 /* CachedImageClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 319FBD5D15D2F444009640A6 /* CachedImageClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
31A089561E738D59003B6609 /* JSWebGPUBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 31A0891D1E738D59003B6609 /* JSWebGPUBuffer.h */; };
@@ -8383,7 +8382,6 @@
319848001A1D816700A13318 /* AnimationEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AnimationEvent.idl; sourceTree = "<group>"; };
319848031A1E6B5D00A13318 /* JSAnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAnimationEvent.cpp; sourceTree = "<group>"; };
319848041A1E6B5D00A13318 /* JSAnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAnimationEvent.h; sourceTree = "<group>"; };
- 319A728723C267E70085353C /* GraphicsContextGLOpenGLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContextGLOpenGLManager.h; sourceTree = "<group>"; };
319AE061142D6B24006563A1 /* StyleFilterData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleFilterData.cpp; sourceTree = "<group>"; };
319AE062142D6B24006563A1 /* StyleFilterData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleFilterData.h; sourceTree = "<group>"; };
319BDE4F1E7A858A00BA296C /* JSRTCIceTransport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCIceTransport.cpp; sourceTree = "<group>"; };
@@ -16502,7 +16500,6 @@
D06C0D8E0CFD11460065F43F /* RemoveFormatCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoveFormatCommand.cpp; sourceTree = "<group>"; };
D07DEAB70A36554A00CA30F8 /* InsertListCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = InsertListCommand.cpp; sourceTree = "<group>"; };
D07DEAB80A36554A00CA30F8 /* InsertListCommand.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = InsertListCommand.h; sourceTree = "<group>"; };
- D0843A4C20FEC16500FE860E /* GraphicsContextGLOpenGLManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsContextGLOpenGLManager.cpp; sourceTree = "<group>"; };
D086FE9609D53AAB005BC74D /* UnlinkCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkCommand.h; sourceTree = "<group>"; };
D086FE9709D53AAB005BC74D /* UnlinkCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkCommand.cpp; sourceTree = "<group>"; };
D0A20D542092A0A600E0C259 /* WebGLCompressedTextureASTC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLCompressedTextureASTC.h; sourceTree = "<group>"; };
@@ -32938,8 +32935,6 @@
children = (
6E21C6BF1126338500A7BE02 /* GraphicsContextGLOpenGL.cpp */,
49C7B9FB1042D3650009D447 /* GraphicsContextGLOpenGL.h */,
- D0843A4C20FEC16500FE860E /* GraphicsContextGLOpenGLManager.cpp */,
- 319A728723C267E70085353C /* GraphicsContextGLOpenGLManager.h */,
);
path = opengl;
sourceTree = "<group>";
@@ -34796,7 +34791,6 @@
7BB34A48253776CA00029D08 /* GraphicsContextGLImageExtractor.h in Headers */,
7B6DC81925712E9200380C70 /* GraphicsContextGLIOSurfaceSwapChain.h in Headers */,
49C7B9FC1042D3650009D447 /* GraphicsContextGLOpenGL.h in Headers */,
- 319A728823C267FE0085353C /* GraphicsContextGLOpenGLManager.h in Headers */,
7B95CFEB2754FF6E000060CE /* GraphicsContextGLState.h in Headers */,
A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */,
0F580B0D0F12A2690051D689 /* GraphicsLayer.h in Headers */,
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (290815 => 290816)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp 2022-03-04 06:02:52 UTC (rev 290816)
@@ -124,8 +124,11 @@
#include <wtf/IsoMallocInlines.h>
#include <wtf/Lock.h>
#include <wtf/Locker.h>
+#include <wtf/MainThread.h>
+#include <wtf/NeverDestroyed.h>
#include <wtf/Scope.h>
#include <wtf/StdLibExtras.h>
+#include <wtf/ThreadSpecific.h>
#include <wtf/UniqueArray.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringBuilder.h>
@@ -151,9 +154,11 @@
WTF_MAKE_ISO_ALLOCATED_IMPL(WebGLRenderingContextBase);
-static const Seconds secondsBetweenRestoreAttempts { 1_s };
-const int maxGLErrorsAllowedToConsole = 256;
-static const Seconds checkContextLossHandlingDelay { 3_s };
+static constexpr Seconds secondsBetweenRestoreAttempts { 1_s };
+static constexpr int maxGLErrorsAllowedToConsole = 256;
+static constexpr Seconds checkContextLossHandlingDelay { 3_s };
+static constexpr size_t maxActiveContexts = 16;
+static constexpr size_t maxActiveWorkerContexts = 4;
namespace {
@@ -784,6 +789,46 @@
return context->contextAttributes().powerPreference == WebGLPowerPreference::HighPerformance;
}
+// Counter for determining which context has the earliest active ordinal number.
+static std::atomic<uint64_t> s_lastActiveOrdinal;
+
+using WebGLRenderingContextBaseSet = HashSet<WebGLRenderingContextBase*>;
+
+static WebGLRenderingContextBaseSet& activeContexts()
+{
+ static LazyNeverDestroyed<ThreadSpecific<WebGLRenderingContextBaseSet>> s_activeContexts;
+ static std::once_flag s_onceFlag;
+ std::call_once(s_onceFlag, [] {
+ s_activeContexts.construct();
+ });
+ return *s_activeContexts.get();
+}
+
+static void addActiveContext(WebGLRenderingContextBase& newContext)
+{
+ auto& contexts = activeContexts();
+ auto maxContextsSize = isMainThread() ? maxActiveContexts : maxActiveWorkerContexts;
+ if (contexts.size() >= maxContextsSize) {
+ auto it = contexts.begin();
+ auto* earliest = *it;
+ for (++it; it != contexts.end(); ++it) {
+ if (earliest->activeOrdinal() > (*it)->activeOrdinal())
+ earliest = *it;
+ }
+ earliest->recycleContext();
+ ASSERT(earliest != &newContext); // This assert is here so we can assert isNewEntry below instead of top-level `!contexts.contains(newContext);`.
+ ASSERT(contexts.size() < maxContextsSize);
+ }
+ auto result = contexts.add(&newContext);
+ ASSERT_UNUSED(result, result.isNewEntry);
+}
+
+static void removeActiveContext(WebGLRenderingContextBase& context)
+{
+ bool didContain = activeContexts().remove(&context);
+ ASSERT_UNUSED(didContain, didContain);
+}
+
std::unique_ptr<WebGLRenderingContextBase> WebGLRenderingContextBase::create(CanvasBase& canvas, WebGLContextAttributes& attributes, WebGLVersion type)
{
auto scriptExecutionContext = canvas.scriptExecutionContext();
@@ -915,7 +960,6 @@
WebGLRenderingContextBase::WebGLRenderingContextBase(CanvasBase& canvas, Ref<GraphicsContextGL>&& context, WebGLContextAttributes attributes)
: GPUBasedCanvasRenderingContext(canvas)
- , m_context(WTFMove(context))
, m_restoreTimer(canvas.scriptExecutionContext(), *this, &WebGLRenderingContextBase::maybeRestoreContext)
, m_generatedImageCache(4)
, m_attributes(attributes)
@@ -925,6 +969,8 @@
, m_isXRCompatible(attributes.xrCompatible)
#endif
{
+ setGraphicsContextGL(WTFMove(context));
+
m_restoreTimer.suspendIfNeeded();
m_contextGroup = WebGLContextGroup::create();
@@ -1202,6 +1248,15 @@
}
}
+void WebGLRenderingContextBase::setGraphicsContextGL(Ref<GraphicsContextGL>&& context)
+{
+ bool wasActive = m_context;
+ m_context = WTFMove(context);
+ updateActiveOrdinal();
+ if (!wasActive)
+ addActiveContext(*this);
+}
+
void WebGLRenderingContextBase::destroyGraphicsContextGL()
{
if (m_isPendingPolicyResolution)
@@ -1212,6 +1267,7 @@
if (m_context) {
m_context->removeClient(*this);
m_context = nullptr;
+ removeActiveContext(*this);
}
}
@@ -1263,6 +1319,9 @@
if (isContextLostOrPending())
return false;
+ // `clearIfComposited()` is a function that prepares for updates. Mark the context as active.
+ updateActiveOrdinal();
+
if (!m_context->layerComposited() || m_layerCleared || m_preventBufferClearForInspector)
return false;
@@ -7762,7 +7821,7 @@
return;
}
- m_context = context;
+ setGraphicsContextGL(context.releaseNonNull());
addActivityStateChangeObserverIfNecessary();
m_contextLost = false;
setupFlags();
@@ -8183,6 +8242,11 @@
m_context->prepareForDisplay();
}
+void WebGLRenderingContextBase::updateActiveOrdinal()
+{
+ m_activeOrdinal = s_lastActiveOrdinal++;
+}
+
} // namespace WebCore
#endif // ENABLE(WEBGL)
Modified: trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h (290815 => 290816)
--- trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h 2022-03-04 06:02:52 UTC (rev 290816)
@@ -432,6 +432,8 @@
// prohibitively expensive.
Lock& objectGraphLock() WTF_RETURNS_LOCK(m_objectGraphLock);
+ // Returns the ordinal number of when the context was last active (drew, read pixels).
+ uint64_t activeOrdinal() const { return m_activeOrdinal; }
protected:
WebGLRenderingContextBase(CanvasBase&, WebGLContextAttributes);
WebGLRenderingContextBase(CanvasBase&, Ref<GraphicsContextGL>&&, WebGLContextAttributes);
@@ -473,6 +475,7 @@
void addContextObject(WebGLContextObject&);
void detachAndRemoveAllObjects();
+ void setGraphicsContextGL(Ref<GraphicsContextGL>&&);
void destroyGraphicsContextGL();
void markContextChanged();
void markContextChangedAndNotifyCanvasObserver();
@@ -542,6 +545,7 @@
bool compositingResultsNeedUpdating() const final { return m_compositingResultsNeedUpdating; }
bool needsPreparationForDisplay() const final { return true; }
void prepareForDisplay() final;
+ void updateActiveOrdinal();
RefPtr<GraphicsContextGL> m_context;
RefPtr<WebGLContextGroup> m_contextGroup;
@@ -1142,6 +1146,8 @@
#if ENABLE(WEBXR)
bool m_isXRCompatible { false };
#endif
+ // The ordinal number of when the context was last active (drew, read pixels).
+ uint64_t m_activeOrdinal { 0 };
};
template <typename T>
Modified: trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp 2022-03-04 06:02:52 UTC (rev 290816)
@@ -31,7 +31,6 @@
#include "ANGLEHeaders.h"
#include "ANGLEUtilities.h"
-#include "GraphicsContextGLOpenGLManager.h"
#include "ImageBuffer.h"
#include "IntRect.h"
#include "IntSize.h"
Modified: trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm 2022-03-04 06:02:52 UTC (rev 290816)
@@ -33,7 +33,6 @@
#import "ANGLEUtilitiesCocoa.h"
#import "CVUtilities.h"
#import "GraphicsContextGLIOSurfaceSwapChain.h"
-#import "GraphicsContextGLOpenGLManager.h"
#import "Logging.h"
#import "PixelBuffer.h"
#import "ProcessIdentity.h"
@@ -428,7 +427,6 @@
GraphicsContextGLANGLE::~GraphicsContextGLANGLE()
{
- GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
if (makeContextCurrent()) {
if (m_texture)
GL_DeleteTextures(1, &m_texture);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/cocoa/WebProcessGraphicsContextGLCocoa.mm 2022-03-04 06:02:52 UTC (rev 290816)
@@ -28,7 +28,6 @@
#if ENABLE(WEBGL)
#import "GraphicsContextGLCocoa.h" // NOLINT
-#import "GraphicsContextGLOpenGLManager.h"
#import "PlatformCALayer.h"
#import "ProcessIdentity.h"
@@ -146,14 +145,9 @@
RefPtr<GraphicsContextGL> createWebProcessGraphicsContextGL(const GraphicsContextGLAttributes& attributes)
{
- // Make space for the incoming context if we're full.
- GraphicsContextGLOpenGLManager::sharedManager().recycleContextIfNecessary();
- if (GraphicsContextGLOpenGLManager::sharedManager().hasTooManyContexts())
- return nullptr;
auto context = adoptRef(new WebProcessGraphicsContextGLCocoa(GraphicsContextGLAttributes { attributes }));
if (!context->initialize())
return nullptr;
- GraphicsContextGLOpenGLManager::sharedManager().addContext(context.get());
return context;
}
Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.cpp 2022-03-04 06:02:52 UTC (rev 290816)
@@ -34,7 +34,6 @@
#include "ANGLEWebKitBridge.h"
#include "GLContext.h"
#include "GraphicsContext.h"
-#include "GraphicsContextGLOpenGLManager.h"
#include "ImageBuffer.h"
#include "IntRect.h"
#include "IntSize.h"
@@ -251,7 +250,6 @@
GraphicsContextGLOpenGL::~GraphicsContextGLOpenGL()
{
- GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
bool success = makeContextCurrent();
ASSERT_UNUSED(success, success);
if (m_texture)
Deleted: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.cpp 2022-03-04 06:02:52 UTC (rev 290816)
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(WEBGL)
-#include "GraphicsContextGLOpenGLManager.h"
-
-#include "Logging.h"
-
-#if USE(ANGLE)
-#include "GraphicsContextGLANGLE.h"
-#else
-#include "GraphicsContextGLOpenGL.h"
-#endif
-namespace WebCore {
-
-GraphicsContextGLOpenGLManager& GraphicsContextGLOpenGLManager::sharedManager()
-{
- static NeverDestroyed<GraphicsContextGLOpenGLManager> s_manager;
- return s_manager;
-}
-
-void GraphicsContextGLOpenGLManager::addContext(GraphicsContextGLType* context)
-{
- ASSERT(context);
- if (!context)
- return;
-
- ASSERT(!m_contexts.contains(context));
- m_contexts.append(context);
-}
-
-void GraphicsContextGLOpenGLManager::removeContext(GraphicsContextGLType* context)
-{
- if (!m_contexts.contains(context))
- return;
- m_contexts.removeFirst(context);
-}
-
-void GraphicsContextGLOpenGLManager::recycleContextIfNecessary()
-{
- if (hasTooManyContexts()) {
- LOG(WebGL, "GraphicsContextGLOpenGLManager recycled context (%p).", m_contexts[0]);
- m_contexts[0]->recycleContext();
- }
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEBGL)
Deleted: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGLManager.h 2022-03-04 06:02:52 UTC (rev 290816)
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <wtf/HashSet.h>
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-const unsigned MaxContexts = 16;
-
-#if USE(ANGLE)
-class GraphicsContextGLANGLE;
-#else
-class GraphicsContextGLOpenGL;
-#endif
-
-class GraphicsContextGLOpenGLManager {
- friend NeverDestroyed<GraphicsContextGLOpenGLManager>;
-public:
-#if USE(ANGLE)
- using GraphicsContextGLType = GraphicsContextGLANGLE;
-#else
- using GraphicsContextGLType = GraphicsContextGLOpenGL;
-#endif
-
- static GraphicsContextGLOpenGLManager& sharedManager();
-
- void addContext(GraphicsContextGLType*);
- void removeContext(GraphicsContextGLType*);
-
- void recycleContextIfNecessary();
- bool hasTooManyContexts() const { return m_contexts.size() >= MaxContexts; }
-
-private:
- GraphicsContextGLOpenGLManager() = default;
-
- Vector<GraphicsContextGLType*> m_contexts;
-};
-
-}
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapper.cpp 2022-03-04 06:02:52 UTC (rev 290816)
@@ -31,7 +31,6 @@
#if ENABLE(WEBGL) && USE(TEXTURE_MAPPER)
-#include "GraphicsContextGLOpenGLManager.h"
#include "PixelBuffer.h"
#include "TextureMapperGCGLPlatformLayer.h"
#include <wtf/Deque.h>
@@ -106,11 +105,6 @@
if (!success)
return nullptr;
- // Make space for the incoming context if we're full.
- GraphicsContextGLOpenGLManager::sharedManager().recycleContextIfNecessary();
- if (GraphicsContextGLOpenGLManager::sharedManager().hasTooManyContexts())
- return nullptr;
-
// Create the GraphicsContextGLOpenGL object first in order to establist a current context on this thread.
auto context = GraphicsContextGLTextureMapper::create(GraphicsContextGLAttributes { attributes });
if (!context)
@@ -120,9 +114,6 @@
if (attributes.webGLVersion == GraphicsContextGLWebGLVersion::WebGL2 && !epoxy_is_desktop_gl() && epoxy_gl_version() < 30)
return nullptr;
#endif
-
- GraphicsContextGLOpenGLManager::sharedManager().addContext(context.get());
-
return context;
}
Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp (290815 => 290816)
--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-03-04 05:28:22 UTC (rev 290815)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsContextGLTextureMapperANGLE.cpp 2022-03-04 06:02:52 UTC (rev 290816)
@@ -31,7 +31,6 @@
#include "ANGLEHeaders.h"
#include "ANGLEUtilities.h"
-#include "GraphicsContextGLOpenGLManager.h"
#include "Logging.h"
#include "PixelBuffer.h"
#include "PlatformLayerDisplayDelegate.h"
@@ -318,7 +317,6 @@
GraphicsContextGLANGLE::~GraphicsContextGLANGLE()
{
- GraphicsContextGLOpenGLManager::sharedManager().removeContext(this);
bool success = makeContextCurrent();
ASSERT_UNUSED(success, success);
if (m_texture)