Bug 183923

Summary: The layout test fast/canvas/webgl/read-pixels-test.html is timing out.
Product: WebKit Reporter: Per Arne Vollan <pvollan>
Component: WebCore Misc.Assignee: Per Arne Vollan <pvollan>
Status: NEW    
Severity: Normal CC: benjamin, bfulgham, cdumez, cmarcelo, commit-queue, dbates, dino, ews-watchlist, graouts, kondapallykalyan, mmaxfield, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
bfulgham: review+, bfulgham: commit-queue-
Patch none

Per Arne Vollan
Reported 2018-03-22 16:24:38 PDT
This happens when there is no WindowServer connection.
Attachments
Patch (1.82 KB, patch)
2018-03-22 16:28 PDT, Per Arne Vollan
no flags
Patch (13.19 KB, patch)
2018-03-26 15:29 PDT, Per Arne Vollan
no flags
Patch (13.09 KB, patch)
2018-03-26 15:39 PDT, Per Arne Vollan
no flags
Patch (14.39 KB, patch)
2018-03-27 11:25 PDT, Per Arne Vollan
no flags
Patch (14.52 KB, patch)
2018-03-27 12:08 PDT, Per Arne Vollan
no flags
Patch (14.58 KB, patch)
2018-03-27 12:11 PDT, Per Arne Vollan
no flags
Patch (17.65 KB, patch)
2018-03-27 14:09 PDT, Per Arne Vollan
bfulgham: review+
bfulgham: commit-queue-
Patch (17.62 KB, patch)
2018-03-27 15:35 PDT, Per Arne Vollan
no flags
Per Arne Vollan
Comment 1 2018-03-22 16:28:41 PDT
Tim Horton
Comment 2 2018-03-22 16:33:41 PDT
Comment on attachment 336325 [details] Patch I assume there's a reason that we're not setting this bit if we don't have a mux-capable GPU, and also this is not the only caller of that function. We need to carefully consider each caller and what it means if this function now lies.
Tim Horton
Comment 3 2018-03-22 16:34:02 PDT
Ccing Dean, who IIRC wrote this
Brent Fulgham
Comment 4 2018-03-22 16:40:13 PDT
Comment on attachment 336325 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=336325&action=review > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:337 > attribs.append(kCGLPFAAllowOfflineRenderers); I actually don't understand why we need to decide whether to set this or not. It seems like for modern WebKit, all of our OpenGL drawing is in an "offline renderer" mode, isn't? We don't throw bits directly from the GPU to the display, do we? I thought it all had to pass to the UIProcess for display?
Tim Horton
Comment 5 2018-03-22 16:42:38 PDT
This is not about whatever you’re talking about, this is about discrete vs. integrated GPU.
Per Arne Vollan
Comment 6 2018-03-23 07:18:05 PDT
(In reply to Tim Horton from comment #2) > Comment on attachment 336325 [details] > Patch > > I assume there's a reason that we're not setting this bit if we don't have a > mux-capable GPU, and also this is not the only caller of that function. We > need to carefully consider each caller and what it means if this function > now lies. Thanks for reviewing! I will look more closely into this.
Per Arne Vollan
Comment 7 2018-03-26 15:29:04 PDT
Per Arne Vollan
Comment 8 2018-03-26 15:39:53 PDT
Per Arne Vollan
Comment 9 2018-03-26 17:10:49 PDT
(In reply to Per Arne Vollan from comment #8) > Created attachment 336548 [details] > Patch We should probably use CGLQueryRendererInfo, instead.
Per Arne Vollan
Comment 10 2018-03-27 11:25:48 PDT
Per Arne Vollan
Comment 11 2018-03-27 12:08:04 PDT
Per Arne Vollan
Comment 12 2018-03-27 12:11:34 PDT
Brent Fulgham
Comment 13 2018-03-27 12:27:36 PDT
Comment on attachment 336609 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=336609&action=review > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:486 > + if (m_displayMask && m_contextObj) { I feel like this might be better as a function, "identifyAndSetCurrentGPU" or something like that. > Source/WebKit/UIProcess/WebPageProxy.cpp:2651 > + CGOpenGLDisplayMask currentDisplaymask = CGDisplayIDToOpenGLDisplayMask(displayID); auto?
Per Arne Vollan
Comment 14 2018-03-27 12:38:50 PDT
(In reply to Brent Fulgham from comment #13) > Comment on attachment 336609 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=336609&action=review > > > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:486 > > + if (m_displayMask && m_contextObj) { > > I feel like this might be better as a function, "identifyAndSetCurrentGPU" > or something like that. > > > Source/WebKit/UIProcess/WebPageProxy.cpp:2651 > > + CGOpenGLDisplayMask currentDisplaymask = CGDisplayIDToOpenGLDisplayMask(displayID); > > auto? Thanks for reviewing! I will update the patch.
Per Arne Vollan
Comment 15 2018-03-27 14:09:41 PDT
Brent Fulgham
Comment 16 2018-03-27 14:37:39 PDT
Comment on attachment 336616 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=336616&action=review > Source/WebCore/ChangeLog:9 > + The test is timing out because software rendering is being used when there is no WindowServer access. The test is timing out when we do not interact directly with the WindowServer, causing OpenGL to fall back to software rendering. In this mode, any call to CGLChoosePixelFormat requesting an accelerated pixel format will fail because it cannot determine which GPU is connected to the display. OpenGL treats all GPUs as if they were offline when used in a process (like the WebContent process) that does not directly control the display. We can get correct behavior if we tell OpenGL which GPU is currently connected to the display, and if we instruct CGLChoosePixelFormat to create an offline renderer pixel format by including the 'kCGLPFAAllowOfflineRenderers' flag in its arguments. We can use CGLSetVirtualScreen with an OpenGL display mask that tells the OpenGL framework which GPU it should use. See https://developer.apple.com/library/content/technotes/tn2229/_index.html#//apple_ref/doc/uid/DTS40008924-CH1-SUBSECTION7 for details on how the virtual screen is found from the OpenGL display mask. > Source/WebCore/WebCore.xcodeproj/project.pbxproj:1273 > + 49C7B9FC1042D3650009D447 /* GraphicsContext3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C7B9FB1042D3650009D447 /* GraphicsContext3D.h */; settings = {ATTRIBUTES = (Private, ); }; }; Were these two changes intentional? > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:406 > + // To help OpenGL choose GPU, it is possible to use the function CGLSetVirtualScreen. // CGLSetVirtualScreen can be used to tell OpenGL which GPU it should be using. > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:412 > + for (int virtualScreen = 0; virtualScreen < numPixelFormats; virtualScreen++) { ++virtualScreen > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:468 > + setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling, attrs.useGLES3, allowOfflineRenderers()); How do we know m_displayMask is set properly here? Does the WebPage always receive OpenGLDisplayMaskChanged when a new Web Process is launched? > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:808 > + if (!hasWindowServerConnection) Isn't this just: if (!!m_displayMask) return true;
Per Arne Vollan
Comment 17 2018-03-27 15:02:02 PDT
(In reply to Brent Fulgham from comment #16) > Comment on attachment 336616 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=336616&action=review > > > Source/WebCore/ChangeLog:9 > > + The test is timing out because software rendering is being used when there is no WindowServer access. > > The test is timing out when we do not interact directly with the > WindowServer, causing > OpenGL to fall back to software rendering. In this mode, any call to > CGLChoosePixelFormat > requesting an accelerated pixel format will fail because it cannot determine > which GPU is > connected to the display. > > OpenGL treats all GPUs as if they were offline when used in a process (like > the WebContent > process) that does not directly control the display. > > We can get correct behavior if we tell OpenGL which GPU is currently > connected to the > display, and if we instruct CGLChoosePixelFormat to create an offline > renderer pixel format > by including the 'kCGLPFAAllowOfflineRenderers' flag in its arguments. > > We can use CGLSetVirtualScreen with an OpenGL display mask that tells the > OpenGL framework > which GPU it should use. > > See > https://developer.apple.com/library/content/technotes/tn2229/_index.html#// > apple_ref/doc/uid/DTS40008924-CH1-SUBSECTION7 > for details on how the virtual screen is found from the OpenGL display mask. > > > Source/WebCore/WebCore.xcodeproj/project.pbxproj:1273 > > + 49C7B9FC1042D3650009D447 /* GraphicsContext3D.h in Headers */ = {isa = PBXBuildFile; fileRef = 49C7B9FB1042D3650009D447 /* GraphicsContext3D.h */; settings = {ATTRIBUTES = (Private, ); }; }; > > Were these two changes intentional? > Yes, these WebCore files are now included from WebKit. > > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:406 > > + // To help OpenGL choose GPU, it is possible to use the function CGLSetVirtualScreen. > > // CGLSetVirtualScreen can be used to tell OpenGL which GPU it should be > using. > > > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:412 > > + for (int virtualScreen = 0; virtualScreen < numPixelFormats; virtualScreen++) { > > ++virtualScreen > > > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:468 > > + setPixelFormat(attribs, 32, 32, !attrs.forceSoftwareRenderer, true, false, useMultisampling, attrs.useGLES3, allowOfflineRenderers()); > > How do we know m_displayMask is set properly here? Does the WebPage always > receive OpenGLDisplayMaskChanged when a new Web Process is launched? > Yes, we should always get a display mask when a Web Process is launched, since the display mask is sent when the display ID is sent. > > Source/WebCore/platform/graphics/cocoa/GraphicsContext3DCocoa.mm:808 > > + if (!hasWindowServerConnection) > > Isn't this just: > > if (!!m_displayMask) > return true; Thanks for reviewing!
Per Arne Vollan
Comment 18 2018-03-27 15:35:14 PDT
Radar WebKit Bug Importer
Comment 19 2018-03-27 15:54:18 PDT
Per Arne Vollan
Comment 20 2018-03-27 16:17:59 PDT
WebKit Commit Bot
Comment 21 2018-03-27 16:39:45 PDT
Comment on attachment 336625 [details] Patch Clearing flags on attachment: 336625 Committed r230015: <https://trac.webkit.org/changeset/230015>
Note You need to log in before you can comment on or make changes to this bug.