Opera not autoconnected to gnome-42-2204

Hey, We are trying to update opera packages (opera, opera-beta, opera-developer) to core22. From what I understand this should autoconnect to gnome-42-2204, but it doesn’t seem to work.

Latest edge opera-developer is based on core22. Could you help me figure out what am I missing here?

Here is snapcraft.yaml:

name: {{ filesystem_name }}
version: {{ major }}.{{ minor }}.{{ nightly }}.{{ patch }}
summary: Fast and secure web browser
description: |
  Opera is a fast, secure, and user-friendly web browser.
  It includes a built-in ad blocker, Video pop-out, and free VPN.
architectures:
- amd64
base: core22
confinement: strict
grade: stable
plugs:
  browser-sandbox:
    allow-sandbox: true
    interface: browser-support
  # We need to specify the chromium-ffmpeg interface slot for Opera. When a snap
  # version Opera cannot play H.264 videos while the debian version can,
  # consider update to the latest interface slot first. A slot version may also
  # be removed from chromium-ffmpeg. In this case, we can do
  # `snap revert chromium-ffmpeg` as a workaround.
  chromium-ffmpeg-111306:
    interface: content
    target: $SNAP
    default-provider: chromium-ffmpeg
apps:
  {{ filesystem_name }}:
    command: bin/{{ filesystem_name }}.launcher
    desktop: usr/share/applications/{{ filesystem_name }}.desktop
    environment:
      DISABLE_WAYLAND: 1
    extensions:
    - gnome
    slots:
    - dbus-daemon
    plugs:
    - audio-playback
    - avahi-observe
    - browser-sandbox
    - camera
    - cups-control
    - home
    - network
    - network-control
    - network-manager
    - password-manager-service
    - process-control
    - pulseaudio
    - removable-media
    - screen-inhibit-control
    - u2f-devices
    - unity7
    - upower-observe
parts:
  browser:
    plugin: dump
    source: data
    stage-packages:
    - libasound2
    - libatk-bridge2.0-0
    - libatk1.0-0
    - libatspi2.0-0
    - libcairo-gobject2
    - libcairo2
    - libcups2
    - libcurl4
    - libdatrie1
    - libepoxy0
    - libfontconfig1
    - libfreetype6
    - libgconf-2-4
    - libgl1-mesa-glx
    - libglu1-mesa
    - libgpm2
    - libgraphite2-3
    - libgtk-3-0
    - libharfbuzz0b
    - libnotify4
    - libnspr4
    - libnss3
    - libpango-1.0-0
    - libpangocairo-1.0-0
    - libpangoft2-1.0-0
    - libpixman-1-0
    - libpulse0
    - libsecret-1-0
    - libthai0
    - libwayland-client0
    - libwayland-cursor0
    - libwayland-egl1
    - libxcb-render0
    - libxcb-shm0
    - libxcomposite1
    - libxcursor1
    - libxi6
    - libxinerama1
    - libxkbcommon0
    - libxrandr2
    - libxrender1
    - libxss1
    - libxtst6
    override-build: |
      snapcraftctl build
      chmod 4755 $SNAPCRAFT_PART_INSTALL/{{ target_dir }}/{{ filesystem_name }}/opera_sandbox
slots:
  dbus-daemon:
    interface: dbus
    bus: session
    name: com.opera.{{ filesystem_name }}

Hi @gmiazga

If I’m right, gnome-42-2204 was granted global auto-connection (so you don’t need any special request for it), but you still needs to plug your snap via the content interface.

Why should I plug it when neither Brave nor Firefox had to do it?

Adding extensions: [gnome] should add all needed interface connections automatically and gnome should surely auto-connect…

You can check your automatically modified snapcraft.yaml with the snapcraft expand-extensions command, perhaps you can spot some discrepancies in the output…

Plug for gnome-42-2204 seems to be created in generated snapcraft.yaml:

version: 108.0.5054.58269
summary: Fast and secure web browser
description: 'Opera is a fast, secure, and user-friendly web browser.

    It includes a built-in ad blocker, Video pop-out, and free VPN.

    '
