Bug 1561859 - [Wayland] Expose active DRM on Wayland in about:support & telemetry, r=kats
authorMartin Stransky <stransky@redhat.com>
Tue, 02 Jul 2019 09:17:22 +0000
changeset 480940 1cdac03c50cd9e75a45153c691309f590306aa6c
parent 480939 69309ca1e67f5f169deaa05735241497a3deba8f
child 480941 99a104e56e35ff3c9c64723036e4976afed9b1db
push id36228
push useraciure@mozilla.com
push dateTue, 02 Jul 2019 21:46:04 +0000
treeherdermozilla-central@da33e6261a81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs1561859
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1561859 - [Wayland] Expose active DRM on Wayland in about:support & telemetry, r=kats Differential Revision: https://phabricator.services.mozilla.com/D36248
toolkit/crashreporter/CrashAnnotations.yaml
widget/GfxInfoX11.cpp
widget/GfxInfoX11.h
widget/gtk/nsWaylandDisplay.cpp
widget/moz.build
--- a/toolkit/crashreporter/CrashAnnotations.yaml
+++ b/toolkit/crashreporter/CrashAnnotations.yaml
@@ -468,16 +468,21 @@ IsGarbageCollecting:
   type: boolean
   ping: true
 
 IsWayland:
   description: >
     If true then the Wayland windowing system was in use.
   type: boolean
 
+IsWaylandDRM:
+  description: >
+    If true then the Wayland DRM backend was in use.
+  type: boolean
+
 JavaStackTrace:
   description: >
     Java stack trace, only present on Firefox for Android if we encounter an
     uncaught Java exception.
   type: string
 
 JSLargeAllocationFailure:
   description: >
--- a/widget/GfxInfoX11.cpp
+++ b/widget/GfxInfoX11.cpp
@@ -15,16 +15,19 @@
 #include "nsICrashReporter.h"
 #include "prenv.h"
 #include "nsPrintfCString.h"
 #include "nsWhitespaceTokenizer.h"
 
 #include "GfxInfoX11.h"
 
 #include <gdk/gdkx.h>
+#ifdef MOZ_WAYLAND
+#  include "mozilla/widget/nsWaylandDisplay.h"
+#endif
 
 #ifdef DEBUG
 bool fire_glxtest_process();
 #endif
 
 namespace mozilla {
 namespace widget {
 
@@ -38,30 +41,33 @@ pid_t glxtest_pid = 0;
 
 nsresult GfxInfo::Init() {
   mGLMajorVersion = 0;
   mGLMinorVersion = 0;
   mHasTextureFromPixmap = false;
   mIsMesa = false;
   mIsAccelerated = true;
   mIsWayland = false;
+  mIsWaylandDRM = false;
   return GfxInfoBase::Init();
 }
 
 void GfxInfo::AddCrashReportAnnotations() {
   CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterVendorID,
                                      mVendorId);
   CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::AdapterDeviceID,
                                      mDeviceId);
   CrashReporter::AnnotateCrashReport(
       CrashReporter::Annotation::AdapterDriverVendor, mDriverVendor);
   CrashReporter::AnnotateCrashReport(
       CrashReporter::Annotation::AdapterDriverVersion, mDriverVersion);
   CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::IsWayland,
                                      mIsWayland);
