prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  libGL error when starting latest version of mitmweb 8.1.1 on Debian 
  #### Problem Description
  I was using old version of mitmproxy 6.0.2 that I got installed from the debian unstable repository and it works just fine. then today I decided to download the latest version of mitmproxy 8.1.1 and I got the below errors immediately after I type in `./mitmweb`
  
  ```
  Web server listening at http://127.0.0.1:8081/
  Opening in existing browser session.
  Proxy server listening at *:8080
  libGL error: MESA-LOADER: failed to open crocus: /usr/lib/dri/crocus_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
  libGL error: failed to load driver: crocus
  libGL error: MESA-LOADER: failed to open crocus: /usr/lib/dri/crocus_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
  libGL error: failed to load driver: crocus
  libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
  libGL error: failed to load driver: swrast
  [5508:5508:0100/000000.622195:ERROR:angle_platform_impl.cc(43)] Display.cpp:992 (initialize): ANGLE Display::initialize error 12289: Could not create a backing OpenGL context.
  [5508:5508:0100/000000.622454:ERROR:gl_surface_egl.cc(831)] EGL Driver message (Critical) eglInitialize: Could not create a backing OpenGL context.
  [5508:5508:0100/000000.622599:ERROR:gl_surface_egl.cc(1353)] eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type
  [5508:5508:0100/000000.625277:ERROR:angle_platform_impl.cc(43)] Display.cpp:992 (initialize): ANGLE Display::initialize error 12289: Could not create a backing OpenGL context.
  [5508:5508:0100/000000.625508:ERROR:gl_surface_egl.cc(831)] EGL Driver message (Critical) eglInitialize: Could not create a backing OpenGL context.
  [5508:5508:0100/000000.625555:ERROR:gl_surface_egl.cc(1353)] eglInitialize OpenGLES failed with error EGL_NOT_INITIALIZED
  [5508:5508:0100/000000.625654:ERROR:gl_ozone_egl.cc(23)] GLSurfaceEGL::InitializeOneOff failed.
  ```
  And the URL at http://127.0.0.1:8081 loads just a blank page.
  
  Note that I checked, and I have `libgl1-mesa-dri` package already installed.
  
  #### Steps to reproduce the behavior:
  1. download latest version of mitmproxy 8.1.1
  2. open the terminal and type in `./mitmweb`
  
  #### System Information
  Paste the output of "./mitmproxy --version" 
  ```
  Mitmproxy: 8.1.1 binary
  Python:    3.10.5
  OpenSSL:   OpenSSL 3.0.3 3 May 2022
  Platform:  Linux-5.18.0-3-amd64-x86_64-with-glibc2.34
  ```
  
  I will include the output of mitmproxy of version 6.0.2 that I have installed on the same system as I noticed that Python and OpenSSL versions are different:
  ```
  Mitmproxy: 6.0.2
  Python:    3.10.6
  OpenSSL:   OpenSSL 3.0.5 5 Jul 2022
  Platform:  Linux-5.18.0-3-amd64-x86_64-with-glibc2.34
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mitmproxy/tools/web/webaddons.py`
  Content:
  ```
  1 import logging
  2 import webbrowser
  3 from collections.abc import Sequence
  4 
  5 from mitmproxy import ctx
  6 
  7 
  8 class WebAddon:
  9     def load(self, loader):
  10         loader.add_option("web_open_browser", bool, True, "Start a browser.")
  11         loader.add_option("web_debug", bool, False, "Enable mitmweb debugging.")
  12         loader.add_option("web_port", int, 8081, "Web UI port.")
  13         loader.add_option("web_host", str, "127.0.0.1", "Web UI host.")
  14         loader.add_option(
  15             "web_columns",
  16             Sequence[str],
  17             ["tls", "icon", "path", "method", "status", "size", "time"],
  18             "Columns to show in the flow list",
  19         )
  20 
  21     def running(self):
  22         if hasattr(ctx.options, "web_open_browser") and ctx.options.web_open_browser:
  23             web_url = f"http://{ctx.options.web_host}:{ctx.options.web_port}/"
  24             success = open_browser(web_url)
  25             if not success:
  26                 logging.info(
  27                     f"No web browser found. Please open a browser and point it to {web_url}",
  28                 )
  29 
  30 
  31 def open_browser(url: str) -> bool:
  32     """
  33     Open a URL in a browser window.
  34     In contrast to webbrowser.open, we limit the list of suitable browsers.
  35     This gracefully degrades to a no-op on headless servers, where webbrowser.open
  36     would otherwise open lynx.
  37 
  38     Returns:
  39         True, if a browser has been opened
  40         False, if no suitable browser has been found.
  41     """
  42     browsers = (
  43         "windows-default",
  44         "macosx",
  45         "wslview %s",
  46         "gio",
  47         "x-www-browser %s",
  48         "gnome-open %s",
  49         "xdg-open",
  50         "google-chrome",
  51         "chrome",
  52         "chromium",
  53         "chromium-browser",
  54         "firefox",
  55         "opera",
  56         "safari",
  57     )
  58     for browser in browsers:
  59         try:
  60             b = webbrowser.get(browser)
  61         except webbrowser.Error:
  62             pass
  63         else:
  64             if b.open(url):
  65                 return True
  66     return False
  67
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/mitmproxy/tools/web/webaddons.py b/mitmproxy/tools/web/webaddons.py
  --- a/mitmproxy/tools/web/webaddons.py
  +++ b/mitmproxy/tools/web/webaddons.py
  @@ -44,7 +44,7 @@
           "macosx",
           "wslview %s",
           "gio",
  -        "x-www-browser %s",
  +        "x-www-browser",
           "gnome-open %s",
           "xdg-open",
           "google-chrome",
  
verification_info: {"golden_diff": "diff --git a/mitmproxy/tools/web/webaddons.py b/mitmproxy/tools/web/webaddons.py\n--- a/mitmproxy/tools/web/webaddons.py\n+++ b/mitmproxy/tools/web/webaddons.py\n@@ -44,7 +44,7 @@\n         \"macosx\",\n         \"wslview %s\",\n         \"gio\",\n-        \"x-www-browser %s\",\n+        \"x-www-browser\",\n         \"gnome-open %s\",\n         \"xdg-open\",\n         \"google-chrome\",\n", "issue": "libGL error when starting latest version of mitmweb 8.1.1 on Debian \n#### Problem Description\r\nI was using old version of mitmproxy 6.0.2 that I got installed from the debian unstable repository and it works just fine. then today I decided to download the latest version of mitmproxy 8.1.1 and I got the below errors immediately after I type in `./mitmweb`\r\n\r\n```\r\nWeb server listening at http://127.0.0.1:8081/\r\nOpening in existing browser session.\r\nProxy server listening at *:8080\r\nlibGL error: MESA-LOADER: failed to open crocus: /usr/lib/dri/crocus_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)\r\nlibGL error: failed to load driver: crocus\r\nlibGL error: MESA-LOADER: failed to open crocus: /usr/lib/dri/crocus_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)\r\nlibGL error: failed to load driver: crocus\r\nlibGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:\\$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)\r\nlibGL error: failed to load driver: swrast\r\n[5508:5508:0100/000000.622195:ERROR:angle_platform_impl.cc(43)] Display.cpp:992 (initialize): ANGLE Display::initialize error 12289: Could not create a backing OpenGL context.\r\n[5508:5508:0100/000000.622454:ERROR:gl_surface_egl.cc(831)] EGL Driver message (Critical) eglInitialize: Could not create a backing OpenGL context.\r\n[5508:5508:0100/000000.622599:ERROR:gl_surface_egl.cc(1353)] eglInitialize OpenGL failed with error EGL_NOT_INITIALIZED, trying next display type\r\n[5508:5508:0100/000000.625277:ERROR:angle_platform_impl.cc(43)] Display.cpp:992 (initialize): ANGLE Display::initialize error 12289: Could not create a backing OpenGL context.\r\n[5508:5508:0100/000000.625508:ERROR:gl_surface_egl.cc(831)] EGL Driver message (Critical) eglInitialize: Could not create a backing OpenGL context.\r\n[5508:5508:0100/000000.625555:ERROR:gl_surface_egl.cc(1353)] eglInitialize OpenGLES failed with error EGL_NOT_INITIALIZED\r\n[5508:5508:0100/000000.625654:ERROR:gl_ozone_egl.cc(23)] GLSurfaceEGL::InitializeOneOff failed.\r\n```\r\nAnd the URL at http://127.0.0.1:8081 loads just a blank page.\r\n\r\nNote that I checked, and I have `libgl1-mesa-dri` package already installed.\r\n\r\n#### Steps to reproduce the behavior:\r\n1. download latest version of mitmproxy 8.1.1\r\n2. open the terminal and type in `./mitmweb`\r\n\r\n#### System Information\r\nPaste the output of \"./mitmproxy --version\" \r\n```\r\nMitmproxy: 8.1.1 binary\r\nPython:    3.10.5\r\nOpenSSL:   OpenSSL 3.0.3 3 May 2022\r\nPlatform:  Linux-5.18.0-3-amd64-x86_64-with-glibc2.34\r\n```\r\n\r\nI will include the output of mitmproxy of version 6.0.2 that I have installed on the same system as I noticed that Python and OpenSSL versions are different:\r\n```\r\nMitmproxy: 6.0.2\r\nPython:    3.10.6\r\nOpenSSL:   OpenSSL 3.0.5 5 Jul 2022\r\nPlatform:  Linux-5.18.0-3-amd64-x86_64-with-glibc2.34\r\n```\r\n\n", "before_files": [{"content": "import logging\nimport webbrowser\nfrom collections.abc import Sequence\n\nfrom mitmproxy import ctx\n\n\nclass WebAddon:\n    def load(self, loader):\n        loader.add_option(\"web_open_browser\", bool, True, \"Start a browser.\")\n        loader.add_option(\"web_debug\", bool, False, \"Enable mitmweb debugging.\")\n        loader.add_option(\"web_port\", int, 8081, \"Web UI port.\")\n        loader.add_option(\"web_host\", str, \"127.0.0.1\", \"Web UI host.\")\n        loader.add_option(\n            \"web_columns\",\n            Sequence[str],\n            [\"tls\", \"icon\", \"path\", \"method\", \"status\", \"size\", \"time\"],\n            \"Columns to show in the flow list\",\n        )\n\n    def running(self):\n        if hasattr(ctx.options, \"web_open_browser\") and ctx.options.web_open_browser:\n            web_url = f\"http://{ctx.options.web_host}:{ctx.options.web_port}/\"\n            success = open_browser(web_url)\n            if not success:\n                logging.info(\n                    f\"No web browser found. Please open a browser and point it to {web_url}\",\n                )\n\n\ndef open_browser(url: str) -> bool:\n    \"\"\"\n    Open a URL in a browser window.\n    In contrast to webbrowser.open, we limit the list of suitable browsers.\n    This gracefully degrades to a no-op on headless servers, where webbrowser.open\n    would otherwise open lynx.\n\n    Returns:\n        True, if a browser has been opened\n        False, if no suitable browser has been found.\n    \"\"\"\n    browsers = (\n        \"windows-default\",\n        \"macosx\",\n        \"wslview %s\",\n        \"gio\",\n        \"x-www-browser %s\",\n        \"gnome-open %s\",\n        \"xdg-open\",\n        \"google-chrome\",\n        \"chrome\",\n        \"chromium\",\n        \"chromium-browser\",\n        \"firefox\",\n        \"opera\",\n        \"safari\",\n    )\n    for browser in browsers:\n        try:\n            b = webbrowser.get(browser)\n        except webbrowser.Error:\n            pass\n        else:\n            if b.open(url):\n                return True\n    return False\n", "path": "mitmproxy/tools/web/webaddons.py"}], "after_files": [{"content": "import logging\nimport webbrowser\nfrom collections.abc import Sequence\n\nfrom mitmproxy import ctx\n\n\nclass WebAddon:\n    def load(self, loader):\n        loader.add_option(\"web_open_browser\", bool, True, \"Start a browser.\")\n        loader.add_option(\"web_debug\", bool, False, \"Enable mitmweb debugging.\")\n        loader.add_option(\"web_port\", int, 8081, \"Web UI port.\")\n        loader.add_option(\"web_host\", str, \"127.0.0.1\", \"Web UI host.\")\n        loader.add_option(\n            \"web_columns\",\n            Sequence[str],\n            [\"tls\", \"icon\", \"path\", \"method\", \"status\", \"size\", \"time\"],\n            \"Columns to show in the flow list\",\n        )\n\n    def running(self):\n        if hasattr(ctx.options, \"web_open_browser\") and ctx.options.web_open_browser:\n            web_url = f\"http://{ctx.options.web_host}:{ctx.options.web_port}/\"\n            success = open_browser(web_url)\n            if not success:\n                logging.info(\n                    f\"No web browser found. Please open a browser and point it to {web_url}\",\n                )\n\n\ndef open_browser(url: str) -> bool:\n    \"\"\"\n    Open a URL in a browser window.\n    In contrast to webbrowser.open, we limit the list of suitable browsers.\n    This gracefully degrades to a no-op on headless servers, where webbrowser.open\n    would otherwise open lynx.\n\n    Returns:\n        True, if a browser has been opened\n        False, if no suitable browser has been found.\n    \"\"\"\n    browsers = (\n        \"windows-default\",\n        \"macosx\",\n        \"wslview %s\",\n        \"gio\",\n        \"x-www-browser\",\n        \"gnome-open %s\",\n        \"xdg-open\",\n        \"google-chrome\",\n        \"chrome\",\n        \"chromium\",\n        \"chromium-browser\",\n        \"firefox\",\n        \"opera\",\n        \"safari\",\n    )\n    for browser in browsers:\n        try:\n            b = webbrowser.get(browser)\n        except webbrowser.Error:\n            pass\n        else:\n            if b.open(url):\n                return True\n    return False\n", "path": "mitmproxy/tools/web/webaddons.py"}]}