base: core22
confinement: strict
compression: lzo
grade: stable
plugs:
    browser-sandbox:
        allow-sandbox: true
        interface: browser-support
    chromium-ffmpeg-111306:
        interface: content
        target: $SNAP
        default-provider: chromium-ffmpeg
    desktop:
        mount-host-font-cache: false
    gtk-3-themes:
        interface: content
        target: $SNAP/data-dir/themes
        default-provider: gtk-common-themes
    icon-themes:
        interface: content
        target: $SNAP/data-dir/icons
        default-provider: gtk-common-themes
    sound-themes:
        interface: content
        target: $SNAP/data-dir/sounds
        default-provider: gtk-common-themes
    gnome-42-2204:
        interface: content
        target: $SNAP/gnome-platform
        default-provider: gnome-42-2204
apps:
    opera-developer:
        command: bin/opera-developer.launcher
        desktop: usr/share/applications/opera-developer.desktop
        environment:
            DISABLE_WAYLAND: 1
        slots:
        - dbus-daemon
        plugs:
        - desktop
        - desktop-legacy
        - gsettings
        - opengl
        - wayland
        - x11
        - audio-playback
        - avahi-observe
        - browser-sandbox
        - camera
        - cups-control
        - home
        - mount-observe
        - network
        - network-control
        - network-manager
        - password-manager-service
        - process-control
        - pulseaudio
        - removable-media
        - screen-inhibit-control
        - u2f-devices
        - unity7
        - upower-observe
        command-chain:
        - snap/command-chain/desktop-launch
parts:
    browser:
        plugin: dump
        source: data
        stage-packages:
        - libasound2
        - libatk-bridge2.0-0
        - libatk1.0-0
        - libatspi2.0-0
        - libcairo-gobject2
        - libcairo2
        - libcups2
        - libcurl4
        - libdatrie1
        - libepoxy0
        - libfontconfig1
        - libfreetype6
        - libgconf-2-4
        - libgl1-mesa-glx
        - libglu1-mesa
        - libgpm2
        - libgraphite2-3
        - libgtk-3-0
        - libharfbuzz0b
        - libnotify4
        - libnspr4
        - libnss3
        - libpango-1.0-0
        - libpangocairo-1.0-0
        - libpangoft2-1.0-0
        - libpixman-1-0
        - libpulse0
        - libsecret-1-0
        - libthai0
        - libwayland-client0
        - libwayland-cursor0
        - libwayland-egl1
        - libxcb-render0
        - libxcb-shm0
        - libxcomposite1
        - libxcursor1
        - libxi6
        - libxinerama1
        - libxkbcommon0
        - libxrandr2
        - libxrender1
        - libxss1
        - libxtst6
        override-build: 'craftctl default

            chmod 4755 $CRAFT_PART_INSTALL/usr/lib/x86_64-linux-gnu/opera-developer/opera_sandbox

            '
        build-environment:
        -   PATH: /snap/gnome-42-2204-sdk/current/usr/bin${PATH:+:$PATH}
        -   XDG_DATA_DIRS: $SNAPCRAFT_STAGE/usr/share:/snap/gnome-42-2204-sdk/current/usr/share:/usr/share${XDG_DATA_DIRS:+:$XDG_DATA_DIRS}
        -   LD_LIBRARY_PATH: /snap/gnome-42-2204-sdk/current/lib/$CRAFT_ARCH_TRIPLET:/snap/gnome-42-2204-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET:/snap/gnome-42-2204-sdk/current/usr/lib:/snap/gnome-42-2204-sdk/current/usr/lib/vala-current:/snap/gnome-42-2204-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET/pulseaudio${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
        -   PKG_CONFIG_PATH: /snap/gnome-42-2204-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET/pkgconfig:/snap/gnome-42-2204-sdk/current/usr/lib/pkgconfig:/snap/gnome-42-2204-sdk/current/usr/share/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}
        -   GETTEXTDATADIRS: /snap/gnome-42-2204-sdk/current/usr/share/gettext-current${GETTEXTDATADIRS:+:$GETTEXTDATADIRS}
        -   GDK_PIXBUF_MODULE_FILE: /snap/gnome-42-2204-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET/gdk-pixbuf-current/loaders.cache
        -   ACLOCAL_PATH: /snap/gnome-42-2204-sdk/current/usr/share/aclocal${ACLOCAL_PATH:+:$ACLOCAL_PATH}
        -   PYTHONPATH: /snap/gnome-42-2204-sdk/current/usr/lib/python3.10:/snap/gnome-42-2204-sdk/current/usr/lib/python3/dist-packages:/snap/gnome-42-2204-sdk/current/usr/lib/$CRAFT_ARCH_TRIPLET/gobject-introspection${PYTHONPATH:+:$PYTHONPATH}
    gnome/sdk:
        source: /snap/snapcraft/10279/share/snapcraft/extensions/desktop/command-chain
        plugin: make
        build-snaps:
        - gnome-42-2204-sdk
