<?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>219456</bug_id>
          
          <creation_ts>2020-12-02 14:11:22 -0800</creation_ts>
          <short_desc>[Flatpak][GTK][X11] WebProcess assertion failure with Nvidia drivers</short_desc>
          <delta_ts>2021-09-29 03:55:45 -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>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=199666</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=217323</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="Sam Sneddon [:gsnedders]">gsnedders</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>clopez</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>pnormand</cc>
    
    <cc>twilco.o</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1711462</commentid>
    <comment_count>0</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2020-12-02 14:11:22 -0800</bug_when>
    <thetext>libEGL warning: DRI2: failed to authenticate
ASSERTION FAILED: windowConfig
../../Source/WebCore/platform/graphics/glx/GLContextGLX.cpp(150) : static std::unique_ptr&lt;WebCore::GLContextGLX&gt; WebCore::GLContextGLX::createWindowContext(GLNativeWindowType, WebCore::PlatformDisplay&amp;, GLXContext)
1   0x7fffdce3315b WTFCrash
2   0x7fffeb93e517 /app/webkit/WebKitBuild/Debug/lib/libwebkit2gtk-4.0.so.37(+0xcf86517) [0x7fffeb93e517]
3   0x7fffef7bec8a WebCore::GLContextGLX::createWindowContext(unsigned long, WebCore::PlatformDisplay&amp;, __GLXcontextRec*)
4   0x7fffef7bf614 WebCore::GLContextGLX::createContext(unsigned long, WebCore::PlatformDisplay&amp;)
5   0x7fffef74753f WebCore::GLContext::createContextForWindow(unsigned long, WebCore::PlatformDisplay*)
6   0x7fffec47beba WebKit::ThreadedCompositor::createGLContext()
...


I&apos;m surprised it has no idea about symbols in libwebkit2gtk-4.0.so.37, and I can&apos;t manage to get the crash happening within gdb.

