Bug 138093 - [GTK] Move RedirectedXCompositeWindow from platform to WebKit2 layer
Summary: [GTK] Move RedirectedXCompositeWindow from platform to WebKit2 layer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: Gtk
Depends on:
Blocks:
 
Reported: 2014-10-27 07:23 PDT by Carlos Garcia Campos
Modified: 2014-11-12 04:13 PST (History)
6 users (show)

See Also:


Attachments
Patch (32.46 KB, patch)
2014-10-27 07:28 PDT, Carlos Garcia Campos
mrobinson: review-
Details | Formatted Diff | Diff
Updated patch explaining all the cleanups in the changelog (33.67 KB, patch)
2014-10-28 08:44 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Cleanup diffs to make it easier to review (14.17 KB, patch)
2014-10-28 08:44 PDT, Carlos Garcia Campos
no flags Details | Formatted Diff | Diff
Updated patch according to review comments (33.07 KB, patch)
2014-10-30 04:13 PDT, Carlos Garcia Campos
mrobinson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2014-10-27 07:23:18 PDT
It's only used by WebKitWebViewBase.
Comment 1 Carlos Garcia Campos 2014-10-27 07:28:35 PDT
Created attachment 240480 [details]
Patch
Comment 2 WebKit Commit Bot 2014-10-27 07:30:26 PDT
Attachment 240480 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:434:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Martin Robinson 2014-10-27 12:45:26 PDT
Comment on attachment 240480 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=240480&action=review

> Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp:-189
> -    if (m_needsContext == CreateGLContext) {
> -        context()->waitNative();
> -        // This swap is based on code in Chromium. It tries to work-around a bug in the Intel drivers
> -        // where a swap is necessary to ensure the front and back buffers are properly resized.
> -        if (context() == GLContext::getCurrent())
> -            context()->swapBuffers();
> -    }
> -

I'm not sure that it is appropriate to remove this workaround in this patch. Please move the file and then make separate changes (like the cool anonymous function) in separate patches. I'm worried about introducing hidden regressions.

> Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:-75
> -#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
> -#include <WebCore/RedirectedXCompositeWindow.h>
> -#endif

