<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>157605</bug_id>
          
          <creation_ts>2016-05-11 20:21:08 -0700</creation_ts>
          <short_desc>[GTK] Browser plugins crash under Wayland</short_desc>
          <delta_ts>2016-06-10 05:48:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Plug-ins</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugzilla.redhat.com/show_bug.cgi?id=1335352</see_also>
    
    <see_also>https://bugzilla.gnome.org/show_bug.cgi?id=766657</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1192194</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-05-11 20:21:08 -0700</bug_when>
    <thetext>The Evince browser plugin is crashing 100% when run under Wayland. See the downstream bug for a backtrace. (I can&apos;t paste it here like I usually do, because we haven&apos;t implemented paste yet. ;) Note that it goes through GtkPlug, which is sure to crash under Wayland.

Whatever code we have to disable windowed plugins in Wayland must not be working.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1195419</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-05-22 08:25:35 -0700</bug_when>
    <thetext>Truncated backtrace:

Thread 1 (Thread 0x7ffff7f0fac0 (LWP 15147)):
#0  0x00005555565b2cd0 in  ()
#1  0x00007ffff78bfbf3 in XGetWindowAttributes () at /lib64/libX11.so.6
#2  0x00007ffff233f894 in gtk_socket_realize () at /lib64/libgtk-3.so.0
#3  0x00007ffff0455617 in _g_closure_invoke_va () at /lib64/libgobject-2.0.so.0
#4  0x00007ffff046fea9 in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
#5  0x00007ffff04704ff in g_signal_emit () at /lib64/libgobject-2.0.so.0
#6  0x00007ffff2309a9e in gtk_widget_realize () at /lib64/libgtk-3.so.0
#7  0x00007ffff230d0d8 in gtk_widget_set_parent () at /lib64/libgtk-3.so.0
#8  0x00007ffff4be7d74 in webkitWebViewBaseContainerAdd(_GtkContainer*, _GtkWidget*) () at /lib64/libwebkit2gtk-4.0.so.37
#9  0x00007ffff0458470 in g_cclosure_marshal_VOID__OBJECTv () at /lib64/libgobject-2.0.so.0
#10 0x00007ffff0455617 in _g_closure_invoke_va () at /lib64/libgobject-2.0.so.0
#11 0x00007ffff046fea9 in g_signal_emit_valist () at /lib64/libgobject-2.0.so.0
#12 0x00007ffff04704ff in g_signal_emit () at /lib64/libgobject-2.0.so.0
#13 0x00007ffff20f5ff5 in gtk_container_add () at /lib64/libgtk-3.so.0
#14 0x00007ffff4c07f7c in WebKit::WebPageProxy::createPluginContainer(unsigned long&amp;) () at /lib64/libwebkit2gtk-4.0.so.37
#15 0x00007ffff4c37a54 in WebKit::WebPageProxy::didReceiveSyncMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;, std::unique_ptr&lt;IPC::MessageEncoder, std::default_delete&lt;IPC::MessageEncoder&gt; &gt;&amp;) ()
    at /lib64/libwebkit2gtk-4.0.so.37
#16 0x00007ffff49a9b91 in IPC::MessageReceiverMap::dispatchSyncMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;, std::unique_ptr&lt;IPC::MessageEncoder, std::default_delete&lt;IPC::MessageEncoder&gt; &gt;&amp;) ()
    at /lib64/libwebkit2gtk-4.0.so.37
#17 0x00007ffff4a5ac0b in WebKit::WebProcessProxy::didReceiveSyncMessage(IPC::Connection&amp;, IPC::MessageDecoder&amp;, std::unique_ptr&lt;IPC::MessageEncoder, std::default_delete&lt;IPC::MessageEncoder&gt; &gt;&amp;) ()
    at /lib64/libwebkit2gtk-4.0.so.37
