Firefox RTC screencasting not working

I’m on an Arch base system with home-manager based config and my window-manager is sway. I’m able to get cameras and microphones to work for webRTC in Firefox, but not screen sharing.

I see that when Firefox tries to start a screencast it does so via D-Bus and I can see the following on dbus-monitor

method call time=1686555522.779241 sender=:1.11 -> destination=org.freedesktop.DBus serial=260 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.portal.Desktop',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',path='/org/freedesktop/portal/desktop',arg0='org.freedesktop.portal.ScreenCast'"
method return time=1686555522.779267 sender=org.freedesktop.DBus -> destination=:1.11 serial=213 reply_serial=260
method call time=1686555522.779274 sender=:1.11 -> destination=org.freedesktop.DBus serial=261 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.portal.Desktop',interface='org.freedesktop.portal.ScreenCast',path='/org/freedesktop/portal/desktop'"
method return time=1686555522.779284 sender=org.freedesktop.DBus -> destination=:1.11 serial=214 reply_serial=261
method call time=1686555522.779289 sender=:1.11 -> destination=org.freedesktop.DBus serial=262 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=AddMatch
   string "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',path='/org/freedesktop/DBus',arg0='org.freedesktop.portal.Desktop'"
method return time=1686555522.779299 sender=org.freedesktop.DBus -> destination=:1.11 serial=215 reply_serial=262
method call time=1686555522.779326 sender=:1.11 -> destination=org.freedesktop.DBus serial=263 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=StartServiceByName
   string "org.freedesktop.portal.Desktop"
   uint32 0
method return time=1686555522.779340 sender=org.freedesktop.DBus -> destination=:1.11 serial=216 reply_serial=263
   uint32 2
method call time=1686555522.785682 sender=:1.11 -> destination=org.freedesktop.DBus serial=264 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
   string "org.freedesktop.portal.Desktop"
method return time=1686555522.785710 sender=org.freedesktop.DBus -> destination=:1.11 serial=217 reply_serial=264
   string ":1.413"
method call time=1686555522.790069 sender=:1.11 -> destination=:1.413 serial=265 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.DBus.Properties; member=GetAll
   string "org.freedesktop.portal.ScreenCast"
error time=1686555522.790378 sender=:1.413 -> destination=:1.11 error_name=org.freedesktop.DBus.Error.InvalidArgs reply_serial=265
   string "No such interface “org.freedesktop.portal.ScreenCast”"
method call time=1686555522.790914 sender=:1.11 -> destination=:1.413 serial=266 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.ScreenCast; member=CreateSession
   array [
      dict entry(
         string "session_handle_token"
         variant             string "webrtc_session1216757917"
      )
      dict entry(
         string "handle_token"
         variant             string "webrtc_1255023056"
      )
   ]
error time=1686555522.791143 sender=:1.413 -> destination=:1.11 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=266
   string "No such interface “org.freedesktop.portal.ScreenCast” on object at path /org/freedesktop/portal/desktop"

I’m at a bit of a loss as to what exactly might be causing the no such interface errors. I have xdg-desktop-portal.service and xdg-desktop-portal-wlr.service running with WAYLAND_DISPLAY=wayland-1 and XDG_CURRENT_DESKTOP=sway in the environment.

System logs don’t have anything of relevance.

Found the solution. It was only looking for portals in the nix store path of the libexec binary itself. Setting XDG_DESKTOP_PORTAL_DIR works.