Skip to content

Commit

Permalink
WebGL sends nonstandard webglcontextchanged event
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=260018
rdar://113677584

Reviewed by Dan Glastonbury.

Remove the code to send the webglcontextchanged event.

The event was not in the specification. It was only dispatched for
OpenGL based dual-GPU machines, e.g. on specific machines on Big Sur.

Remove the code to test the delivering webglcontextchanged.

Note: preserve the code for changing WebGL contexts to current GPU.
So for example, if user plugs external monitor to such a computer,
the WebGL contexts will still migrate to dGPU. This is just not
observable through webglcontextchanged. Naturally, the intention is that
this is not observable in any way other than performance difference.

* LayoutTests/fast/canvas/webgl/context-update-on-display-configuration-expected.txt: Removed.
* LayoutTests/fast/canvas/webgl/context-update-on-display-configuration.html: Removed.
* LayoutTests/fast/canvas/webgl/webglcontextchangedevent-expected.txt: Removed.
* LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html: Removed.
* Source/WebCore/dom/EventNames.h:
* Source/WebCore/html/HTMLCanvasElement.cpp:
(WebCore::HTMLCanvasElement::virtualHasPendingActivity const):
(WebCore::HTMLCanvasElement::eventListenersDidChange):
* Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp:
(WebCore::WebGLRenderingContextBase::dispatchContextChangedNotification): Deleted.
* Source/WebCore/html/canvas/WebGLRenderingContextBase.h:
* Source/WebCore/platform/graphics/GraphicsContextGL.cpp:
(WebCore::GraphicsContextGL::dispatchContextChangedNotification): Deleted.
* Source/WebCore/platform/graphics/GraphicsContextGL.h:
* Source/WebCore/platform/graphics/GraphicsContextGLEnums.h:
* Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:
(WebCore::GraphicsContextGLANGLE::simulateEventForTesting):
* Source/WebCore/platform/graphics/cocoa/GraphicsContextGLCocoa.mm:
(WebCore::GraphicsContextGLCocoa::updateContextOnDisplayReconfiguration):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::simulateEventForWebGLContext):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp:
(WebKit::RemoteGraphicsContextGL::simulateEventForTesting):
(WebKit::RemoteGraphicsContextGL::dispatchContextChangedNotification): Deleted.
* Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.h:
* Source/WebKit/Headers.cmake:
* Source/WebKit/Modules/OSX_Private.modulemap:
* Source/WebKit/Modules/iOS_Private.modulemap:
* Source/WebKit/Shared/WebCoreArgumentCoders.h:
* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/API/C/WKMockDisplay.cpp: Removed.
* Source/WebKit/UIProcess/API/C/WKMockDisplay.h: Removed.
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::sendDisplayConfigurationChangedMessageForTesting): Deleted.
* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.cpp:
(WebKit::RemoteGraphicsContextGLProxy::handleMessageToRemovedDestination):
(WebKit::RemoteGraphicsContextGLProxy::wasChanged): Deleted.
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.h:
* Source/WebKit/WebProcess/GPU/graphics/RemoteGraphicsContextGLProxy.messages.in:
* Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestGraphicsContextGLCocoa.mm:
* Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl:
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp:
(WTR::TestRunner::sendDisplayConfigurationChangedMessageForTesting): Deleted.
* Tools/WebKitTestRunner/InjectedBundle/TestRunner.h:
* Tools/WebKitTestRunner/TestController.cpp:
(WTR::TestController::sendDisplayConfigurationChangedMessageForTesting): Deleted.
* Tools/WebKitTestRunner/TestController.h:
* Tools/WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

Canonical link: https://commits.webkit.org/266861@main
  • Loading branch information
kkinnunen-apple committed Aug 14, 2023
1 parent fb99b56 commit 5e5018b
Show file tree
Hide file tree
Showing 42 changed files with 3 additions and 315 deletions.
3 changes: 0 additions & 3 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,6 @@ fast/forms/file/entries-api/pages-jpeg-open-panel.html [ Skip ]
fast/forms/file/entries-api/pdf-jpeg-open-panel.html [ Skip ]
fast/forms/file/entries-api/png-raw-open-panel.html [ Skip ]