#18 0x00007ffff49a5b3b in IPC::Connection::dispatchSyncMessage(IPC::MessageDecoder&amp;) () at /lib64/libwebkit2gtk-4.0.so.37
#19 0x00007ffff49a5c2d in IPC::Connection::dispatchMessage(std::unique_ptr&lt;IPC::MessageDecoder, std::default_delete&lt;IPC::MessageDecoder&gt; &gt;) () at /lib64/libwebkit2gtk-4.0.so.37
#20 0x00007ffff49a63e6 in IPC::Connection::dispatchOneMessage() () at /lib64/libwebkit2gtk-4.0.so.37
#21 0x00007ffff42de8bd in WTF::RunLoop::performWork() () at /lib64/libjavascriptcoregtk-4.0.so.18
#22 0x00007ffff4301da9 in WTF::RunLoop::RunLoop()::{lambda(void*)#1}::_FUN(void*) () at /lib64/libjavascriptcoregtk-4.0.so.18
#23 0x00007ffff0181703 in g_main_context_dispatch () at /lib64/libglib-2.0.so.0
#24 0x00007ffff0181ab0 in g_main_context_iterate.isra () at /lib64/libglib-2.0.so.0
#25 0x00007ffff0181b5c in g_main_context_iteration () at /lib64/libglib-2.0.so.0
#26 0x00007ffff074458d in g_application_run () at /lib64/libgio-2.0.so.0
#27 0x0000555555586954 in main ()

This backtrace is slightly different as it goes through GtkSocket rather than GtkPlug, but any rate WebKit should definitely not be using either when running under Wayland. See GNOME #766657 for a full backtrace.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1197008</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-05-27 01:22:29 -0700</bug_when>
    <thetext>createPluginContainer() starts in NetscapePluginX11::create() and that&apos;s called from NetscapePlugin::platformPostInitialize (in NetscapePluginUnix.cpp) which checks if PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11. So I don&apos;t understand why that&apos;s happening. Could you check if we are returning PlatformDisplay::Type::X11 there in Wayland?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200451</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-06-08 08:23:23 -0700</bug_when>
    <thetext>Hm, I guess we have two different plugin process crashes here. My backtrace (see the Red Hat bug) does not go through createPluginContainer at all.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200453</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-06-08 08:35:04 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; Hm, I guess we have two different plugin process crashes here. My backtrace
&gt; (see the Red Hat bug) does not go through createPluginContainer at all.

It doesn&apos;t matter the same applies to the geometry did change method that is specific to windowed plugins</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200553</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-06-08 13:10:49 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; createPluginContainer() starts in NetscapePluginX11::create() and that&apos;s
&gt; called from NetscapePlugin::platformPostInitialize (in
&gt; NetscapePluginUnix.cpp) which checks if
&gt; PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11. So I
&gt; don&apos;t understand why that&apos;s happening. Could you check if we are returning
&gt; PlatformDisplay::Type::X11 there in Wayland?

No, it&apos;s PlatformDisplay::Type::Wayland as expected. We never create the NetscapePluginX11 object.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200572</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-06-08 13:40:37 -0700</bug_when>
    <thetext>The plugin process is creating a GtkPlug before it crashes, but I don&apos;t think it&apos;s being created anywhere inside WebKit. Yes, I know that doesn&apos;t make sense, but our only use of gtk_plug_new is in NetscapePluginX11.cpp in the constructor, and I&apos;ve added WTFLogAlways and ASSERT_NOT_REACHED at the top of the constructor and it&apos;s definitely not being called. I even checked to make sure we&apos;re not passing GTK_TYPE_PLUG directly to g_object_new anywhere.

Anyway, PluginProxy::geometryDidChange and then NetscapePlugin::geometryDidChange are both being called before the crash. It&apos;s not so unexpected because this is the evince browser plugin, it&apos;s a windowed plugin; the code to stop us from creating a windowed plugin under Wayland must not be working.

Related: it&apos;s quite frustrating that we have the NetscapePlugin class under the WebProcess directory when it&apos;s also used by the plugin process; makes everything needlessly confusing. ;/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200758</commentid>
    <comment_count>7</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-06-09 00:35:49 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; The plugin process is creating a GtkPlug before it crashes, but I don&apos;t
&gt; think it&apos;s being created anywhere inside WebKit. Yes, I know that doesn&apos;t
&gt; make sense, but our only use of gtk_plug_new is in NetscapePluginX11.cpp in
&gt; the constructor, and I&apos;ve added WTFLogAlways and ASSERT_NOT_REACHED at the
&gt; top of the constructor and it&apos;s definitely not being called. I even checked
&gt; to make sure we&apos;re not passing GTK_TYPE_PLUG directly to g_object_new
&gt; anywhere.
&gt; 
&gt; Anyway, PluginProxy::geometryDidChange and then
&gt; NetscapePlugin::geometryDidChange are both being called before the crash.
&gt; It&apos;s not so unexpected because this is the evince browser plugin, it&apos;s a
&gt; windowed plugin; the code to stop us from creating a windowed plugin under
&gt; Wayland must not be working.
&gt; 
&gt; Related: it&apos;s quite frustrating that we have the NetscapePlugin class under
&gt; the WebProcess directory when it&apos;s also used by the plugin process; makes
&gt; everything needlessly confusing. ;/

