screenshot: Move HAVE_RECORDER check into screencast service

Some gstreamer plugins require a connection to the display server,
so if we end up initializing gstreamer before we are ourselves
fully initialized, we may end up with a locked compositor.

Avoid this by moving the runtime recorder check into the screencast
D-Bus service, so that all gstreamer calls happen out of process.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5710

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2519>
This commit is contained in:
Florian Müllner
2022-10-19 12:43:29 +02:00
parent cff56d4b03
commit f266c2ca15
5 changed files with 61 additions and 63 deletions

View File

@ -258,9 +258,17 @@ var Recorder = class {
};
var ScreencastService = class extends ServiceImplementation {
static canScreencast() {
return Gst.init_check(null) &&
Gst.ElementFactory.find('pipewiresrc') &&
Gst.ElementFactory.find('filesink');
}
constructor() {
super(ScreencastIface, '/org/gnome/Shell/Screencast');
this._canScreencast = ScreencastService.canScreencast();
Gst.init(null);
Gtk.init();
@ -280,6 +288,10 @@ var ScreencastService = class extends ServiceImplementation {
'/org/gnome/Shell/Introspect');
}
get ScreencastSupported() {
return this._canScreencast;
}
_removeRecorder(sender) {
this._recorders.delete(sender);
if (this._recorders.size === 0)