Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/www/firefox firefox: different way of avoiding pshared...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/a1f8d5d26f79
branches:  trunk
changeset: 434354:a1f8d5d26f79
user:      maya <maya%pkgsrc.org@localhost>
date:      Sun Jun 14 18:42:19 2020 +0000

description:
firefox: different way of avoiding pshared semaphores for NetBSD

NetBSD has slightly (NetBSD>=9.x) or very (NetBSD<8) broken pshared
semaphores. Fortunately, so does macOS, so there's an easy way to avoid
reaching the code relying on it which works better.

Do so for NetBSD unconditionally, and enable multiprocess unconditionally.
Avoids PR kern/55386 for NetBSD>9.0
Avoids corrupt output on major websites, webGL bugs, etc. for NetBSD<=9.0

diffstat:

 www/firefox/Makefile                                                |   13 +-
 www/firefox/distinfo                                                |    5 +-
 www/firefox/patches/patch-gfx_thebes_gfxPlatform.cpp                |   28 +
 www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore.h          |   29 -
 www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp |  188 ----------
 5 files changed, 32 insertions(+), 231 deletions(-)

diffs (truncated from 310 to 300 lines):

diff -r c7fb3664f9e5 -r a1f8d5d26f79 www/firefox/Makefile
--- a/www/firefox/Makefile      Sun Jun 14 16:28:19 2020 +0000
+++ b/www/firefox/Makefile      Sun Jun 14 18:42:19 2020 +0000
@@ -1,8 +1,9 @@
-# $NetBSD: Makefile,v 1.430 2020/06/05 03:38:56 ryoon Exp $
+# $NetBSD: Makefile,v 1.431 2020/06/14 18:42:19 maya Exp $
 
 FIREFOX_VER=           ${MOZ_BRANCH}${MOZ_BRANCH_MINOR}
 MOZ_BRANCH=            77.0
 MOZ_BRANCH_MINOR=      .1
