Skip to content

Error running Linux AppImage containing Webkit #1029

@freakboy3742

Description

@freakboy3742

Describe the bug

If you package a GTK app that references Webkit, the app will build, but will fail at runtime.

Steps to reproduce

  1. Obtain a copy of Toga Tutorial 3
  2. Add the default Toga Appimage configuration to pyproject.toml:
[tool.briefcase.app.tutorial.linux.appimage]
system_requires = [
    'gir1.2-webkit-3.0',
    'libcairo2-dev',
    'libgirepository1.0-dev',
    'libgtk-3-dev',
    'libpango1.0-dev',
    'librsvg2-dev',
    'libwebkitgtk-3.0-0',
]
linuxdeploy_plugins = [
    'DEPLOY_GTK_VERSION=3 gtk',
]
  1. Package app as an AppImage
  2. Run AppImage on any platform other than Ubuntu 18.04
  3. See runtime error:
           ** (__main__.py:548313): WARNING **: 09:22:13.888: Failed to load shared library 'libwebkit2gtk-4.0.so.37' referenced by the typelib:                   subprocess.py:644
           /lib/x86_64-linux-gnu/libsecret-1.so.0: undefined symbol: g_task_set_name                                                                                                
           /tmp/.mount_Tutori7Nvvex/usr/app_packages/toga_gtk/widgets/webview.py:19: Warning: cannot retrieve class for invalid (unclassed) type 'void'            subprocess.py:644
             self.native = WebKit2.WebView()                                                                                                                       subprocess.py:644
           Traceback (most recent call last):                                                                                                                      subprocess.py:644
             File "/tmp/.mount_Tutori7Nvvex/usr/app_packages/toga_gtk/app.py", line 105, in gtk_startup                                                            subprocess.py:644
               self.interface.startup()                                                                                                                            subprocess.py:644
             File "/tmp/.mount_Tutori7Nvvex/usr/app/tutorial/app.py", line 9, in startup                                                                           subprocess.py:644
               self.webview = toga.WebView(                                                                                                                        subprocess.py:644
             File "/tmp/.mount_Tutori7Nvvex/usr/app_packages/toga/widgets/webview.py", line 51, in __init__                                                        subprocess.py:644
               self._impl = self.factory.WebView(interface=self)                                                                                                   subprocess.py:644
             File "/tmp/.mount_Tutori7Nvvex/usr/app_packages/toga_gtk/widgets/base.py", line 13, in __init__                                                       subprocess.py:644
               self.create()                                                                                                                                       subprocess.py:644
             File "/tmp/.mount_Tutori7Nvvex/usr/app_packages/toga_gtk/widgets/webview.py", line 19, in create                                                      subprocess.py:644
               self.native = WebKit2.WebView()                                                                                                                     subprocess.py:644
           TypeError: could not get a reference to type class                        

Expected behavior

App should run without error, displaying the "graze" webkit browser on GTK.

Screenshots

No response

Environment

  • Operating System: Ubuntu 22.04, Arch
  • Python version: 3.10
  • Software versions:
    • Briefcase: 0.3.10.dev207
    • Toga: 0.3.0.dev39

Logs

Briefcase build:
briefcase.2023_01_03-09_19_06.build.log

Briefcase run:
briefcase.2023_01_03-09_22_29.run.log

Additional context

The app runs fine under Ubuntu 18.04.

The problem appears to be that the webkit libraries aren't being included in the AppImage. The Docker container installs libwebkit-3.0; but at runtime, GTK attempts to load libwebkit2-4.0. There's no reference to any Webkit library in the AppImage build logs.

The use of libwebkit-3.0 appears to be a hangover from the days when Briefcase used an Ubuntu 16.04 base; Ubuntu 18.04 provides both libwebkit-3.0 and libwebkit2-4.0. However, modifying the system_requires to use libwebkit2-4.0 (and the corresponding gir package) doesn't fix the problem; it changes the error to a problem with libjavascriptcoregtk-4.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA crash or error in behavior.linuxThe issue relates Linux support.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions