WebGL MonoGame game doesn't run in strictly confined / devmode mode

I am trying to package a MonoGame app that uses OpenGL to render its video output. Currently I have this snapcraft.yaml file:

name: pong-by-yesser-studios
version: '0.0.1'
# ^ this will be changed by the GitHub action.
grade: devel
# ^ this will also be changed by the GitHub action.
summary: A Pong clone by Yesser Studios
description: |
  This Pong clone has everything you would expect from a Pong clone - two pads and a ball.
  Play it with a keyboard or a gamepad with a friend.

base: core22
confinement: devmode
# ^ this will also be changed by the GitHub action.

parts:
  pong-by-yesser-studios:
    plugin: dotnet
    dotnet-build-configuration: Release
    dotnet-self-contained-runtime-identifier: linux-x64
    source: .
    build-packages:
      - dotnet-sdk-8.0
    stage-packages:
      - libicu70
      - libpulse0
      - libglu1-mesa
      - libgl1
    override-build: |
      cd Pong.Desktop
      dotnet restore
      dotnet publish -p:Platform=Linux -c Release -o $SNAPCRAFT_PART_INSTALL --self-contained --use-current-runtime

apps:
  pong-by-yesser-studios:
    command: Pong.Desktop
    plugs:
      - opengl

Which plugs or packages should I include in the build? For reference, here is the output of the app:

libGL error: MESA-LOADER: failed to open iris: /usr/lib/dri/iris_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: iris
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
X Error:  BadValue
  Request Major code 149 (GLX)
  Request Minor code 3 ()
  Value 0x0
  Error Serial #91
  Current Serial #92

Here is a link to the repository for reference: GitHub - Yesser-Studios/Pong: A Pong clone made in C#

This is based on The graphics-core22 Snap interface - Docs - Ubuntu Community Hub

Since your base snap is core22, you might want to plug the mesa-core22 provider and make sure the Snap picks up its libraries, for example:

plugs:
  graphics-core22:
    interface: content
    target: $SNAP/graphics
    default-provider: mesa-core22

apps:
  pong-by-yesser-studios:
    command-chain:
    - bin/graphics-core22-wrapper
    command: Pong.Desktop
    plugs: [ opengl ]

Also this cleanup step might be desired since you want to reduce size of the Snap:

  graphics-core22:
    after: [ pong-by-yesser-studios ]
    source: https://github.com/MirServer/graphics-core22.git
    plugin: dump
    override-prime: |
      craftctl default
      ${CRAFT_PART_SRC}/bin/graphics-core22-cleanup mesa-core22 nvidia-core22
    prime:
    - bin/graphics-core22-wrapper

You can take this snapcraft.yaml as an inspiration: yamagi-quake2-snap/snapcraft.yaml at master · fredldotme/yamagi-quake2-snap · GitHub

@beidl Thank you for your response. Now, the error does not show up and a fullscreen window actually pops up, but the application crashes right away.

Can snaps access files in subdirectories of their binary directory? (e.g. /snap/pong-by-yesser-studios/Content)? If not, how do I let my snap access them?

Yes, snaps can access their own data without any restrictions, see https://snapcraft.io/docs/data-locations

You can also use the usual debugging tools like gdb and strace with snap run --strace snapname and snap run --gdb snapname respectively.