# This test is currently only relevant on mac-wk2
fast/canvas/webgl/context-update-on-display-configuration.html [ Skip ]

fast/misc/valid-primary-screen-displayID.html [ Skip ]

fast/events/detect-caps-lock.html [ Skip ]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

57 changes: 0 additions & 57 deletions LayoutTests/fast/canvas/webgl/webglcontextchangedevent.html

This file was deleted.

1 change: 0 additions & 1 deletion LayoutTests/platform/ios/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2646,7 +2646,6 @@ webkit.org/b/171617 perf/object-keys.html [ Pass Failure ]
fast/canvas/webgl/webgl-compressed-texture-size-limit.html [ Failure ]
fast/canvas/webgl/webgl2-texture-upload-enums.html [ Failure ]
fast/canvas/webgl/read-pixels-test.html [ Skip ]
fast/canvas/webgl/webglcontextchangedevent.html [ Skip ]

fast/canvas/webgl/texImage2D-mse-flipY-false.html [ Skip ]
fast/canvas/webgl/texImage2D-mse-flipY-true.html [ Skip ]
Expand Down
2 changes: 0 additions & 2 deletions LayoutTests/platform/mac-wk2/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ webkit.org/b/187183 http/tests/security/pasteboard-file-url.html [ Pass ]

webkit.org/b/231328 http/tests/preload/onload_event.html [ Pass Failure ]

fast/canvas/webgl/context-update-on-display-configuration.html [ Pass ]

fast/misc/valid-primary-screen-displayID.html [ Pass ]

