Changeset 207590 in webkit
- Timestamp:
- Oct 20, 2016 1:33:44 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207588 r207590 1 2016-10-20 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Wrong use of EGL_DEPTH_SIZE 4 https://bugs.webkit.org/show_bug.cgi?id=155536 5 6 Reviewed by Michael Catanzaro. 7 8 What happens here is that the driver doesn't implement EGL_DEPTH_SIZE and the default value, which is 0, is 9 returned. Then XCreatePixmap fails because 0 is not a valid depth. The thing is that even if EGL_DEPTH_SIZE or 10 EGL_BUFFER_SIZE returned a valid depth, it still might not be supported by the default screen and XCreatePixmap 11 can fail. What we need to ensure is that the depth we pass is compatible with the X display, not only with the 12 EGL config, to avoid failures when creating the pixmap. So, we can use EGL_NATIVE_VISUAL_ID instead, and 13 then ask X for the visual info for that id. If it isn't found then we just return before creating the pixmap, 14 but if the visual is found then we can be sure that the depth of the visual will not make the pixmap creation 15 fail. However, with the driver I'm using it doesn't matter how we create the pixmap that eglCreatePixmapSurface 16 always fails, again with X errors that are fatal by default. Since the driver is not free, I assume it doesn't 17 support eglCreatePixmapSurface or it's just buggy, so the only option we have here is trap the x errors and 18 ignore them. It turns out that the X errors are not fatal in this case, because eglCreatePixmapSurface ends up 19 returning a surface, and since these are offscreen contexts, it doesn't really matter if they contain an 20 invalid pixmap, because we never do swap buffer on them, so just ignoring the X errors fixes the crashes and 21 makes everythig work. This patch adds a helper class XErrorTrapper that allows to trap XErrors and decide what 22 to do with them (ignore, warn or crash) or even not consider a particular set of errors as errors. 23 24 * PlatformEfl.cmake: Add new file to compilation. 25 * PlatformGTK.cmake: Ditto. 26 * platform/graphics/egl/GLContextEGL.cpp: 27 (WebCore::GLContextEGL::createPixmapContext): Use EGL_NATIVE_VISUAL_ID instead of EGL_DEPTH_SIZE to figure out 28 the depth to be passed to XCreatePixmap. Also use the XErrorTrapper class to ignore all BadDrawable errors 29 produced by eglCreatePixmapSurface() and only show a warning about all other X errors. 30 * platform/graphics/x11/XErrorTrapper.cpp: Added. 31 (WebCore::xErrorTrappersMap): 32 (WebCore::XErrorTrapper::XErrorTrapper): 33 (WebCore::XErrorTrapper::~XErrorTrapper): 34 (WebCore::XErrorTrapper::errorCode): 35 (WebCore::XErrorTrapper::errorEvent): 36 * platform/graphics/x11/XErrorTrapper.h: Added. 37 (WebCore::XErrorTrapper::XErrorTrapper): 38 1 39 2016-10-20 Nael Ouedraogo <nael.ouedraogo@crf.canon.fr> 2 40 -
trunk/Source/WebCore/PlatformEfl.cmake
r206883 r207590 183 183 184 184 platform/graphics/x11/PlatformDisplayX11.cpp 185 platform/graphics/x11/XErrorTrapper.cpp 185 186 platform/graphics/x11/XUniqueResource.cpp 186 187 -
trunk/Source/WebCore/PlatformGTK.cmake
r207406 r207590 150 150 151 151 platform/graphics/x11/PlatformDisplayX11.cpp 152 platform/graphics/x11/XErrorTrapper.cpp 152 153 platform/graphics/x11/XUniqueResource.cpp 153 154 -
trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
r205116 r207590 37 37 #if PLATFORM(X11) 38 38 #include "PlatformDisplayX11.h" 39 #include "XErrorTrapper.h" 40 #include "XUniquePtr.h" 39 41 #include <X11/Xlib.h> 40 42 #endif … … 176 178 return nullptr; 177 179 178 EGLint depth;179 if (!eglGetConfigAttrib(display, config, EGL_ DEPTH_SIZE, &depth)) {180 EGLint visualId; 181 if (!eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &visualId)) { 180 182 eglDestroyContext(display, context); 181 183 return nullptr; … … 183 185 184 186 Display* x11Display = downcast<PlatformDisplayX11>(platformDisplay).native(); 185 XUniquePixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, depth); 187 188 XVisualInfo visualInfo; 189 visualInfo.visualid = visualId; 190 int numVisuals = 0; 191 XUniquePtr<XVisualInfo> visualInfoList(XGetVisualInfo(x11Display, VisualIDMask, &visualInfo, &numVisuals)); 192 if (!visualInfoList || !numVisuals) { 193 eglDestroyContext(display, context); 194 return nullptr; 195 } 196 197 // We are using VisualIDMask so there must be only one. 198 ASSERT(numVisuals == 1); 199 XUniquePixmap pixmap = XCreatePixmap(x11Display, DefaultRootWindow(x11Display), 1, 1, visualInfoList.get()[0].depth); 186 200 if (!pixmap) { 187 201 eglDestroyContext(display, context); … … 189 203 } 190 204 205 // Some drivers fail to create the surface producing BadDrawable X error and the default XError handler normally aborts. 206 // However, if the X error is ignored, eglCreatePixmapSurface() ends up returning a surface and we can continue creating 207 // the context. Since this is an offscreen context, it doesn't matter if the pixmap used is not valid because we never do 208 // swap buffers. So, we use a custom XError handler here that ignores BadDrawable errors and only warns about any other 209 // errors without aborting in any case. 210 XErrorTrapper trapper(x11Display, XErrorTrapper::Policy::Warn, { BadDrawable }); 191 211 EGLSurface surface = eglCreatePixmapSurface(display, config, reinterpret_cast<EGLNativePixmapType>(pixmap.get()), 0); 192 212 if (surface == EGL_NO_SURFACE) { -
trunk/Source/WebKit2/ChangeLog
r207586 r207590 1 2016-10-20 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Wrong use of EGL_DEPTH_SIZE 4 https://bugs.webkit.org/show_bug.cgi?id=155536 5 6 Reviewed by Michael Catanzaro. 7 8 Use XErrorTrapper class instead of the custom XErrorHandler. 9 10 * PluginProcess/unix/PluginProcessMainUnix.cpp: 11 (WebKit::PluginProcessMainUnix): 12 1 13 2016-10-19 Carlos Garcia Campos <cgarcia@igalia.com> 2 14 -
trunk/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp
r170183 r207590 37 37 #include <WebCore/FileSystem.h> 38 38 #include <stdlib.h> 39 #include <wtf/text/CString.h>40 39 41 40 #if PLATFORM(GTK) … … 45 44 #endif 46 45 46 #if defined(XP_UNIX) 47 #include <WebCore/PlatformDisplayX11.h> 48 #include <WebCore/XErrorTrapper.h> 49 #endif 50 47 51 namespace WebKit { 48 52 49 53 #if defined(XP_UNIX) 50 51 #if !LOG_DISABLED 52 static const char xErrorString[] = "The program '%s' received an X Window System error.\n" 53 "This probably reflects a bug in a browser plugin.\n" 54 "The error was '%s'.\n" 55 " (Details: serial %ld error_code %d request_code %d minor_code %d)\n"; 56 #endif // !LOG_DISABLED 57 58 static CString programName; 59 60 static int webkitXError(Display* xdisplay, XErrorEvent* error) 61 { 62 char errorMessage[64]; 63 XGetErrorText(xdisplay, error->error_code, errorMessage, 63); 64 65 LOG(Plugins, xErrorString, programName.data(), errorMessage, error->serial, error->error_code, error->request_code, error->minor_code); 66 67 return 0; 68 } 54 static std::unique_ptr<WebCore::XErrorTrapper> xErrorTrapper; 69 55 #endif // XP_UNIX 70 56 … … 99 85 100 86 #if defined(XP_UNIX) 101 programName = WebCore::pathGetFileName(argv[0]).utf8(); 102 XSetErrorHandler(webkitXError); 87 if (WebCore::PlatformDisplay::sharedDisplay().type() == WebCore::PlatformDisplay::Type::X11) { 88 auto* display = downcast<WebCore::PlatformDisplayX11>(WebCore::PlatformDisplay::sharedDisplay()).native(); 89 xErrorTrapper = std::make_unique<WebCore::XErrorTrapper>(display, WebCore::XErrorTrapper::Policy::Warn); 90 } 103 91 #endif 104 92
Note: See TracChangeset
for help on using the changeset viewer.