NEW 181986
[CMake][GTK] OpenGL support should be disabled if only EGL is found
https://bugs.webkit.org/show_bug.cgi?id=181986
Summary [CMake][GTK] OpenGL support should be disabled if only EGL is found
Adrian Perez
Reported 2018-01-23 07:18:51 PST
If a system has an EGL implementation, but it's not possible to find a libGL, libGLES, or libepoxy, then CMake should disable all the WebKit features which depend on OpenGL. Currently, if EGL is found but OpenGL is not, it's assumed that plain OpenGL is being used, which can result in a build error due to the <GL/gl.h> header not being available. You can see this in the following Buildroot compilation log: http://autobuild.buildroot.net/results/57b77520d3a3fcfa683406e223771d0ccf8733df/ If you check the “config” file, you will notice that EGL is indeed enabled (BR2_PACKAGE_HAS_LIBEGL=y) but neither OpenGL nor GLES are (both BR2_PACKAGE_HAS_LIBGL and BR2_PACKAGE_HAS_LIBGLES are undefined)
Attachments
Full log of the CMake configuration step (23.91 KB, text/plain)
2018-01-25 11:21 PST, Adrian Perez
no flags
Carlos Alberto Lopez Perez
Comment 1 2018-01-23 07:31:52 PST
I agree that an EGL library without either a OpenGL or OpenGLES one is useless. But.. how this can happen? That looks like a bug on your/buildroot system.
Michael Catanzaro
Comment 2 2018-01-23 08:52:23 PST
(In reply to Adrian Perez from comment #0) > If a system has an EGL implementation, but it's not possible to find > a libGL, libGLES, or libepoxy, then CMake should disable all the WebKit > features which depend on OpenGL. I don't think so; OpenGL is an important feature and it should never be automagically disabled. The only way that should ever happen is if the user passes -DENABLE_OPENGL=OFF at configure time. The current code allows OpenGL to be automagically replaced with OpenGLES, but it does not allow for both to be automagically disabled. And, if -DENABLE_OPENGL=OFF was passed, this would not be a problem at all. So IMO the problem is that the error occurs too late, at build time instead of configure time. IMO CMake should fail the build when this situation is detected. I'm surprised that didn't happen; our find_package checks should already ensure that. Something must be wrong there.
Adrian Perez
Comment 3 2018-01-23 10:42:35 PST
(In reply to Michael Catanzaro from comment #2) > (In reply to Adrian Perez from comment #0) > > If a system has an EGL implementation, but it's not possible to find > > a libGL, libGLES, or libepoxy, then CMake should disable all the WebKit > > features which depend on OpenGL. > > I don't think so; OpenGL is an important feature and it should never be > automagically disabled. The only way that should ever happen is if the user > passes -DENABLE_OPENGL=OFF at configure time. The current code allows OpenGL > to be automagically replaced with OpenGLES, but it does not allow for both > to be automagically disabled. Indeed, and I agree that we have to keep enabling OpenGL by default, and only disabling it if explicitly requested. As a matter of fact, I will be submitting a patch for Buildroot which makes the build recipe explicitly pass “-DENABLE_OPENGL=OFF” when no OpenGL (ES) is available, plus showing a warning during configuration. > And, if -DENABLE_OPENGL=OFF was passed, this would not be a problem at all. > So IMO the problem is that the error occurs too late, at build time instead > of configure time. IMO CMake should fail the build when this situation is > detected. I'm surprised that didn't happen; our find_package checks should > already ensure that. Something must be wrong there. Agreed. I think there has to be some gremlin in our CMake files. It's not urgent to fix this, but it would be nice to fail early when CMake runs instead of later on during compilation.
Adrian Perez
Comment 4 2018-01-25 11:20:55 PST
I had a few minutes today to check this a bit. This is the CMake command line that Buildroot is using; as you can see it is already passing “-DENABLE_OPENGL=OFF” (reformatting mine to ease reading), check the last few lines: % cmake <…>/webkitgtk-2.18.6/ \ -DCMAKE_TOOLCHAIN_FILE="<…>/toolchainfile.cmake" \ -DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_COLOR_MAKEFILE=OFF \ -DBUILD_DOC=OFF \ -DBUILD_DOCS=OFF \ -DBUILD_EXAMPLE=OFF \ -DBUILD_EXAMPLES=OFF \ -DBUILD_TEST=OFF \ -DBUILD_TESTS=OFF \ -DBUILD_TESTING=OFF \ -DBUILD_SHARED_LIBS=ON \ -DENABLE_API_TESTS=OFF \ -DENABLE_GEOLOCATION=OFF \ -DENABLE_GTKDOC=OFF \ -DENABLE_INTROSPECTION=OFF \ -DENABLE_MINIBROWSER=ON \ -DENABLE_SPELLCHECK=ON \ -DPORT=GTK \ -DUSE_LIBNOTIFY=OFF \ -DUSE_LIBHYPHEN=OFF \ -DENABLE_JIT=ON \ -DENABLE_VIDEO=OFF \ -DENABLE_WEB_AUDIO=OFF \ -DENABLE_MEDIA_STREAM=OFF \ -DENABLE_WEBDRIVER=OFF \ -DENABLE_GLES2=OFF \ -DENABLE_OPENGL=OFF Then the configuration summary at the end of the run is: -- Enabled features: -- ENABLE_ACCELERATED_2D_CANVAS .......... OFF -- ENABLE_DRAG_SUPPORT ON -- ENABLE_GEOLOCATION .................... OFF -- ENABLE_GLES2 OFF -- ENABLE_GTKDOC ......................... OFF -- ENABLE_ICONDATABASE ON -- ENABLE_INTROSPECTION .................. OFF -- ENABLE_JIT ON -- ENABLE_MINIBROWSER .................... ON -- ENABLE_OPENGL OFF -- ENABLE_PLUGIN_PROCESS_GTK2 ............ OFF -- ENABLE_QUARTZ_TARGET OFF -- ENABLE_SAMPLING_PROFILER .............. ON -- ENABLE_SPELLCHECK ON -- ENABLE_TOUCH_EVENTS ................... ON -- ENABLE_VIDEO OFF -- ENABLE_WAYLAND_TARGET ................. OFF -- ENABLE_WEBDRIVER OFF -- ENABLE_WEB_AUDIO ...................... OFF -- ENABLE_WEB_CRYPTO ON -- ENABLE_X11_TARGET ..................... OFF -- USE_LIBHYPHEN OFF -- USE_LIBNOTIFY ......................... OFF -- USE_LIBSECRET ON -- USE_SYSTEM_MALLOC ..................... OFF See how both X11 and Wayland targets are disabled. Looking at the steps during detection, there's the following three relevant snippets (gtk+-3.0 is found, egl is found, but none of gtk+-x11-3.0, gtk+-wayland-3.0, gl, or glesv2 can be found): -- Checking for module 'gtk+-x11-3.0' -- Package gtk+-x11-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-x11-3.0.pc' to the PKG_CONFIG_PATH environment variable Package 'gtk+-x11-3.0', required by 'world', not found -- Checking for module 'gtk+-wayland-3.0' -- Package gtk+-wayland-3.0 was not found in the pkg-config search path. Perhaps you should add the directory containing `gtk+-wayland-3.0.pc' to the PKG_CONFIG_PATH environment variable Package 'gtk+-wayland-3.0', required by 'world', not found -- Found GTK3: <…> (Required is at least version "3.6.0") -- Checking for module 'gdk-3.0' -- Found gdk-3.0, version 3.22.15 -- Found GDK3: <…> (Required is at least version "3.6.0") -- Checking for module 'egl' -- Found egl, version 17.3.3 -- Found EGL: /home/aperez/buildroot/qemu-x64/host/x86_64-buildroot-linux-gnu/sysroot/usr/include -- Checking for module 'gl' -- Package gl was not found in the pkg-config search path. Perhaps you should add the directory containing `gl.pc' to the PKG_CONFIG_PATH environment variable Package 'gl', required by 'world', not found -- Could NOT find OpenGL (missing: OPENGL_INCLUDE_DIRS OPENGL_LIBRARIES) -- Checking for module 'glesv2' -- Package glesv2 was not found in the pkg-config search path. Perhaps you should add the directory containing `glesv2.pc' to the PKG_CONFIG_PATH environment variable Package 'glesv2', required by 'world', not found -- Could NOT find OpenGLES2 (missing: OPENGLES2_INCLUDE_DIRS OPENGLES2_LIBRARIES) So regarless of having “-DUSE_OPENGL=OFF”, the build still tries to use EGL, which means “#if USE(EG)” is true, and I suspect some of the code guarded with USE(EGL) assumes that the <GL/gl.h> is available. I think one possible solution here is to forcibly set “USE_EGL=OFF” if “USE_OPENGL=OFF”, or neither OpenGL nor OpenGL ES can be found. It is even arguable that when “-DUSE_OPENGL=OFF” is passed, CMake shouldn't even try to find EGL/GL/GLES. What do you people think?
Adrian Perez
Comment 5 2018-01-25 11:21:47 PST
Created attachment 332289 [details] Full log of the CMake configuration step Here's the full output log of the configuration step.
Carlos Alberto Lopez Perez
Comment 6 2018-01-25 11:26:48 PST
(In reply to Adrian Perez from comment #4) > Then the configuration summary at the end of the run is: > > -- Enabled features: [...] > -- ENABLE_QUARTZ_TARGET OFF [...] > -- ENABLE_WAYLAND_TARGET ................. OFF [...] > -- ENABLE_X11_TARGET ..................... OFF > [...] > See how both X11 and Wayland targets are disabled. This should be a fatal error. You can't build without any target. I think we need to check at configure time (CMake) that at least one target is enabled.
Michael Catanzaro
Comment 7 2018-01-25 14:35:31 PST
(In reply to Adrian Perez from comment #4) > I think one possible solution here is to forcibly set “USE_EGL=OFF” > if “USE_OPENGL=OFF”, or neither OpenGL nor OpenGL ES can be found. > It is even arguable that when “-DUSE_OPENGL=OFF” is passed, CMake > shouldn't even try to find EGL/GL/GLES. > > What do you people think? I don't know. Isn't EGL required for Wayland regardless of whether OpenGL is used? (In reply to Carlos Alberto Lopez Perez from comment #6) > This should be a fatal error. You can't build without any target. > I think we need to check at configure time (CMake) that at least one target > is enabled. Yes.
Carlos Alberto Lopez Perez
Comment 8 2018-01-25 16:09:31 PST
(In reply to Michael Catanzaro from comment #7) > (In reply to Adrian Perez from comment #4) > > I think one possible solution here is to forcibly set “USE_EGL=OFF” > > if “USE_OPENGL=OFF”, or neither OpenGL nor OpenGL ES can be found. > > It is even arguable that when “-DUSE_OPENGL=OFF” is passed, CMake > > shouldn't even try to find EGL/GL/GLES. > > > > What do you people think? > > I don't know. Isn't EGL required for Wayland regardless of whether OpenGL is > used? > You can't use EGL without OpenGL (I believe). So if EGL is required, then either OpenGL or OpenGL-ES should be also required. I'm unsure if its possible running WebKitGTK+ on Wayland without OpenGL/EGL (by disabling AC mode)
Note You need to log in before you can comment on or make changes to this bug.