+  CrashReporter::AnnotateCrashReport(CrashReporter::Annotation::IsWaylandDRM,
+                                     mIsWaylandDRM);
 }
 
 void GfxInfo::GetData() {
   // to understand this function, see bug 639842. We retrieve the OpenGL driver
   // information in a separate process to protect against bad drivers.
 
   // if glxtest_pipe == -1, that means that we already read the information
   if (glxtest_pipe == -1) return;
@@ -288,18 +294,22 @@ void GfxInfo::GetData() {
   if (mVendorId.IsEmpty()) {
     mVendorId.Assign(glVendor.get());
   }
   if (mDeviceId.IsEmpty()) {
     mDeviceId.Assign(glRenderer.get());
   }
 
   mAdapterDescription.Assign(glRenderer);
+#ifdef MOZ_WAYLAND
   mIsWayland = !GDK_IS_X11_DISPLAY(gdk_display_get_default());
-
+  if (mIsWayland) {
+    mIsWaylandDRM = nsWaylandDisplay::IsDMABufEnabled();
+  }
+#endif
   AddCrashReportAnnotations();
 }
 
 const nsTArray<GfxDriverInfo>& GfxInfo::GetGfxDriverInfo() {
   if (!sDriverInfo->Length()) {
     // Mesa 10.0 provides the GLX_MESA_query_renderer extension, which allows us
     // to query device IDs backing a GL context for blacklisting.
     APPEND_TO_DRIVER_BLOCKLIST(
@@ -446,17 +456,21 @@ GfxInfo::GetDWriteVersion(nsAString& aDw
 NS_IMETHODIMP
 GfxInfo::GetCleartypeParameters(nsAString& aCleartypeParams) {
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 GfxInfo::GetWindowProtocol(nsAString& aWindowProtocol) {
   if (mIsWayland) {
-    aWindowProtocol.AssignLiteral("wayland");
+    if (mIsWaylandDRM) {
+      aWindowProtocol.AssignLiteral("wayland (drm)");
+    } else {
+      aWindowProtocol.AssignLiteral("wayland");
+    }
     return NS_OK;
   }
 
   aWindowProtocol.AssignLiteral("x11");
   return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/widget/GfxInfoX11.h
+++ b/widget/GfxInfoX11.h
@@ -76,16 +76,17 @@ class GfxInfo final : public GfxInfoBase
   nsCString mAdapterRAM;
   nsCString mOS;
   nsCString mOSRelease;
   bool mHasTextureFromPixmap;
   unsigned int mGLMajorVersion, mGLMinorVersion;
   bool mIsMesa;
   bool mIsAccelerated;
   bool mIsWayland;
+  bool mIsWaylandDRM;
 
   void AddCrashReportAnnotations();
 };
 
 }  // namespace widget
 }  // namespace mozilla
 
 #endif /* __GfxInfoX11_h__ */
--- a/widget/gtk/nsWaylandDisplay.cpp
+++ b/widget/gtk/nsWaylandDisplay.cpp
@@ -95,16 +95,19 @@ static nsWaylandDisplay* WaylandDisplayG
 
   MOZ_CRASH("There's too many wayland display conections!");
   return nullptr;
 }
 
 nsWaylandDisplay* WaylandDisplayGet(GdkDisplay* aGdkDisplay) {
   if (!aGdkDisplay) {
     aGdkDisplay = gdk_display_get_default();
+    if (!aGdkDisplay) {
+      return nullptr;
+    }
   }
 
   StaticMutexAutoLock lock(gWaylandDisplaysMutex);
   return WaylandDisplayGetLocked(aGdkDisplay, lock);
 }
 
 void nsWaylandDisplay::SetShm(wl_shm* aShm) { mShm = aShm; }
 
@@ -341,16 +344,21 @@ nsWaylandDisplay::~nsWaylandDisplay() {
 
 bool nsWaylandDisplay::IsDMABufEnabled() {
   if (mIsDMABufConfigured) {
     return mIsDMABufEnabled;
   }
 
   // WaylandDisplayGet() sets mIsDMABufPrefState
   nsWaylandDisplay* display = WaylandDisplayGet();
+  if (!display) {
+    NS_WARNING("Failed to get nsWaylandDisplay, called too early?");
+    return false;
+  }
+
   if (nsWaylandDisplay::mIsDMABufPrefState == -1) {
     MOZ_ASSERT(false,
                "We're missing nsWaylandDisplay preference configuration!");
     return false;
   }
 
   mIsDMABufConfigured = true;
   if (!nsWaylandDisplay::mIsDMABufPrefState) {
--- a/widget/moz.build
+++ b/widget/moz.build
@@ -330,8 +330,10 @@ LOCAL_INCLUDES += [
     '/widget/%s' % widget_dir,
 ]
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_ENABLE_D3D10_LAYER']:
     DEFINES['MOZ_ENABLE_D3D10_LAYER'] = True
 
 CXXFLAGS += CONFIG['TK_CFLAGS']
+if CONFIG['MOZ_WAYLAND']:
+    CXXFLAGS += CONFIG['MOZ_WAYLAND_CFLAGS']