RESOLVED FIXED 231011
ScopedEGLDefaultDisplay should be removed
https://bugs.webkit.org/show_bug.cgi?id=231011
Summary ScopedEGLDefaultDisplay should be removed
Kimmo Kinnunen
Reported 2021-09-30 01:33:58 PDT
ScopedEGLDefaultDisplay should be removed It makes the use of EGLDisplays harder, especially in scenarios where there might be multiple EGLDisplays
Attachments
Patch (61.00 KB, patch)
2021-09-30 01:50 PDT, Kimmo Kinnunen
no flags
Patch (61.13 KB, patch)
2021-09-30 10:03 PDT, Kimmo Kinnunen
ews-feeder: commit-queue-
Patch (61.55 KB, patch)
2021-09-30 10:26 PDT, Kimmo Kinnunen
no flags
Patch for landing (61.83 KB, patch)
2021-10-01 05:17 PDT, Kimmo Kinnunen
no flags
Patch for landing (61.67 KB, patch)
2021-10-01 07:00 PDT, Kimmo Kinnunen
no flags
Patch for landing (65.63 KB, patch)
2021-10-05 01:50 PDT, Kimmo Kinnunen
no flags
Patch for landing (61.83 KB, patch)
2021-10-06 04:27 PDT, Kimmo Kinnunen
no flags
Patch for landing (61.85 KB, patch)
2021-10-06 23:37 PDT, Kimmo Kinnunen
no flags
Kimmo Kinnunen
Comment 1 2021-09-30 01:50:57 PDT
Kimmo Kinnunen
Comment 2 2021-09-30 10:03:55 PDT
Kimmo Kinnunen
Comment 3 2021-09-30 10:26:56 PDT
Kenneth Russell
Comment 4 2021-09-30 13:31:30 PDT
Comment on attachment 439755 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=439755&action=review Looks good overall, and a good step toward better supporting multiple EGLDisplays. A couple of small naming suggestions, but feel free to take/ignore as you see fit. r+ > Source/WebCore/platform/graphics/angle/GraphicsContextGLANGLE.cpp:107 > + EGL_Terminate(display); If TerminateAndReleaseThreadResources is passed, this code calls EGL_Terminate before falling through to the EGL_ReleaseThread call below. Is that the correct order in which to call these fairly low-level APIs? It looks like it probably is - just asking for a double-check. I hope this is tested in UIWebView (?) tests on the ios-wk2 bot and not just in the wild. > Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:64 > return !!EGL_Initialize; How does this turn into a function pointer that can be tested in this way? Via some of the weak-linked dylib magic that was added recently? Worth adding a comment? > Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:121 > + enum class ReleaseResourcesBehavior { Reading this code afresh, the term "ReleaseResources" in this enum and in the method call is a little confusing - it sounds like OpenGL resources like textures or buffers are being released, where in fact thread-related resources like the current context or access to the EGL API are being released. I wonder whether a different name could be chosen like: ReleaseThreadResourcesBehavior ReleasePerThreadResourcesBehavior ReleaseEGLResourcesBehavior (and releasePerThreadResources(), releaseEGLResources(), or similar.) > Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:584 > + static void platformReleaseResources(); If releaseResources is renamed, let's rename this to match.
Kimmo Kinnunen
Comment 5 2021-10-01 05:16:03 PDT
Thanks for the thoughts! (In reply to Kenneth Russell from comment #4) > If TerminateAndReleaseThreadResources is passed, this code calls > EGL_Terminate before falling through to the EGL_ReleaseThread call below. Is > that the correct order in which to call these fairly low-level APIs? It > looks like it probably is - just asking for a double-check. Yeah. First destroy the display, then free driver internal structures, like potential TLS slots. > I hope this is > tested in UIWebView (?) tests on the ios-wk2 bot and not just in the wild. Yeah, I actually wrote a test for it year ago, WebGLNoCrashOnOnOtherThreadAccess, though it starts to be a bit outdated since EAGL isn't used on iOS anymore. > > > Source/WebCore/platform/graphics/cocoa/GraphicsContextGLOpenGLCocoa.mm:64 > > return !!EGL_Initialize; > > How does this turn into a function pointer that can be tested in this way? > Via some of the weak-linked dylib magic that was added recently? > Worth adding a comment? Correct. Added. > > > Source/WebCore/platform/graphics/opengl/GraphicsContextGLOpenGL.h:121 > > + enum class ReleaseResourcesBehavior { > > Reading this code afresh, the term "ReleaseResources" in this enum and in > the method call is a little confusing - it sounds like OpenGL resources like > textures or buffers are being released, where in fact thread-related > resources like the current context or access to the EGL API are being > released. > > I wonder whether a different name could be chosen like: > ReleaseThreadResourcesBehavior Used this.
Kimmo Kinnunen
Comment 6 2021-10-01 05:17:12 PDT
Created attachment 439840 [details] Patch for landing
Kimmo Kinnunen
Comment 7 2021-10-01 06:52:57 PDT
*** Bug 230951 has been marked as a duplicate of this bug. ***
Kimmo Kinnunen
Comment 8 2021-10-01 07:00:44 PDT
Created attachment 439854 [details] Patch for landing
Kenneth Russell
Comment 9 2021-10-04 16:19:37 PDT
Still looks good. Did this land? Note that if you fix up the "Reviewed by" lines in the Changelog, you don't need to set the r+ flag yourself.
Kimmo Kinnunen
Comment 10 2021-10-05 00:39:06 PDT
Comment on attachment 439854 [details] Patch for landing User error: first I waited on the mac-debug-wk1 which never showed up, then I set the plus on wrong field..
EWS
Comment 11 2021-10-05 00:40:18 PDT
Tools/Scripts/svn-apply failed to apply attachment 439854 [details] to trunk. Please resolve the conflicts and upload a new patch.
Kimmo Kinnunen
Comment 12 2021-10-05 01:50:45 PDT
Created attachment 440182 [details] Patch for landing
EWS
Comment 13 2021-10-05 12:15:11 PDT
Tools/Scripts/svn-apply failed to apply attachment 440182 [details] to trunk. Please resolve the conflicts and upload a new patch.
Kimmo Kinnunen
Comment 14 2021-10-06 04:27:45 PDT
Created attachment 440352 [details] Patch for landing
EWS
Comment 15 2021-10-06 04:29:43 PDT
ChangeLog entry in Source/WebKit/ChangeLog contains OOPS!.
Kimmo Kinnunen
Comment 16 2021-10-06 23:37:17 PDT
Created attachment 440473 [details] Patch for landing
EWS
Comment 17 2021-10-07 01:08:50 PDT
Committed r283703 (242629@main): <https://commits.webkit.org/242629@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 440473 [details].
Radar WebKit Bug Importer
Comment 18 2021-10-07 01:09:21 PDT
Michael Catanzaro
Comment 19 2021-10-07 10:43:14 PDT
Hi, the non-ANGLE implementation of GraphicsContextGLOpenGL::releaseThreadResources is broken, it's missing its return value: bool GraphicsContextGLOpenGL::releaseThreadResources(ReleaseThreadResourceBehavior) { } The ANGLE implementation carefully chooses between true or false, but I don't understand how or why. It's called from only two places, WebCoreThread.mm and ScopedWebGLRenderingResourcesRequest.cpp, and neither caller checks the return value, so it's somewhat academic, I suppose. I'm going to have it always return false, but you might consider converting this to return void.
Note You need to log in before you can comment on or make changes to this bug.