+PKGREVISION=           1
 
 DISTNAME=      firefox-${FIREFOX_VER}.source
 PKGNAME=       ${DISTNAME:S/.source//:S/b/beta/:S/esr//}
@@ -99,16 +100,6 @@
        cd ${WRKSRC}/${OBJDIR} && touch old-configure.vars
        # Do not fetch Rust Cargo file via network during build
 
-.if !empty(MACHINE_PLATFORM:MNetBSD-8.*-*) || !empty(MACHINE_PLATFORM:MNetBSD-9.0*)
-.PHONY: disable-multiprocess
-disable-multiprocess:
-       ${STEP_MSG} "Broken process-shared mutexes, disabling multiprocess windows..."
-       cd ${WRKSRC} && ${ECHO} 'pref("browser.tabs.remote.autostart", false);' >> browser/app/profile/firefox.js
-       cd ${WRKSRC} && ${ECHO} 'pref("webgl.disabled", true);' >> browser/app/profile/firefox.js
-
-post-configure: disable-multiprocess
-.endif
-
 post-build:
        ${SED} -e 's|@MOZILLA@|${MOZILLA}|g'                            \
          -e 's|@MOZILLA_NAME@|${MOZILLA_NAME}|g'                       \
diff -r c7fb3664f9e5 -r a1f8d5d26f79 www/firefox/distinfo
--- a/www/firefox/distinfo      Sun Jun 14 16:28:19 2020 +0000
+++ b/www/firefox/distinfo      Sun Jun 14 18:42:19 2020 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.397 2020/06/05 03:38:56 ryoon Exp $
+$NetBSD: distinfo,v 1.398 2020/06/14 18:42:19 maya Exp $
 
 SHA1 (firefox-77.0.1.source.tar.xz) = 86735b221c17964f5e6a756a973b6d0696fbf1c5
 RMD160 (firefox-77.0.1.source.tar.xz) = 59ef718e1bf9eef0a6b90c60ec20bbe4c7402ffe
@@ -16,11 +16,10 @@
 SHA1 (patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h) = 2f73c76c48852613e0c55c1680fcc2a9eb3cf4ef
 SHA1 (patch-gfx_cairo_cairo_src_cairo-type1-subset.c) = 89a9d934ef76706c552c0b81e6cbc0f45b1ffd2c
 SHA1 (patch-gfx_skia_skia_src_core_SkCpu.cpp) = 36218819254f3681b9c717d652ea78c9f20d49ad
+SHA1 (patch-gfx_thebes_gfxPlatform.cpp) = f6f8996f0818a1b890698c7cc5054d49cb1e8924
 SHA1 (patch-ipc_chromium_src_base_lock__impl__posix.cc) = d84d9b4d416e049423120dcbf9199644ce1c93ab
 SHA1 (patch-ipc_chromium_src_base_message__pump__libevent.cc) = 4a6606da590cfb8d855bde58b9c6f90e98d0870c
 SHA1 (patch-ipc_chromium_src_base_platform__thread__posix.cc) = 35d20981d33ccdb1d8ffb8039e48798777f11658
-SHA1 (patch-ipc_glue_CrossProcessSemaphore.h) = 102e8a164584c6d73a5ca2bd4ad1050586082410
-SHA1 (patch-ipc_glue_CrossProcessSemaphore__posix.cpp) = 9635992da0fbae262a02a0eafce7e2445c44c22b
 SHA1 (patch-ipc_glue_GeckoChildProcessHost.cpp) = 260c29bacd8bf265951b7a412f850bf2b292c836
 SHA1 (patch-js_src_jsfriendapi.h) = 6bbb895b882ee24929f011751c42732215e153a2
 SHA1 (patch-js_src_util_NativeStack.cpp) = a0a16d8d8d78d3cc3f4d2a508586f1a7821f7dba
diff -r c7fb3664f9e5 -r a1f8d5d26f79 www/firefox/patches/patch-gfx_thebes_gfxPlatform.cpp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/www/firefox/patches/patch-gfx_thebes_gfxPlatform.cpp      Sun Jun 14 18:42:19 2020 +0000
@@ -0,0 +1,28 @@
+$NetBSD: patch-gfx_thebes_gfxPlatform.cpp,v 1.7 2020/06/14 18:42:19 maya Exp $
+
+Don't rely on CrossProcessSemaphore on NetBSD. It has some implementation
+issues that cause issues (kern/55386, not available on NetBSD<9)
+
+This idea is borrowed from macOS which has the same limitation.
+
+--- gfx/thebes/gfxPlatform.cpp.orig    2020-06-03 01:04:50.000000000 +0000
++++ gfx/thebes/gfxPlatform.cpp
+@@ -2922,6 +2922,10 @@ bool gfxPlatform::UsesOffMainThreadCompo
+ }
+ 
+ bool gfxPlatform::UsesTiling() const {
++#ifdef __NetBSD__
++  // Avoid relying on CrossProcessSemaphore
++  return true;
++#else
+   bool usesSkia = GetDefaultContentBackend() == BackendType::SKIA;
+ 
+   // We can't just test whether the PaintThread is initialized here because
+@@ -2934,6 +2938,7 @@ bool gfxPlatform::UsesTiling() const {
+   return StaticPrefs::layers_enable_tiles_AtStartup() ||
+          (StaticPrefs::layers_enable_tiles_if_skia_pomtp_AtStartup() &&
+           usesSkia && usesPOMTP);
++#endif
+ }
+ 
+ bool gfxPlatform::ContentUsesTiling() const {
diff -r c7fb3664f9e5 -r a1f8d5d26f79 www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore.h
--- a/www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore.h        Sun Jun 14 16:28:19 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-$NetBSD: patch-ipc_glue_CrossProcessSemaphore.h,v 1.4 2020/05/04 21:29:08 maya Exp $
-
---- ipc/glue/CrossProcessSemaphore.h.orig      2018-10-18 20:06:06.000000000 +0000
-+++ ipc/glue/CrossProcessSemaphore.h
-@@ -18,6 +18,10 @@
- #  include "mozilla/Atomics.h"
- #endif
- 
-+#ifdef __NetBSD__ // For version check only.
-+#include <sys/param.h>
-+#endif
-+
- namespace IPC {
- template <typename T>
- struct ParamTraits;
-@@ -105,7 +109,13 @@ class CrossProcessSemaphore {
-   HANDLE mSemaphore;
- #elif !defined(OS_MACOSX)
-   RefPtr<mozilla::ipc::SharedMemoryBasic> mSharedBuffer;
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  pthread_mutex_t* mMutex;
-+  pthread_cond_t* mNotZero;
-+  uint32_t* mValue;
-+#else
-   sem_t* mSemaphore;
-+#endif
-   mozilla::Atomic<int32_t>* mRefCount;
- #endif
- };
diff -r c7fb3664f9e5 -r a1f8d5d26f79 www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp
--- a/www/firefox/patches/patch-ipc_glue_CrossProcessSemaphore__posix.cpp       Sun Jun 14 16:28:19 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,188 +0,0 @@
-$NetBSD: patch-ipc_glue_CrossProcessSemaphore__posix.cpp,v 1.7 2020/05/04 21:29:08 maya Exp $
-
---- ipc/glue/CrossProcessSemaphore_posix.cpp.orig      2019-01-18 00:20:30.000000000 +0000
-+++ ipc/glue/CrossProcessSemaphore_posix.cpp
-@@ -9,6 +9,12 @@
- #include "nsDebug.h"
- #include "nsISupportsImpl.h"
- #include <errno.h>
-+#if defined(__NetBSD__)
-+#include <sys/param.h>
-+#include <iostream>
-+#include <unistd.h>
-+#include <limits>
-+#endif
- 
- static const uint64_t kNsPerMs = 1000000;
- static const uint64_t kNsPerSec = 1000000000;
-@@ -16,7 +22,13 @@ static const uint64_t kNsPerSec = 100000
- namespace {
- 
- struct SemaphoreData {
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  pthread_mutex_t mMutex;
-+  pthread_cond_t mNotZero;
-+  uint32_t mValue;
-+#else
-   sem_t mSemaphore;
-+#endif
-   mozilla::Atomic<int32_t> mRefCount;
-   uint32_t mInitialValue;
- };
-@@ -43,13 +55,27 @@ CrossProcessSemaphore* CrossProcessSemap
-     return nullptr;
-   }
- 
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  data->mValue = aInitialValue;
-+  if (pthread_mutex_init(&data->mMutex, NULL) ||
-+      pthread_cond_init(&data->mNotZero, NULL) ) {
-+    return nullptr;
-+  }
-+#else
-   if (sem_init(&data->mSemaphore, 1, aInitialValue)) {
-     return nullptr;
-   }
-+#endif
- 
-   CrossProcessSemaphore* sem = new CrossProcessSemaphore;
-   sem->mSharedBuffer = sharedBuffer;
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  sem->mMutex = &data->mMutex;
-+  sem->mNotZero = &data->mNotZero;
-+  sem->mValue = &data->mValue;
-+#else
-   sem->mSemaphore = &data->mSemaphore;
-+#endif
-   sem->mRefCount = &data->mRefCount;
-   *sem->mRefCount = 1;
- 
-@@ -85,23 +111,44 @@ CrossProcessSemaphore* CrossProcessSemap
- 
-   int32_t oldCount = data->mRefCount++;
-   if (oldCount == 0) {
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+    if (pthread_mutex_init(&data->mMutex, NULL) ||
-+        pthread_cond_init(&data->mNotZero, NULL) ) {
-+      data->mRefCount--;
-+      return nullptr;
-+    }
-+#else
-     // The other side has already let go of their CrossProcessSemaphore, so now
-     // mSemaphore is garbage. We need to re-initialize it.
-     if (sem_init(&data->mSemaphore, 1, data->mInitialValue)) {
-       data->mRefCount--;
-       return nullptr;
-     }
-+#endif
-   }
- 
-   CrossProcessSemaphore* sem = new CrossProcessSemaphore;
-   sem->mSharedBuffer = sharedBuffer;
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  sem->mMutex = &data->mMutex;
-+  sem->mNotZero = &data->mNotZero;
-+  sem->mValue = &data->mValue;
-+#else
-   sem->mSemaphore = &data->mSemaphore;
-+#endif
-   sem->mRefCount = &data->mRefCount;
-   return sem;
- }
- 
- CrossProcessSemaphore::CrossProcessSemaphore()
--    : mSemaphore(nullptr), mRefCount(nullptr) {
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  : mMutex (nullptr)
-+  , mNotZero (nullptr)
-+  , mValue (nullptr)
-+#else
-+    : mSemaphore(nullptr)
-+#endif
-+    , mRefCount(nullptr) {
-   MOZ_COUNT_CTOR(CrossProcessSemaphore);
- }
- 
-@@ -110,16 +157,57 @@ CrossProcessSemaphore::~CrossProcessSema
- 
-   if (oldCount == 0) {
-     // Nothing can be done if the destroy fails so ignore return code.
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+    (void)pthread_cond_destroy(mNotZero);
-+    (void)pthread_mutex_destroy(mMutex);
-+#else
-     Unused << sem_destroy(mSemaphore);
-+#endif
-   }
- 
-   MOZ_COUNT_DTOR(CrossProcessSemaphore);
- }
- 
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+static struct timespec
-+makeAbsTime(const Maybe<TimeDuration>& aWaitTime) {
-+  struct timespec ts;
-+  if (aWaitTime.isSome()) {
-+    clock_gettime(CLOCK_REALTIME, &ts);
-+    ts.tv_nsec += (kNsPerMs * aWaitTime->ToMilliseconds());
-+    ts.tv_sec += ts.tv_nsec / kNsPerSec;
-+    ts.tv_nsec %= kNsPerSec;
-+  }
-+  else {
-+    ts.tv_sec = std::numeric_limits<time_t>::max();
-+    ts.tv_nsec = 0;
-+  }
-+  return ts;
-+}
-+#endif
-+
- bool CrossProcessSemaphore::Wait(const Maybe<TimeDuration>& aWaitTime) {
-   MOZ_ASSERT(*mRefCount > 0,
-              "Attempting to wait on a semaphore with zero ref count");
-   int ret;
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  struct timespec ts = makeAbsTime(aWaitTime);
-+
-+  ret = pthread_mutex_lock(mMutex);
-+
-+  if (ret == 0) {
-+    while (ret == 0 && mValue == 0) {
-+      ret = pthread_cond_timedwait(mNotZero, mMutex, &ts);
-+      while (ret == -1 && errno == EINTR) {
-+        ret = pthread_cond_timedwait(mNotZero, mMutex, &ts);
-+      }
-+    }
-+    if (ret == 0) {
-+      --(*mValue);
-+    }
-+    pthread_mutex_unlock(mMutex);
-+  }
-+#else
-   if (aWaitTime.isSome()) {
-     struct timespec ts;
-     if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
-@@ -136,13 +224,24 @@ bool CrossProcessSemaphore::Wait(const M
-     while ((ret = sem_wait(mSemaphore)) == -1 && errno == EINTR) {
-     }
-   }
-+#endif
-   return ret == 0;
- }
- 
- void CrossProcessSemaphore::Signal() {
-   MOZ_ASSERT(*mRefCount > 0,
-              "Attempting to signal a semaphore with zero ref count");
-+#if defined(__NetBSD__) && (__NetBSD_Version__ < 900000001)
-+  int ret;
-+  ret = pthread_mutex_lock(mMutex);
-+  if (ret == 0) {



Home | Main Index | Thread Index | Old Index