slots:
    dbus-daemon:
        interface: dbus
        bus: session
        name: com.opera.opera-developer
assumes:
- snapd2.43
environment:
    SNAP_DESKTOP_RUNTIME: $SNAP/gnome-platform
    GTK_USE_PORTAL: '1'
hooks:
    configure:
        plugs:
        - desktop
        command-chain:
        - snap/command-chain/hooks-configure-fonts
layout:
    /usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0:
        bind: $SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0
    /usr/share/xml/iso-codes:
        bind: $SNAP/gnome-platform/usr/share/xml/iso-codes
    /usr/share/libdrm:
        bind: $SNAP/gnome-platform/usr/share/libdrm

You might need to clean up your stage packages, many (if not all) are shipped in the gnome snap and will be used from there, though this should still not prevent the autoconnect…

I’ve removed all staged packages but still it isn’t autoconnected.

Can you provide the output of snap info gnome-42-2204 - we’re hoping the revision doesn’t begin with an X!

$ snap info gnome-42-2204
name:      gnome-42-2204
summary:   Shared GNOME 42 Ubuntu stack
publisher: Canonical✓
store-url: https://snapcraft.io/gnome-42-2204
contact:   https://github.com/ubuntu/gnome-sdk/issues
license:   unset
description: |
  This snap provides the GNOME 42 stack to other snaps that use it. It shares the base GNOME
  libraries and desktop integration components through the content interface. This helps reduce the
  size of snaps and helps developers to easily snap desktop applications.
  
  **For users**
  
  This snap is automatically installed and removed when needed. **Manually adding or removing this
  snap is not recommended** and might break things.
  
  * If you are having issues with **snaps** using GNOME, please contact the experts on the Snapcraft
  forum: https://forum.snapcraft.io/
  * If you want to install the GNOME Desktop Environment, then you are in the wrong place. Please
  take a look at https://www.gnome.org/ for more information on how to get it.
  
  **For developers**
  
  * The `gnome` extension is the recommended way to use this in your own snap:
  https://snapcraft.io/docs/gnome-extension
  * You can report issues with this content snap on GitHub:
  https://github.com/ubuntu/gnome-sdk/issues
  * The source code of this snap is available on GitHub in the `gnome-42-2204` branch:
  https://github.com/ubuntu/gnome-sdk/tree/gnome-42-2204
snap-id:      lATO8HzwVvrAPrlZRAWpfyrJKlAJrZS3
tracking:     latest/stable
refresh-date: today at 12:20 UTC
channels:
  latest/stable:    0+git.ff35a85 2023-09-30 (141) 521MB -
  latest/candidate: 0+git.510a601 2024-01-05 (166) 527MB -
  latest/beta:      ↑                                    
  latest/edge:      0+git.510a601 2024-01-05 (166) 527MB -
installed:          0+git.ff35a85            (141) 521MB -

This also happens when trying core20 and gnome-3-38. So we are stuck with core18 for time being.

Hello, another Opera dev over here.

Just for your information, a similar issue happened to our package before with gnome-3-28-1804.

@ogra @James-Carroll Could you take a look if this is relevant?

Also, I noticed that both Brave and Chormium do not have a dbus slot anymore. Instead, mpris is used. Should we also update our yaml file to use mpris as well? Like this:

name: {{ filesystem_name }}
version: {{ major }}.{{ minor }}.{{ nightly }}.{{ patch }}
summary: Fast and secure web browser
description: |
  Opera is a fast, secure, and user-friendly web browser.
  It includes a built-in ad blocker, Video pop-out, and free VPN.
architectures:
  - build-on: amd64
base: core22
confinement: strict
grade: stable
plugs:
  browser-sandbox:
    allow-sandbox: true
    interface: browser-support
  # We need to specify the chromium-ffmpeg interface slot for Opera. When a snap
  # version Opera cannot play H.264 videos while the debian version can,
  # consider update to the latest interface slot first. A slot version may also
  # be removed from chromium-ffmpeg. In this case, we can do
  # `snap revert chromium-ffmpeg` as a workaround.
  chromium-ffmpeg-111306:
    interface: content
    target: $SNAP
    default-provider: chromium-ffmpeg
