A quick question about desktop capture linux Wayland ScreenCastPortal regarding the session close signal handler. It is only unsubscribed in ScreenCastPortal::OnSessionClosedSignal() and not in ScreenCastPortal dtor or ScreenCastPortal::UnsubscribeSignalHandlers(). For success case (when the user selects a window and clicks share), I do not see ScreenCastPortal::OnSessionClosedSignal() called at all. When a user cancels the native screen selection dialog, it is called most of the time. In some cases, however, it is called when the user starts to share again - at this point, ScreenCastPortal object is long destructed and results in a crash.
When native screen selection is cancelled, BaseCapturerPipeWire::OnScreenCastSessionClosed() already has capturer_failed_ set to 2, so the function is a no-op.
It is totally possible that we use the desktop capture API wrong and that is the reason that we experience a crash. However, it would be good code hygiene to unsubscribe listener when the object is destructed.
Jozsef