It&apos;s easy enough to trigger (https://webkit.org triggers it, but not about:blank or https://example.com/).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711467</commentid>
    <comment_count>1</comment_count>
    <who name="Sam Sneddon [:gsnedders]">gsnedders</who>
    <bug_when>2020-12-02 14:31:22 -0800</bug_when>
    <thetext>And then just after I give up I try using gdbserver again and hey now I have it in a debugger:

In WebCore::GLContextGLX::createWindowContext there, glXGetFBConfigs returns no (zero) configs, hence why windowConfig remains nullptr.

I wonder if this is something odd with how things are running within flatpak and then talking to the wider system? `Reading /usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0 from remote target...` got logged by gdb just before it all kicked off.

I&apos;ll be around more here/Slack during the European work day tomorrow if any of the European Igalians want to help!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711485</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2020-12-02 15:26:54 -0800</bug_when>
    <thetext>Nvidia proprietary drivers are problematic.

I have an nvidia card and I ended up using the free drivers (Nouveau) due to the continuous issues I was having with WebKit and other software.

You can workaround this issue by exporting the environment variable WEBKIT_DISABLE_COMPOSITING_MODE=1 and that will disable AC mode in WebKit.

I wonder if your issues is with flatpak or with webkitgtk itself. 

Does the issue happen if you build WebKit without flatpak? (for that simply wipe the WebKitBuild directory and start a new build without calling the update-webkitgtk-libs script before the build. You may need to pass the flag &apos;--no-experimental-features&apos; to build-webkit to disable some features that perhaps don&apos;t build on your distro)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711534</commentid>
    <comment_count>3</comment_count>
    <who name="Tyler Wilcock">twilco.o</who>
    <bug_when>2020-12-02 17:12:57 -0800</bug_when>
    <thetext>I just tested it -- it does seem to be the combination of the Nvidia proprietary drivers and Flatpak.

```
rm -rf WebKitBuild
update-webkitgtk-libs --debug
Tools/Scripts/build-webkit --gtk --debug --no-experimental-features --cmakeargs=&quot;-DUSE_WPE_RENDERER=OFF -DENABLE_GAMEPAD=OFF&quot;
run-minibrowser --gtk --debug https://www.webkit.org
```

Reproduces the crash, while:

```
rm -rf WebKitBuild
Tools/Scripts/build-webkit --gtk --debug --no-experimental-features --cmakeargs=&quot;-DUSE_WPE_RENDERER=OFF -DENABLE_GAMEPAD=OFF&quot;
run-minibrowser --gtk --debug https://www.webkit.org
```

does not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711551</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2020-12-02 18:16:10 -0800</bug_when>
    <thetext>Perhaps it works if you install the nvidia drivers inside the flatpak runtime of WebKit.

Try this:

1. Check what flatpak runtimes you have intalled in the WebKit directory. It should print something like this.

$ FLATPAK_USER_DIR=/home/igalia/clopez/webkit/WebKitBuild/UserFlatpak flatpak --user list
Name                                             Application ID                                       Version            Branch           Origin
Rust stable Sdk extension                        org.freedesktop.Sdk.Extension.rust-stable            1.48.0             20.08            flathub
WebKit Platform (0.3)                            org.webkit.Platform                                  r270199            0.3              webkit-sdk
WebKit Software Development Kit (0.3)            org.webkit.Sdk                                       r270199            0.3              webkit-sdk

2. Get the nvidia version that matches more closely what you host has.

$ FLATPAK_USER_DIR=/home/igalia/clopez/webkit/WebKitBuild/UserFlatpak flatpak remote-ls|grep nvidia

3. Install it

$ FLATPAK_USER_DIR=/home/igalia/clopez/webkit/WebKitBuild/UserFlatpak flatpak --user install org.freedesktop.Platform.GL.nvidia-455-38
Looking for matches…
Found similar ref(s) for ‘org.freedesktop.Platform.GL.nvidia-455-38’ in remote ‘flathub’ (user).
Use this remote? [Y/n]: y


        ID                                                    Branch            Op            Remote             Download
 1. [✓] org.freedesktop.Platform.GL.nvidia-455-38             1.4               i             flathub            356.3 kB / 127.0 MB

Installation complete.


4. Check that is installed, the command from point 1 now should return:


$ FLATPAK_USER_DIR=/home/igalia/clopez/webkit/WebKitBuild/UserFlatpak flatpak --user list
Name                                             Application ID                                       Version            Branch           Origin
nvidia-455-38                                    org.freedesktop.Platform.GL.nvidia-455-38                               1.4              flathub
Rust stable Sdk extension                        org.freedesktop.Sdk.Extension.rust-stable            1.48.0             20.08            flathub
WebKit Platform (0.3)                            org.webkit.Platform                                  r270199            0.3              webkit-sdk
WebKit Software Development Kit (0.3)            org.webkit.Sdk                                       r270199            0.3              webkit-sdk



5. Finally try to run webkit now to see if there is better luck


(of course, change the path on the environment variable FLATPAK_USER_DIR on all the commands above to point to your $webkit/WebKitBuild/UserFlatpak directory)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711552</commentid>
    <comment_count>5</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2020-12-02 18:28:38 -0800</bug_when>
    <thetext>BTW, i&apos;m not sure if the above is going to work.. i have not tested it since I don&apos;t use the nvidia propietary drivers. But when entering into a shell with &quot;Tools/Scripts/webkit-flatpak -c bash&quot; I can&apos;t see the nvidia drivers anywhere mounted inside the runtime.

Perhaps the WebKit SDK runtime needs to declare a dependency on the nvidia extensions and mount it somewhere like we do for other extensions on Tools/buildstream/elements/flatpak/sdk.bst

Here is some info on how this is supposed to work https://lists.freedesktop.org/archives/flatpak/2017-February/000534.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711562</commentid>
    <comment_count>6</comment_count>
    <who name="Tyler Wilcock">twilco.o</who>
    <bug_when>2020-12-02 19:11:06 -0800</bug_when>
    <thetext>OK, well in any case I&apos;ll try it now and report back.

---

FWIW, I started debugging through and here is what I&apos;ve found so far:

Starting from this line of the stacktrace:

4   0x7fffef7bf614 WebCore::GLContextGLX::createContext(unsigned long, WebCore::PlatformDisplay&amp;)

GLContextGLX::createContext calls into PlatformDisplay::sharingGLContext

https://github.com/WebKit/webkit/blob/817c46e152af795d735678386db68805d0aa505e/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp#L279

https://github.com/WebKit/webkit/blob/817c46e152af795d735678386db68805d0aa505e/Source/WebCore/platform/graphics/PlatformDisplay.cpp#L179

Which then calls into GLContext::createSharingContext:

https://github.com/WebKit/webkit/blob/817c46e152af795d735678386db68805d0aa505e/Source/WebCore/platform/graphics/GLContext.cpp#L115

The highlighted line fails to create a glxContent (`auto glxContext =  GLContextGLX::createSharingContext(display)`).  Need to do more digging as to why this fails...I briefly stepped through, but not enough to understand.

Execution then continues into this portion of the function:

#if USE(EGL) || PLATFORM(WAYLAND) || PLATFORM(WPE)
    if (auto eglContext = GLContextEGL::createSharingContext(display))
        return eglContext;
#endif

which is where the `libEGL warning: DRI2: failed to authenticate` log is spawned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711578</commentid>
    <comment_count>7</comment_count>
    <who name="Tyler Wilcock">twilco.o</who>
    <bug_when>2020-12-02 19:42:57 -0800</bug_when>
    <thetext>Hmm, that was a good idea, but it didn&apos;t seem to work.  Installing the recommended driver for my hardware, org.freedesktop.Platform.GL.nvidia-450-80-02, and re-running the Minibrowser via Flatpak results in the same crash.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711671</commentid>
    <comment_count>8</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-12-03 07:51:26 -0800</bug_when>
    <thetext>(In reply to Tyler Wilcock from comment #7)
&gt; Hmm, that was a good idea, but it didn&apos;t seem to work.  Installing the
&gt; recommended driver for my hardware,
&gt; org.freedesktop.Platform.GL.nvidia-450-80-02, and re-running the Minibrowser
&gt; via Flatpak results in the same crash.

Can you check if the nvidia extension was mounted correctly in the sandbox?

webkit-flatpak -c cat /.flatpak-info

It should be listed somewhere in that file.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711673</commentid>
    <comment_count>9</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-12-03 07:54:48 -0800</bug_when>
    <thetext>If the nvidia extension is not listed in `runtime-extensions` then it&apos;s not been mounted in the sandbox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711677</commentid>
    <comment_count>10</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2020-12-03 08:13:01 -0800</bug_when>
    <thetext>(In reply to Philippe Normand from comment #9)
&gt; If the nvidia extension is not listed in `runtime-extensions` then it&apos;s not
&gt; been mounted in the sandbox.

how can you tell flatpak to mount it? is it needed to rebuild the webkit-sdk runtime?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711678</commentid>
    <comment_count>11</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-12-03 08:30:54 -0800</bug_when>
    <thetext>(In reply to Carlos Alberto Lopez Perez from comment #10)
&gt; (In reply to Philippe Normand from comment #9)
&gt; &gt; If the nvidia extension is not listed in `runtime-extensions` then it&apos;s not
&gt; &gt; been mounted in the sandbox.
&gt; 
&gt; how can you tell flatpak to mount it? is it needed to rebuild the webkit-sdk
&gt; runtime?

Yeah, undo the change I did in Tools/buildstream/elements/flatpak/sdk.bst in https://bugs.webkit.org/show_bug.cgi?id=215763</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711680</commentid>
    <comment_count>12</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-12-03 08:34:42 -0800</bug_when>
    <thetext>The problem is that by bringing Mesa in our SDK, I had to get rid of the FDO GL extension which is able to enable the Nvidia extension too... So this won&apos;t be easy to revert...

We&apos;d need to find a way to enable the nvidia extension without bringing back the dependency on the GL extension.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711685</commentid>
    <comment_count>13</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2020-12-03 08:50:15 -0800</bug_when>
    <thetext>(In reply to Philippe Normand from comment #12)
&gt; The problem is that by bringing Mesa in our SDK, I had to get rid of the FDO
&gt; GL extension which is able to enable the Nvidia extension too... So this
&gt; won&apos;t be easy to revert...
&gt; 
&gt; We&apos;d need to find a way to enable the nvidia extension without bringing back
&gt; the dependency on the GL extension.

Maybe we can have that mesa version installed in a special path like /lib/softGL and before starting the tests add that path to LD_LIBRARY_PATH and LIBGL_DRIVERS_PATH. So we only use the mesa we build for layout tests when is passed &apos;--display-server=xvfb&apos; (the default) or &apos;--display-server=weston&apos;. We did (do?) something like this for JHBuild.

But when running the MiniBrowser or tests with &apos;--display-server=wayland&apos; or &apos;--display-server=xorg&apos; then use the host GL (FDO GL extensions)

WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711686</commentid>
    <comment_count>14</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-12-03 08:56:43 -0800</bug_when>
    <thetext>That won&apos;t work... We can&apos;t assume libs from the host will be usable in the sandbox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1711687</commentid>
    <comment_count>15</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2020-12-03 08:58:41 -0800</bug_when>
    <thetext>Ah sorry I misread your comment... Yeah maybe it could work...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1798243</commentid>
    <comment_count>16</comment_count>
    <who name="Philippe Normand">pnormand</who>
    <bug_when>2021-09-29 03:55:45 -0700</bug_when>
    <thetext>This fixed by the SDK update to version 21.08.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>