apps:
  {{ filesystem_name }}:
    command: bin/{{ filesystem_name }}.launcher
    desktop: usr/share/applications/{{ filesystem_name }}.desktop
    environment:
      DISABLE_WAYLAND: 1
      GTK_USE_PORTAL: 1
    extensions: [gnome]
    slots:
    - mpris
    plugs:
    - audio-playback
    - audio-record
    - bluez
    - camera
    - cups-control
    - hardware-observe
    - home
    - joystick
    - mount-observe
    - network
    - network-control
    - network-manager
    - opengl
    - password-manager-service
    - pulseaudio
    - raw-usb
    - removable-media
    - screen-inhibit-control
    - system-packages-doc
    - u2f-devices
    - unity7
    - upower-observe
parts:
  browser:
    plugin: dump
    source: data
    stage-packages:
    - libnss3
    - libxss1
    override-build: |
      craftctl default
      chmod 4755 $SNAPCRAFT_PART_INSTALL/{{ target_dir }}/{{ filesystem_name }}/opera_sandbox
    prime:
      - -etc/init.d
      - -etc/xdg
      - -usr/include
      - -usr/share/doc
      - -usr/share/lintian
      - -usr/share/man
slots:
  mpris:
    interface: mpris

Hey, I think @xshi is absolutely right and the issue is related to the one with gnome-3-28-1804.

I’ve just updated the declarations for opera, opera-beta, opera-developer accordingly and (hopefully) it should auto-connect now.

In the typical case, the autoconnection for the Gnome content snaps isn’t something that applies to the consumer snap (Opera), but the content snap itself.

I.E, the Gnome-42-2204 snap has an assertion that says it can ignore the usual autoconnect rules (connection between the same publisher only), and is actually valid to connect to any snap.

The usual cause for this falling apart is when somebody installs the content snap in --dangerous mode. Without the proper store assertion, the snap would then fail to autoconnect in general, Opera or otherwise.

It’s not impossible that there’s assertions on Opera itself interfering with this, but it’s difficult to determine on our (my) end, since I’m not part of Canonical/the Store team.

However, the Snapcraft.yaml above looks absolutely fine to myself, there’s nothing in it directly that would look like a candidate for this being a problem.

Would it be possible to use that build file and produce a release on the store to test against? It doesn’t have to be fully public, there’s built in functionality known as branches which can be used to enable a temporary but hidden bug-fix release that expires automatically after 30 days and then starts automatically following the right channel/risk afterwards.

