2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2018-05-15 17:15:35 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GTK
|
2021-03-11 17:32:53 +03:00
|
|
|
# include "mozilla/WidgetUtilsGtk.h"
|
2018-05-15 17:15:35 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "GLContextProvider.h"
|
|
|
|
|
2020-01-18 16:48:34 +03:00
|
|
|
namespace mozilla::gl {
|
2018-05-15 17:15:35 +03:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::widget;
|
|
|
|
|
2020-07-02 16:50:41 +03:00
|
|
|
static class GLContextProviderX11 sGLContextProviderX11;
|
2018-05-15 17:15:35 +03:00
|
|
|
static class GLContextProviderEGL sGLContextProviderEGL;
|
|
|
|
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
// Note that if there is no GTK display, `GdkIsX11Display` and
|
|
|
|
// `GdkIsWaylandDisplay` will both return false. That case can
|
|
|
|
// currently happen only in X11 mode if the pref `dom.ipc.avoid-gtk`
|
|
|
|
// is set (and applicable to this process). Thus, these conditionals
|
|
|
|
// check for the presence of Wayland rather than the absence of X11.
|
|
|
|
//
|
|
|
|
// In the future we'll want `dom.ipc.avoid-gtk` to also apply to
|
|
|
|
// Wayland; at that time we'll need another way to communicate the
|
|
|
|
// choice of window system.
|
|
|
|
|
2018-05-15 17:15:35 +03:00
|
|
|
already_AddRefed<GLContext> GLContextProviderWayland::CreateForCompositorWidget(
|
2021-04-07 10:04:43 +03:00
|
|
|
CompositorWidget* aCompositorWidget, bool aHardwareWebRender,
|
2019-03-13 03:17:01 +03:00
|
|
|
bool aForceAccelerated) {
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
if (GdkIsWaylandDisplay()) {
|
|
|
|
return sGLContextProviderEGL.CreateForCompositorWidget(
|
2021-04-07 10:04:43 +03:00
|
|
|
aCompositorWidget, aHardwareWebRender, aForceAccelerated);
|
2018-05-15 17:15:35 +03:00
|
|
|
} else {
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
return sGLContextProviderX11.CreateForCompositorWidget(
|
2021-04-07 10:04:43 +03:00
|
|
|
aCompositorWidget, aHardwareWebRender, aForceAccelerated);
|
2018-05-15 17:15:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
already_AddRefed<GLContext> GLContextProviderWayland::CreateHeadless(
|
2020-06-15 21:25:55 +03:00
|
|
|
const GLContextCreateDesc& desc, nsACString* const out_failureId) {
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
if (GdkIsWaylandDisplay()) {
|
2020-06-15 21:25:55 +03:00
|
|
|
return sGLContextProviderEGL.CreateHeadless(desc, out_failureId);
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
} else {
|
|
|
|
return sGLContextProviderX11.CreateHeadless(desc, out_failureId);
|
2018-05-15 17:15:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
GLContext* GLContextProviderWayland::GetGlobalContext() {
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
if (GdkIsWaylandDisplay()) {
|
2018-05-15 17:15:35 +03:00
|
|
|
return sGLContextProviderEGL.GetGlobalContext();
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
} else {
|
|
|
|
return sGLContextProviderX11.GetGlobalContext();
|
2018-05-15 17:15:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-26 01:07:19 +03:00
|
|
|
/*static*/
|
|
|
|
void GLContextProviderWayland::Shutdown() {
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
if (GdkIsWaylandDisplay()) {
|
2018-05-15 17:15:35 +03:00
|
|
|
sGLContextProviderEGL.Shutdown();
|
Bug 1635451 - Minimize content processes' connections to the X server. r=jgilbert,stransky,nika
This patch launches content processes with the `MOZ_HEADLESS` env var set
if they're using GTK with an X11 display (and there's no other reason
they'd need GTK).
The goal is to avoid exhausting Xorg's default limit of 256 clients if
there are many content processes due to Fission. If these conditions
are met, the content process doesn't need to eagerly connect to the X
server. This does not affect the sandbox policy, and content processes
can still use X if needed for, e.g., WebGL.
The boolean pref `dom.ipc.avoid-gtk`, set by default, controls this
feature. In the future it could also be extended to minimize GTK use
with Wayland displays.
Note that disabling `widget.non-native-theme.enabled`, which is also
enabled by default, will restore the use of X11 in all content processes
even if this pref is set; the alternative is that widgets wouldn't render
in that case.
This change will also save some memory for now-unnecessary instances of
GTK's global state, and improve content process startup time.
Remove also the temp pref dom.ipc.remote-mozIcon because it cannot work
anymore with the content process being headless.
Differential Revision: https://phabricator.services.mozilla.com/D112197
2021-07-06 10:42:42 +03:00
|
|
|
} else {
|
|
|
|
sGLContextProviderX11.Shutdown();
|
2018-05-15 17:15:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-18 16:48:34 +03:00
|
|
|
} // namespace mozilla::gl
|