ipc/webpageproxy-correctionpanel-no-crash.html [ Pass ]
Expand Down
1 change: 0 additions & 1 deletion LayoutTests/platform/wincairo/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,6 @@ fast/canvas/webgl/webgl-compressed-texture-astc.html [ Failure ]
fast/canvas/webgl/webgl-compressed-texture-size-limit.html [ Failure ]
fast/canvas/webgl/webgl-depth-texture.html [ Failure ]
fast/canvas/webgl/webgl2-texture-upload-enums.html [ Failure ]
fast/canvas/webgl/webglcontextchangedevent.html [ Skip ] # Timeout
fast/css-grid-layout/grid-align-baseline-vertical.html [ Failure ]
fast/css/font-face-multiple-faces.html [ Failure Pass ]
fast/css/font-face-synthetic-bold-italic.html [ Failure ]
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/dom/EventNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ namespace WebCore {
macro(volumechange) \
macro(waiting) \
macro(waitingforkey) \
macro(webglcontextchanged) \
macro(webglcontextcreationerror) \
macro(webglcontextlost) \
macro(webglcontextrestored) \
Expand Down
5 changes: 2 additions & 3 deletions Source/WebCore/html/HTMLCanvasElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ bool HTMLCanvasElement::virtualHasPendingActivity() const
{
#if ENABLE(WEBGL)
if (is<WebGLRenderingContextBase>(m_context)) {
// WebGL rendering context may fire contextlost / contextchange / contextrestored events at any point.
// WebGL rendering context may fire contextlost / contextrestored events at any point.
return m_hasRelevantWebGLEventListener && !downcast<WebGLRenderingContextBase>(*m_context).isContextUnrecoverablyLost();
}
#endif
Expand All @@ -977,8 +977,7 @@ void HTMLCanvasElement::eventListenersDidChange()
{
#if ENABLE(WEBGL)
auto& eventNames = WebCore::eventNames();
m_hasRelevantWebGLEventListener = hasEventListeners(eventNames.webglcontextchangedEvent)
|| hasEventListeners(eventNames.webglcontextlostEvent)
m_hasRelevantWebGLEventListener = hasEventListeners(eventNames.webglcontextlostEvent)
|| hasEventListeners(eventNames.webglcontextrestoredEvent);
#endif
}
Expand Down
9 changes: 0 additions & 9 deletions Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6072,15 +6072,6 @@ void WebGLRenderingContextBase::recycleContext()
destroyGraphicsContextGL();
}

void WebGLRenderingContextBase::dispatchContextChangedNotification()
{
auto* canvas = htmlCanvas();
if (!canvas)
return;

queueTaskToDispatchEvent(*canvas, TaskSource::WebGL, WebGLContextEvent::create(eventNames().webglcontextchangedEvent, Event::CanBubble::No, Event::IsCancelable::Yes, emptyString()));
}

void WebGLRenderingContextBase::addMembersToOpaqueRoots(JSC::AbstractSlotVisitor& visitor)
{
Locker locker { objectGraphLock() };
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/html/canvas/WebGLRenderingContextBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ class WebGLRenderingContextBase : public GraphicsContextGL::Client, public GPUBa

// GraphicsContextGL::Client
void forceContextLost() override;
void dispatchContextChangedNotification() override;

void recycleContext();

Expand Down
6 changes: 0 additions & 6 deletions Source/WebCore/platform/graphics/GraphicsContextGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,6 @@ void GraphicsContextGL::forceContextLost()
m_client->forceContextLost();
}

void GraphicsContextGL::dispatchContextChangedNotification()
{
if (m_client)
m_client->dispatchContextChangedNotification();
}

#if ENABLE(VIDEO)
RefPtr<Image> GraphicsContextGL::videoFrameToImage(VideoFrame& frame)
{
Expand Down
2 changes: 0 additions & 2 deletions Source/WebCore/platform/graphics/GraphicsContextGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,6 @@ class GraphicsContextGL : public RefCounted<GraphicsContextGL> {
WEBCORE_EXPORT Client();
WEBCORE_EXPORT virtual ~Client();
virtual void forceContextLost() = 0;
virtual void dispatchContextChangedNotification() = 0;
};

WEBCORE_EXPORT GraphicsContextGL(GraphicsContextGLAttributes);
Expand Down Expand Up @@ -1711,7 +1710,6 @@ class GraphicsContextGL : public RefCounted<GraphicsContextGL> {
bool isContextLost() const { return m_contextLost; }
protected:
WEBCORE_EXPORT virtual void forceContextLost();
WEBCORE_EXPORT void dispatchContextChangedNotification();

int m_currentWidth { 0 };
int m_currentHeight { 0 };
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/platform/graphics/GraphicsContextGLEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
namespace WebCore {

enum class GraphicsContextGLSimulatedEventForTesting {
ContextChange,
GPUStatusFailure,
Timeout,
DisplayBufferAllocationFailure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3183,10 +3183,6 @@ void GraphicsContextGLANGLE::polygonOffsetClampEXT(GCGLfloat factor, GCGLfloat u

void GraphicsContextGLANGLE::simulateEventForTesting(SimulatedEventForTesting event)
{
if (event == SimulatedEventForTesting::ContextChange) {
dispatchContextChangedNotification();
return;
}
if (event == SimulatedEventForTesting::GPUStatusFailure || event == SimulatedEventForTesting::DisplayBufferAllocationFailure) {
m_failNextStatusCheck = true;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,6 @@ static bool needsEAGLOnMac()
{
if (m_switchesGPUOnDisplayReconfiguration)
EGL_HandleGPUSwitchANGLE(m_displayObj);
dispatchContextChangedNotification();
}
#endif

Expand Down
3 changes: 0 additions & 3 deletions Source/WebCore/testing/Internals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5692,9 +5692,6 @@ void Internals::simulateEventForWebGLContext(SimulatedWebGLContextEvent event, W
{
WebGLRenderingContext::SimulatedEventForTesting contextEvent;
switch (event) {
case SimulatedWebGLContextEvent::ContextChange:
contextEvent = WebGLRenderingContext::SimulatedEventForTesting::ContextChange;
break;
case SimulatedWebGLContextEvent::GPUStatusFailure:
contextEvent = WebGLRenderingContext::SimulatedEventForTesting::GPUStatusFailure;
break;
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/testing/Internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,6 @@ class Internals final : public RefCounted<Internals>, private ContextDestruction

#if ENABLE(WEBGL)
enum class SimulatedWebGLContextEvent {
ContextChange,
GPUStatusFailure,
Timeout
};
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/testing/Internals.idl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ enum TreeType {
};

[Conditional=WEBGL] enum SimulatedWebGLContextEvent {
"ContextChange",
"GPUStatusFailure",
"Timeout"
};
Expand Down
15 changes: 0 additions & 15 deletions Source/WebKit/GPUProcess/graphics/RemoteGraphicsContextGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ void RemoteGraphicsContextGL::forceContextLost()
send(Messages::RemoteGraphicsContextGLProxy::WasLost());
}

void RemoteGraphicsContextGL::dispatchContextChangedNotification()
{
assertIsCurrent(workQueue());
send(Messages::RemoteGraphicsContextGLProxy::WasChanged());
}

void RemoteGraphicsContextGL::createAndBindEGLImage(GCGLenum target, WebCore::GraphicsContextGL::EGLImageSource source, CompletionHandler<void(uint64_t handle, WebCore::IntSize size)>&& completionHandler)
{
assertIsCurrent(workQueue());
Expand Down Expand Up @@ -302,15 +296,6 @@ void RemoteGraphicsContextGL::simulateEventForTesting(WebCore::GraphicsContextGL
});
return;
}
if (event == WebCore::GraphicsContextGL::SimulatedEventForTesting::ContextChange) {
#if PLATFORM(MAC)
callOnMainRunLoop([weakConnection = m_gpuConnectionToWebProcess]() {
if (auto connection = weakConnection.get())
connection->dispatchDisplayWasReconfiguredForTesting();
});
#endif
return;
}
m_context->simulateEventForTesting(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class RemoteGraphicsContextGL : private WebCore::GraphicsContextGL::Client, publ

// GraphicsContextGL::Client overrides.
void forceContextLost() final;
void dispatchContextChangedNotification() final;

// Messages to be received.
void ensureExtensionEnabled(String&&);
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ set(WebKit_PUBLIC_FRAMEWORK_HEADERS
UIProcess/API/C/WKLayoutMode.h
UIProcess/API/C/WKMediaKeySystemPermissionCallback.h
UIProcess/API/C/WKMessageListener.h
UIProcess/API/C/WKMockDisplay.h
UIProcess/API/C/WKMockMediaDevice.h
UIProcess/API/C/WKNativeEvent.h
UIProcess/API/C/WKNavigationActionRef.h
Expand Down
5 changes: 0 additions & 5 deletions Source/WebKit/Modules/OSX_Private.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -714,11 +714,6 @@ framework module WebKit_Private [system] {
export *
}

explicit module WKMockDisplay {
header "WKMockDisplay.h"
export *
}

explicit module WKMockMediaDevice {
header "WKMockMediaDevice.h"
export *
Expand Down
5 changes: 0 additions & 5 deletions Source/WebKit/Modules/iOS_Private.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -1414,11 +1414,6 @@ framework module WebKit_Private [system] {
export *
}

explicit module WKMockDisplay {
header "WKMockDisplay.h"
export *
}

explicit module WKMockMediaDevice {
header "WKMockMediaDevice.h"
export *
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Shared/WebCoreArgumentCoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ template <> struct EnumTraits<WebCore::CDMInstance::HDCPStatus> {
template <> struct EnumTraits<WebCore::GraphicsContextGLSimulatedEventForTesting> {
using values = EnumValues<
WebCore::GraphicsContextGLSimulatedEventForTesting,
WebCore::GraphicsContextGLSimulatedEventForTesting::ContextChange,
WebCore::GraphicsContextGLSimulatedEventForTesting::GPUStatusFailure,
WebCore::GraphicsContextGLSimulatedEventForTesting::Timeout
>;
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/Sources.txt
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ UIProcess/API/C/WKInspector.cpp
UIProcess/API/C/WKKeyValueStorageManager.cpp
UIProcess/API/C/WKMediaKeySystemPermissionCallback.cpp
UIProcess/API/C/WKMessageListener.cpp
UIProcess/API/C/WKMockDisplay.cpp
UIProcess/API/C/WKMockMediaDevice.cpp
UIProcess/API/C/WKNavigationActionRef.cpp
UIProcess/API/C/WKNavigationDataRef.cpp
Expand Down
Loading

0 comments on commit 5e5018b

Please sign in to comment.