(https://snapcraft.io/docs/publish-to-a-branch)

So for example, you could publish it to latest/edge/core22-test and nobody would see it unless they came into this thread looking for it. 30 days after it stops recieving updates, the store will remove it automatically and anyone who did happen to use it would be moved back to latest/edge.

(It could also be latest/stable/core22-test for example, and they’d fall back to latest/stable).

If you can provide a built copy on Core22, we’d be able to see what the assertions look like on our end (i.e publically) and might be able to identify if there’s a conflict that’s specific to Opera.

Thanks @jslarraz @James-Carroll

We will push a new build to Opera-Developer’s edge channel for testing with the snapcraft.yaml file above.

Just to make sure that I don’t break snap declaration rule again. Is it fine to include the change with mpris slot and a bunch of new plugs like audio-record, bluez, etc in our test build? In my understanding, I think the plugs changes are fine. We don’t have auto-connect to them but that’s a separated topic. However, I am not sure about the mpris slot based on the thread of our previous dbus-daemon issue on gnome-3-28.

Maybe let me just list the diff here to make everything clear to everyone :slight_smile:

--- a/desktop/packaging/linux/snapcraft/snapcraft.yaml
+++ b/desktop/packaging/linux/snapcraft/snapcraft.yaml
@@ -5,8 +5,8 @@ description: |
   Opera is a fast, secure, and user-friendly web browser.
   It includes a built-in ad blocker, Video pop-out, and free VPN.
 architectures:
-- amd64
-base: core18
+  - build-on: amd64
+base: core22
 confinement: strict
 grade: stable
 plugs:
@@ -28,88 +28,50 @@ apps:
     desktop: usr/share/applications/{{ filesystem_name }}.desktop
     environment:
       DISABLE_WAYLAND: 1
-    extensions: [gnome-3-28]
+      GTK_USE_PORTAL: 1
+    extensions: [gnome]
     slots:
-    - dbus-daemon
+    - mpris
     plugs:
     - audio-playback
-    - avahi-observe
-    - browser-sandbox
+    - audio-record
+    - bluez
     - camera
     - cups-control
-    - desktop
-    - desktop-legacy
-    - gsettings
+    - hardware-observe
     - home
+    - joystick
     - mount-observe
     - network
     - network-control
     - network-manager
     - opengl
     - password-manager-service
-    - process-control
     - pulseaudio
+    - raw-usb # for WebUSB https://launchpad.net/bugs/1780678
     - removable-media
     - screen-inhibit-control
+    - system-packages-doc # for viewing HTML system documentation
     - u2f-devices
     - unity7
     - upower-observe
-    - wayland
-    - x11
 parts:
   browser:
     plugin: dump
     source: data
     stage-packages:
-    - libasound2
-    - libatk-bridge2.0-0
-    - libatk1.0-0
-    - libatspi2.0-0
-    - libcairo-gobject2
-    - libcairo2
-    - libcups2
-    - libcurl3
-    - libdatrie1
-    - libepoxy0
-    - libfontconfig1
-    - libfreetype6
-    - libgconf-2-4
-    - libgl1-mesa-glx
-    - libglu1-mesa
-    - libgnome-keyring0
-    - libgpm2
-    - libgraphite2-3
-    - libgtk-3-0
-    - libharfbuzz0b
-    - libnotify4
-    - libnspr4
     - libnss3
-    - libpango-1.0-0
-    - libpangocairo-1.0-0
-    - libpangoft2-1.0-0
-    - libpixman-1-0
-    - libpulse0
-    - libsecret-1-0
-    - libthai0
-    - libwayland-client0
-    - libwayland-cursor0
-    - libwayland-egl1
-    - libxcb-render0
-    - libxcb-shm0
-    - libxcomposite1
-    - libxcursor1
-    - libxi6
-    - libxinerama1
-    - libxkbcommon0
-    - libxrandr2
-    - libxrender1
     - libxss1
-    - libxtst6
     override-build: |
-      snapcraftctl build
+      craftctl default
       chmod 4755 $SNAPCRAFT_PART_INSTALL/{{ target_dir }}/{{ filesystem_name }}/opera_sandbox
+    prime:
+      - -etc/init.d
+      - -etc/xdg
+      - -usr/include
+      - -usr/share/doc
+      - -usr/share/lintian
+      - -usr/share/man
 slots:
-  dbus-daemon:
-    interface: dbus
-    bus: session
-    name: com.opera.{{ filesystem_name }}
+  mpris:
+    interface: mpris

Hi @James-Carroll

Although you are generally right, assertions defined for plugs have precedence. That means (if I’m right) that if opera assertion contains any information about content interfaces in its plugs, the assertion of the slot (the content snap) would not be taken into consideration. As opera is plugging chromium-ffmpeg I think we also need to explicitly allow other content snaps (even if they have global auto-connection at the slot side) in the opera declaration.

I may be wrong here, so let’s double check if the changes I made work

Hey @xshi

The snapcraft.yaml looks good to me, however I’m not the most experienced one building snaps and therefore the best one spotting issues hehe.

Regarding the new interfaces, I expect it to require manual review at the store because of the mpris slot, but it should be granted with not issue.

If you know the number of the snap revision where you first tried to move to core22 (and failed to auto-connect to gnome-42-2204), you can check if the auto-connection is now working without creating a new version by installing this concrete revision as:

snap install opera[-xxx] revision=<#rev>

Tried with snap install opera-developer --revision=294 which was one based on core22 and can confirm it connected to gnome automatically.

Yep, confirmed with 293 as well. Everything seems connected.

In that case, we will break up the yaml file change into basic core22 upgrade and all the slot & plugs changes then. And request for review for the latter next time. Thanks again.

Yes that is correct @jslarraz - snapd does not merge declarations, instead it just takes the first one it finds based on precedence (where the declarations of the plug side snap (opera in this case) takes precedence over slot side (gnome content snap)) - so if we add a declaration for a content plug then we need to duplicate the rules from the slot side to ensure they get applied correctly.