Ah, it must be EvBrowserPlugin::setWindow() the one creating the plug. That shouldn&apos;t be called when we don&apos;t have an X11 implementation, but we can probably just fail the initialization when we don&apos;t have a platform implementation and the plugin is windowed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200759</commentid>
    <comment_count>8</comment_count>
      <attachid>280894</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-06-09 00:36:19 -0700</bug_when>
    <thetext>Created attachment 280894
Patch

Could you try this patch, please?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1200832</commentid>
    <comment_count>9</comment_count>
      <attachid>280894</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2016-06-09 07:55:10 -0700</bug_when>
    <thetext>Comment on attachment 280894
Patch

This fixes the crash and I even understand the code change, r+.

However, it is still impossible to view PDFs unless I uninstall the browser plugin, which is very bad. I see a black surface instead of the PDF. With the plugin uninstalled, Epiphany instead downloads the PDFs. This could be treated as a separate bug, though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1201219</commentid>
    <comment_count>10</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2016-06-10 05:48:52 -0700</bug_when>
    <thetext>Committed r201921: &lt;http://trac.webkit.org/changeset/201921&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>280894</attachid>
            <date>2016-06-09 00:36:19 -0700</date>
            <delta_ts>2016-06-09 07:55:10 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>wk2-wayland-windowed-plugins.diff</filename>
            <type>text/plain</type>
            <size>1668</size>
            <attacher name="Carlos Garcia Campos">cgarcia</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQyL0No
YW5nZUxvZwppbmRleCBlNmE2NjY5Li42MzU5MTlhIDEwMDY0N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VnaW5Vbml4LmNwcAppbmRleCBiMzk2YjBi
My4uOGI4ZWFhMCAxMDA2NDQKLS0tIGEvU291cmNlL1dlYktpdDIvV2ViUHJvY2Vzcy9QbHVnaW5z
L05ldHNjYXBlL3VuaXgvTmV0c2NhcGVQbHVnaW5Vbml4LmNwcAorKysgYi9Tb3VyY2UvV2ViS2l0
Mi9XZWJQcm9jZXNzL1BsdWdpbnMvTmV0c2NhcGUvdW5peC9OZXRzY2FwZVBsdWdpblVuaXguY3Bw
CkBAIC01MSwxMyArNTEsMTQgQEAgYm9vbCBOZXRzY2FwZVBsdWdpbjo6cGxhdGZvcm1Qb3N0SW5p
dGlhbGl6ZSgpCiAgICAgfQogI2VuZGlmCiAKLSAgICBpZiAobV9pbXBsKSB7Ci0gICAgICAgIG1f
bnBXaW5kb3cudHlwZSA9IG1faW1wbC0+d2luZG93VHlwZSgpOwotICAgICAgICBtX25wV2luZG93
LndpbmRvdyA9IG1faW1wbC0+d2luZG93KCk7Ci0gICAgICAgIG1fbnBXaW5kb3cud3NfaW5mbyA9
IG1faW1wbC0+d2luZG93U3lzdGVtSW5mbygpOwotICAgICAgICBjYWxsU2V0V2luZG93KCk7Ci0g
ICAgfQorICAgIC8vIFdpbmRvd2VkIHBsdWdpbnMgbmVlZCBhIHBsYXRmb3JtIGltcGxlbWVudGF0
aW9uLgorICAgIGlmICghbV9pbXBsKQorICAgICAgICByZXR1cm4gIW1faXNXaW5kb3dlZDsKIAor
ICAgIG1fbnBXaW5kb3cudHlwZSA9IG1faW1wbC0+d2luZG93VHlwZSgpOworICAgIG1fbnBXaW5k
b3cud2luZG93ID0gbV9pbXBsLT53aW5kb3coKTsKKyAgICBtX25wV2luZG93LndzX2luZm8gPSBt
X2ltcGwtPndpbmRvd1N5c3RlbUluZm8oKTsKKyAgICBjYWxsU2V0V2luZG93KCk7CiAgICAgcmV0
dXJuIHRydWU7CiB9CiAK
</data>
<flag name="review"
          id="304766"
          type_id="1"
          status="+"
          setter="mcatanzaro"
    />
          </attachment>
      

    </bug>

</bugzilla>