Bug 136576 - can not find cairo-gl.h when build webkit with gtk on ubuntu 14.04
Summary: can not find cairo-gl.h when build webkit with gtk on ubuntu 14.04
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-05 08:04 PDT by Geng Qifu
Modified: 2016-08-29 10:48 PDT (History)
11 users (show)

See Also:


Attachments
Patch (1.23 KB, patch)
2014-12-03 15:19 PST, Alberto Garcia
no flags Details | Formatted Diff | Diff
Patch (1.14 KB, patch)
2014-12-03 15:30 PST, Alberto Garcia
cgarcia: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Geng Qifu 2014-09-05 08:04:26 PDT
I got webkit newest code with svn, then try to build it follow instructions on this page:

http://trac.webkit.org/wiki/BuildingGtk

When I run Tools/Scripts/build-webkit --gtk,
There is an error:
../../Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp:43:22: fatal error: cairo-gl.h: No such file or directory

and I found these two file named cairo-gl.h under webkit directory:
./WebKitBuild/Dependencies/Source/cairo-1.12.8/src/cairo-gl.h
./WebKitBuild/Dependencies/Root/include/cairo/cairo-gl.h

I add "WebKitBuild/Dependencies/Root/include/cairo" to Source/WebCore/PlatformGTK.cmake, then build continue.
Comment 1 Yoav Weiss 2014-09-12 09:06:08 PDT
I'm seeing the same problem.
Comment 2 Alberto Garcia 2014-09-15 07:51:07 PDT
(In reply to comment #0)
> ../../Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp:43:22: fatal error: cairo-gl.h: No such file or directory

> I add "WebKitBuild/Dependencies/Root/include/cairo" to Source/WebCore/PlatformGTK.cmake, then build continue.

This should not be necessary because that should be already in CAIRO_INCLUDE_DIRS.

Can you see what's the value of CAIRO_INCLUDE_DIRS in WebKitBuild/Release/CMakeCache.txt ?

Thanks!
Comment 3 nalldav 2014-09-15 12:11:09 PDT
Same here.

CAIRO_INCLUDE_DIRS:PATH=/usr/include/cairo
Comment 4 Alberto Garcia 2014-09-16 01:11:12 PDT
(In reply to comment #3)
> Same here.
> 
> CAIRO_INCLUDE_DIRS:PATH=/usr/include/cairo

And do you have /usr/include/cairo/cairo-gl.h installed?
Comment 5 Yoav Weiss 2014-09-16 07:01:09 PDT
Seeing the same CAIRO_INCLUDE_DIRS. No cairo-gl.h in /usr/include/cairo
Comment 6 Alberto Garcia 2014-09-16 07:11:55 PDT
(In reply to comment #5)
> Seeing the same CAIRO_INCLUDE_DIRS. No cairo-gl.h in /usr/include/cairo

Ok, there's a couple of things here.

1) You don't seem to have cairo-gl installed in your system. What
   distro are you using? This is not so important.

2) WebKit does not seem to find the version of cairo-gl installed
   under WebKitBuild/Dependencies/. Can you try this?

   $ Tools/jhbuild/jhbuild-wrapper --gtk run pkg-config --cflags cairo-gl
Comment 7 Yoav Weiss 2014-09-16 07:16:46 PDT
I'm using Ubuntu 14.04, and can't really find a cairo-gl package... I'm trying what you suggested. Will report back.
Comment 8 Yoav Weiss 2014-09-16 08:18:26 PDT
The pkg-config did not help
Comment 9 nalldav 2014-09-16 08:37:45 PDT
Ubuntu 14.04 as well.  I'm running it on a VM.  I compiled Cairo from source with --enable-gl --enable-flags --prefix=/usr and webkit compiles now.  Shouldn't the configuration detect if the GL backend is there or not though?
Comment 10 Martin Robinson 2014-09-16 10:11:34 PDT
The build should be using WebKitBuild/Dependencies/Root/include/cairo when including cairo-gl.h. That is the issue here. I'm not sure why that directory wasn't on the include path.
Comment 11 Martin Robinson 2014-09-16 10:12:09 PDT
Perhaps you have a pre-existing CMakeCache.txt file when you built the JHBuild dependencies?
Comment 12 Alberto Garcia 2014-09-16 11:41:50 PDT
(In reply to comment #11)
> Perhaps you have a pre-existing CMakeCache.txt file when you built
> the JHBuild dependencies?

That was my first thought too, but I think we tried this on IRC the
other day and didn't help ...

Yoav, what do you mean with "the pkg-config did not help"? That
command is not going to fix anything by itself, but it should print
the full path of the cairo headers in WebKitBuild/Dependencies/ if
they are detected.

If pkg-config shows WebKitBuild/Dependencies/Root/include/cairo, then
remove WebKitBuild/Release and run "build-webkit --gtk" again.

If after that CAIRO_INCLUDE_DIRS is still pointing to
/usr/include/cairo then it would be a bug, because the version of
Cairo inside WebKitBuild/Dependencies should be used before the one
installed in /usr.
Comment 13 Alberto Garcia 2014-09-16 11:51:58 PDT
(In reply to comment #9)
> Ubuntu 14.04 as well.  I'm running it on a VM.  I compiled Cairo
> from source with --enable-gl --enable-flags --prefix=/usr and webkit
> compiles now.  Shouldn't the configuration detect if the GL backend
> is there or not though?

So if you don't have a GL-enabled Cairo, build-webkit doesn't complain
during the configuration time but in the middle of the compilation,
right?

Is it what happened to you? If that's the case then yes, it seems like a bug.
Comment 14 nalldav 2014-09-17 14:56:44 PDT
Yeah I'm not sure what happened but I trashed the source and got a fresh copy and it compiled without a hitch.  Go figure??
Thanks though.
Comment 15 Geng Qifu 2014-09-17 20:28:39 PDT
(In reply to comment #14)
> Yeah I'm not sure what happened but I trashed the source and got a fresh copy and it compiled without a hitch.  Go figure??
> Thanks though.

Yes, that is the case.
Comment 16 Yoav Weiss 2014-09-20 08:25:36 PDT
Getting a new copy worked for me as well (after disabling SUBTLE_CRYPTO because of https://bugs.webkit.org/show_bug.cgi?id=136158).
Comment 17 Alberto Garcia 2014-09-24 06:21:10 PDT
(In reply to comment #13)
> So if you don't have a GL-enabled Cairo, build-webkit doesn't
> complain during the configuration time but in the middle of the
> compilation, right?

Ok, I don't have much cmake-fu but I'm not sure if this code is really
working:

    if (CAIRO_GL_FOUND)
        WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS ON)
    else ()
        WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
    endif ()
Comment 18 Philippe Normand 2014-11-10 01:24:49 PST
So the plugin process is built with features enabled for the jhbuild deps apart from the gtk2 dep which isn't in jhbuild, that pulls in system-wide deps such as cairo.

One workaround is to disable Accelerated 2d canvas for that part of the build. Like most features I don't think it's actually needed by the plugin process, are they?
Comment 19 Martin Robinson 2014-11-10 08:30:53 PST
(In reply to comment #18)
> So the plugin process is built with features enabled for the jhbuild deps
> apart from the gtk2 dep which isn't in jhbuild, that pulls in system-wide
> deps such as cairo.
> 
> One workaround is to disable Accelerated 2d canvas for that part of the
> build. Like most features I don't think it's actually needed by the plugin
> process, are they?

I do not believe the plugin process needs accelerated 2D canvas.
Comment 20 Alberto Garcia 2014-12-03 02:11:40 PST
We should fix this, webkit currently does not build in Debian (without the jhbuild) because of this, cairo is now built without gl support.
Comment 21 Alberto Garcia 2014-12-03 07:07:52 PST
Ok, so the problem here doesn't seem to have anything to do with the
plugin process, but with what I said in comment #17:

We have this code to detect cairo-gl:

     if (CAIRO_GL_FOUND)
         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS ON)
     else ()
         WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_ACCELERATED_2D_CANVAS OFF)
     endif ()

If cairo-gl is found then ENABLE_ACCELERATED_2D_CANVAS is ON and
everything builds fine.

If cairo-gl is not found then ENABLE_ACCELERATED_2D_CANVAS is OFF and
everything builds fine as well.

However, the build-webkit script sets ENABLE_ACCELERATED_2D_CANVAS to
ON unconditionally in the GTK port (see FeatureList.pm), and the cmake
code above does not override that setting if cairo-gl is not found.

Hence, WebKit expects to find cairo-gl, which is not present, and the
build fails.

Debian does not ship cairo-gl lately (I don't know about other
distros), that's why this error has popped up recently in my system.

The workaround here is to invoke cmake directly or to pass
--cmakeargs=-DENABLE_ACCELERATED_2D_CANVAS=OFF to build-webkit.
Comment 22 Víctor M. Jáquez L. 2014-12-03 08:24:56 PST

> Debian does not ship cairo-gl lately (I don't know about other
> distros), that's why this error has popped up recently in my system.

For sake of completeness: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765684#10
Comment 23 Martin Robinson 2014-12-03 10:43:54 PST
(In reply to comment #21)
> However, the build-webkit script sets ENABLE_ACCELERATED_2D_CANVAS to
> ON unconditionally in the GTK port (see FeatureList.pm), and the cmake
> code above does not override that setting if cairo-gl is not found.

Is Debian using build-webkit to build? That's really only meant for upstream development.
Comment 24 Alberto Garcia 2014-12-03 15:01:41 PST
(In reply to comment #23)
> Is Debian using build-webkit to build? That's really only meant for
> upstream development.

Right, this problem only appears if you use build-webkit, the Debian
packaging is not affected by it, but people doing upstream development
without using jhbuild will find this problem.

I think one solution would be to make build-webkit fail immediately
before compilation if ENABLE_ACCELERATED_2D_CANVAS is enabled but
cairo-gl is not found.

That way the user would be able to see what's going on.
Comment 25 Alberto Garcia 2014-12-03 15:19:02 PST
Created attachment 242529 [details]
Patch

Something like this.
Comment 26 Alberto Garcia 2014-12-03 15:30:02 PST
Created attachment 242530 [details]
Patch

This one is a bit better.
Comment 27 Alberto Garcia 2014-12-04 02:10:14 PST
Committed r176787: <http://trac.webkit.org/changeset/176787>
Comment 28 Mario Sanchez Prada 2015-08-04 03:14:49 PDT
(In reply to comment #0)
> I got webkit newest code with svn, then try to build it follow instructions
> on this page:
> 
> http://trac.webkit.org/wiki/BuildingGtk
> 
> When I run Tools/Scripts/build-webkit --gtk,
> There is an error:
> ../../Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp:43:22: fatal
> error: cairo-gl.h: No such file or directory
> 
> and I found these two file named cairo-gl.h under webkit directory:
> ./WebKitBuild/Dependencies/Source/cairo-1.12.8/src/cairo-gl.h
> ./WebKitBuild/Dependencies/Root/include/cairo/cairo-gl.h
> 

I hit a similar problem to this today, although perhaps not exactly the same issue:

When I tried to build the latest release of WebKitGTK+ (2.9.5) right from the tarball in a 32-bit Linux system withOUT cairo-gl available, ACCELERATED_2D_CANVAS was enabled by default, making the build fail later on with a similar error to the one above, due to "missing cairo-gl.h".

I have no idea why it enabled 2D_ACCELERATED_CANVAS by default, I've just noticed it when I saw the build failing, because of this line in CMakeCache.txt:

  //Toggle accelerated 2D canvas support
  ENABLE_ACCELERATED_2D_CANVAS:BOOL=ON

Will try to provide more info later on, but for now just to mention that I was not using the build-webkit script at all, as I was building straight from the tarball.
Comment 29 Mario Sanchez Prada 2015-08-04 03:35:19 PDT
This seems to be the problem: Even though cairo-gl is not found, CMake ends up concluding that it is found for some reason, and that enables ACCELERATED_2D_CANVAS:

    -- checking for module 'cairo-gl'
    --   package 'cairo-gl' not found
    -- checking for module 'cairo-glx'
    --   package 'cairo-glx' not found
    -- checking for module 'cairo-egl'
    --   package 'cairo-egl' not found
    -- Found CairoGL: CAIRO_GLX_INCLUDE_DIRS;CAIRO_EGL_INCLUDE_DIRS
    (Required is at least version "1.10.2") 
    
    [...]
    
    -- Enabled features:
    --  ENABLE_ACCELERATED_2D_CANVAS ............ ON
    --  ENABLE_CREDENTIAL_STORAGE                 ON
    [...]

Seems like a different bug to me, while file it once I confirm whether this is an issue in the 2.9.5 release or also in the latest master from trunk.
Comment 30 Brian Burg 2016-08-29 10:48:00 PDT
I ran into this when building WebKitGTK from source on one of my old VMs. The solution was to delete the CMakeCache.txt file and re-run CMake so that it uses the correct path to the jhbuild-installed <cairo/cairo_gl.h> header. It had been looking in /usr/include, but it was not installed system-wide.