Bug 165237

Summary: [GTK] The inspector is broken when AC support is disabled
Product: WebKit Reporter: Carlos Alberto Lopez Perez <clopez>
Component: WebKitGTKAssignee: Miguel Gomez <magomez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, bugs-noreply, cgarcia, commit-queue, esprehn+autocc, glenn, kondapallykalyan, magomez, mcatanzaro, mike, simon.fraser, thorton, tpopela, yoon, zan
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Description Carlos Alberto Lopez Perez 2016-11-30 18:02:03 PST
If WebKitGTK+ is built without OpenGL support, or it is started with this support disabled via the environment variable WEBKIT_DISABLE_COMPOSITING_MODE, then the inspector window is broken.

Doing right click, inspect element will show a black or empty window and will end crashing the webprocess.
Comment 1 Michael Gratton 2017-01-19 16:01:20 PST
*** Bug 167218 has been marked as a duplicate of this bug. ***
Comment 2 Michael Gratton 2017-01-19 16:02:33 PST
Per the duplicate, this is making debugging CSS and JS issues in the WK2 port of Geary somewhat difficult.
Comment 3 Carlos Garcia Campos 2017-01-20 08:42:10 PST
This is not specific to GTK+, but I guess it doesn't happen in other ports based on coordinated graphics because they don't allow to disable accelerated compositing. The problem is that PageOverlay depends on accelerated compositing and assumes it's always available. We get also crashes if accelerated compositing is not forced when the roo layer is detached, because the page overlay controller keep its graphics layer alive. In coordinated graphics the layers have a coordinator associated, when the coordinator is destroyed, it expects all the layers to be also destroyed, but that's not true for the page olverlays. So, I think we should do two things here:

 1. Do not use page overlays when accelerated compositing is disabled. The same way RenderLayercompositor doesn't create any GraphicsLayer when AC is disabled. Features depending on page overlays will not work of course, but that's better than crashing. I think the GTK+ port only uses page overlays for the inspector highlights, so not a big deal.

 2. When RenderLayerCompositor detaches the root layer, and we leave accelerated compositor mode, the page overlays should be destroyed to ensure we don't leave any GraphicsLayer pointing to a deleted coordindator.
Comment 4 Michael Catanzaro 2017-01-20 09:14:10 PST
(Also: Geary should really seriously consider disabling JS if at all possible, like Evolution does.)
Comment 5 Miguel Gomez 2017-01-24 08:40:02 PST
Created attachment 299601 [details]
Patch
Comment 6 Carlos Garcia Campos 2017-01-24 23:23:02 PST
Comment on attachment 299601 [details]
Patch

Thanks for the patch! This looks good to me, r=me but I would like someone more familiarized with the page overlays and compositor code confirms this is ok, so also setting cq-.
Comment 7 Tim Horton 2017-01-24 23:32:47 PST
Comment on attachment 299601 [details]
Patch

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

> Source/WebCore/rendering/RenderLayerCompositor.cpp:773
>  void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<GraphicsLayer*>& childList)

Is this sufficient? What about view-relative overlays? Maybe they get installed in a different way, I don't really remember.

> Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp:110
> +    if (!m_page->corePage()->settings().acceleratedCompositingEnabled())
> +        return;

These are just a few of the many places PageOverlays are used; should we perhaps instead proceed with the installation and just not install layers? (And then if a root layer is attached they'll just start working?)
Comment 8 Carlos Garcia Campos 2017-01-24 23:39:58 PST
(In reply to comment #7)
> Comment on attachment 299601 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299601&action=review
> 
> > Source/WebCore/rendering/RenderLayerCompositor.cpp:773
> >  void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<GraphicsLayer*>& childList)
> 
> Is this sufficient? What about view-relative overlays? Maybe they get
> installed in a different way, I don't really remember.

I think this is enough for GTK+ port, I think we only use overlays for the inspector. But this is not really a GTK+ specific issue, it just happens that GTK+ port is probably the only one that still allows to disable AC.
Comment 9 Tim Horton 2017-01-24 23:42:39 PST
(In reply to comment #8)
> (In reply to comment #7)
> > Comment on attachment 299601 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=299601&action=review
> > 
> > > Source/WebCore/rendering/RenderLayerCompositor.cpp:773
> > >  void RenderLayerCompositor::appendDocumentOverlayLayers(Vector<GraphicsLayer*>& childList)
> > 
> > Is this sufficient? What about view-relative overlays? Maybe they get
> > installed in a different way, I don't really remember.
> 
> I think this is enough for GTK+ port, I think we only use overlays for the
> inspector. But this is not really a GTK+ specific issue, it just happens
> that GTK+ port is probably the only one that still allows to disable AC.

Right, what I should have said was "this seems like a somewhat haphazard way to fix this, maybe instead of checking this bit at the callsites we should check it at the bottleneck inside PageOverlayController instead, so that we never get it wrong in the future and don't have settings checks scattered in random places"
Comment 10 Miguel Gomez 2017-01-25 00:42:20 PST
> Right, what I should have said was "this seems like a somewhat haphazard way
> to fix this, maybe instead of checking this bit at the callsites we should
> check it at the bottleneck inside PageOverlayController instead, so that we
> never get it wrong in the future and don't have settings checks scattered in
> random places"

Even moving the check to PageOverlayController, which would be an option as you mention, we want to avoid the creation of GraphicsLayers in the caller as well. This is needed in GTK+ because requesting the GraphicsLayerFactory causes AC mode to be enabled. So in any case the callers need to be modified as well. Or am I missing something?
Comment 11 Tim Horton 2017-01-25 00:44:40 PST
(In reply to comment #10)
> > Right, what I should have said was "this seems like a somewhat haphazard way
> > to fix this, maybe instead of checking this bit at the callsites we should
> > check it at the bottleneck inside PageOverlayController instead, so that we
> > never get it wrong in the future and don't have settings checks scattered in
> > random places"
> 
> Even moving the check to PageOverlayController, which would be an option as
> you mention, we want to avoid the creation of GraphicsLayers in the caller
> as well. This is needed in GTK+ because requesting the GraphicsLayerFactory
> causes AC mode to be enabled. So in any case the callers need to be modified
> as well. Or am I missing something?

Ah, fair point, I didn't realize the inspector made sublayers, but it does. Carry on!
Comment 12 WebKit Commit Bot 2017-01-25 05:27:19 PST
Comment on attachment 299601 [details]
Patch

Clearing flags on attachment: 299601

Committed r211141: <http://trac.webkit.org/changeset/211141>
Comment 13 WebKit Commit Bot 2017-01-25 05:27:25 PST
All reviewed patches have been landed.  Closing bug.