I think we need to maintain at least PLATFORM(X11) here to deal with Wayland.
Comment 4 Carlos Garcia Campos 2014-10-28 00:29:52 PDT
(In reply to comment #3)
> Comment on attachment 240480 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=240480&action=review
> 
> > Source/WebCore/platform/gtk/RedirectedXCompositeWindow.cpp:-189
> > -    if (m_needsContext == CreateGLContext) {
> > -        context()->waitNative();
> > -        // This swap is based on code in Chromium. It tries to work-around a bug in the Intel drivers
> > -        // where a swap is necessary to ensure the front and back buffers are properly resized.
> > -        if (context() == GLContext::getCurrent())
> > -            context()->swapBuffers();
> > -    }
> > -
> 
> I'm not sure that it is appropriate to remove this workaround in this patch.

That's dead code, since the CreateGLContext mode is not used at all.

> Please move the file and then make separate changes (like the cool anonymous
> function) in separate patches. I'm worried about introducing hidden
> regressions.

I can make a diff of the file.

> > Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:-75
> > -#if USE(TEXTURE_MAPPER_GL) && PLATFORM(X11)
> > -#include <WebCore/RedirectedXCompositeWindow.h>
> > -#endif
> 
> I think we need to maintain at least PLATFORM(X11) here to deal with Wayland.

It's done in the header already, we usually try to avoid #ifdefs around header includes, by adding the ifdefs in the headers, in this case, the header was already protected.
Comment 5 Carlos Garcia Campos 2014-10-28 08:44:02 PDT
Created attachment 240541 [details]
Updated patch explaining all the cleanups in the changelog
Comment 6 Carlos Garcia Campos 2014-10-28 08:44:40 PDT
Created attachment 240542 [details]
Cleanup diffs to make it easier to review
Comment 7 WebKit Commit Bot 2014-10-28 08:45:59 PDT
Attachment 240541 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:434:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Martin Robinson 2014-10-29 18:39:47 PDT
Comment on attachment 240542 [details]
Cleanup diffs to make it easier to review

View in context: https://bugs.webkit.org/attachment.cgi?id=240542&action=review

I like the reorganization overall and think it's an improvement, but there are some issues I have with the new design.

> Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:143
> -    Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
> +    ASSERT(supportsXDamageAndXComposite(display));

I think it's a bug to put this into an ASSERT. This means that this check is only run for debug builds and will crash when run on an XServer that does not support these extensions. Instead we should fail gracefully in this case.

> Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:223
>      if (!m_needsNewPixmapAfterResize && m_surface)
> -        return m_surface.get();
> +        return;

One issue here is that you can no longer detect a failure to create the surface after a resize. I think that the old design handled this case better and this can now hide subtle failures.

> Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:267
> +void RedirectedXCompositeWindow::draw(cairo_t* cr)
>  {
> -    if (m_damageNotifyCallback)
> -        m_damageNotifyCallback(m_damageNotifyData);
> +    prepareSurfaceForDrawing();
> +    if (!m_surface)
> +        return;
> +
> +    cairo_set_source_surface(cr, m_surface.get(), 0, 0);
> +    cairo_fill(cr);
>  }

It's a bit odd to move the drawing operation here, and I greatly preferred it exterior to the class. Let the user of the interface decide how to use the surface.
Comment 9 Carlos Garcia Campos 2014-10-30 00:26:02 PDT
Comment on attachment 240542 [details]
Cleanup diffs to make it easier to review

View in context: https://bugs.webkit.org/attachment.cgi?id=240542&action=review

>> Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:143
>> +    ASSERT(supportsXDamageAndXComposite(display));
> 
> I think it's a bug to put this into an ASSERT. This means that this check is only run for debug builds and will crash when run on an XServer that does not support these extensions. Instead we should fail gracefully in this case.

No, it's not. The thing is that previously we had the constructor private, and you could only create the object using the create factory method. Now we are removing the factory methods in WebKit in favor of using std::make_unqiue, but in this particular case, the factory method is required, because it calls supportsXDamageAndXComposite() to return NULL in case xserver doesn't support the required extensions. I still moved to use std::unique_ptr and std::make_unique, but keeping the factory method to check the xserver extensions. But std::make_unique requires the constructor to be public, so this assert is a way to make sure that the caller has used the factory method to create the object. I can remove the ASSERT here, and make the constructor private again, by not using make_unique and returning a std::unique_ptr<RedirectedXCompositeWindow>(new RedirectedXCompositeWindow()); directly.

>> Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:267
>>  }
> 
> It's a bit odd to move the drawing operation here, and I greatly preferred it exterior to the class. Let the user of the interface decide how to use the surface.

Ok. I made this to simplify the caller code, but it's also true that it may only fit in the current caller code.
Comment 10 Carlos Garcia Campos 2014-10-30 04:07:20 PDT
(In reply to comment #8)
> Comment on attachment 240542 [details]
> Cleanup diffs to make it easier to review
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=240542&action=review
> 
> I like the reorganization overall and think it's an improvement, but there
> are some issues I have with the new design.
> 
> > Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:143
> > -    Display* display = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
> > +    ASSERT(supportsXDamageAndXComposite(display));
> 
> I think it's a bug to put this into an ASSERT. This means that this check is
> only run for debug builds and will crash when run on an XServer that does
> not support these extensions. Instead we should fail gracefully in this case.
> 
> > Source/WebKit2/UIProcess/gtk/RedirectedXCompositeWindow.cpp:223
> >      if (!m_needsNewPixmapAfterResize && m_surface)
> > -        return m_surface.get();
> > +        return;
> 
> One issue here is that you can no longer detect a failure to create the
> surface after a resize. I think that the old design handled this case better
> and this can now hide subtle failures.

Note that current code, doesn't event check the returned value is not NULL before using it :-)
Comment 11 Carlos Garcia Campos 2014-10-30 04:13:33 PDT
Created attachment 240665 [details]
Updated patch according to review comments

Changes:

  - Removed the confusing ASSERT in the constructor by leaving the constructor private to ensure the object can only be created by the factory method that already checks if xserver extensions are supported.
  - Moved the draw code back to the web view.
  - Renamed prepareSurfaceForDrawing as just surface() that returns the surface and made it public again.
Comment 12 WebKit Commit Bot 2014-10-30 04:16:08 PDT
Attachment 240665 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp:434:  More than one command on the same line  [whitespace/newline] [4]
Total errors found: 1 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Carlos Garcia Campos 2014-11-12 04:13:23 PST
Committed r176016: <http://trac.webkit.org/changeset/176016>