Bug 1678445 - Crash related to Widevine playback on macOS 11 with Apples Silicon/arm64 r=jld,bryce

When using an x64 GMP child process with an arm64 parent process on arm64 Mac's, use a 16k Shmem pagesize in the child process.

Differential Revision: https://phabricator.services.mozilla.com/D98241
This commit is contained in:
Haik Aftandilian 2020-12-01 19:05:20 +00:00
parent 40bf7ed8c2
commit ba86698ecc
2 changed files with 25 additions and 1 deletions

View File

@ -89,6 +89,9 @@ bool GMPProcessParent::Launch(int32_t aTimeoutMs) {
GMP_LOG_DEBUG("GMPProcessParent::Launch() mChildLaunchArch: %d", GMP_LOG_DEBUG("GMPProcessParent::Launch() mChildLaunchArch: %d",
mChildLaunchArch); mChildLaunchArch);
mLaunchOptions->arch = mChildLaunchArch; mLaunchOptions->arch = mChildLaunchArch;
if (mChildLaunchArch == base::PROCESS_ARCH_X86_64) {
mLaunchOptions->env_map["MOZ_SHMEM_PAGESIZE_16K"] = 1;
}
#endif #endif
#if defined(XP_WIN) && defined(MOZ_SANDBOX) #if defined(XP_WIN) && defined(MOZ_SANDBOX)

View File

@ -9,9 +9,17 @@
#include "mozilla/ipc/SharedMemory.h" #include "mozilla/ipc/SharedMemory.h"
#if defined(XP_MACOSX) && defined(__x86_64__)
#include "prenv.h"
#endif
namespace mozilla { namespace mozilla {
namespace ipc { namespace ipc {
#if defined(XP_MACOSX) && defined(__x86_64__)
std::atomic<size_t> sPageSizeOverride = 0;
#endif
void SharedMemory::SystemProtect(char* aAddr, size_t aSize, int aRights) { void SharedMemory::SystemProtect(char* aAddr, size_t aSize, int aRights) {
if (!SystemProtectFallible(aAddr, aSize, aRights)) { if (!SystemProtectFallible(aAddr, aSize, aRights)) {
MOZ_CRASH("can't mprotect()"); MOZ_CRASH("can't mprotect()");
@ -28,7 +36,20 @@ bool SharedMemory::SystemProtectFallible(char* aAddr, size_t aSize,
return 0 == mprotect(aAddr, aSize, flags); return 0 == mprotect(aAddr, aSize, flags);
} }
size_t SharedMemory::SystemPageSize() { return sysconf(_SC_PAGESIZE); } size_t SharedMemory::SystemPageSize() {
#if defined(XP_MACOSX) && defined(__x86_64__)
if (sPageSizeOverride == 0) {
if (PR_GetEnv("MOZ_SHMEM_PAGESIZE_16K")) {
sPageSizeOverride = 16 * 1024;
} else {
sPageSizeOverride = sysconf(_SC_PAGESIZE);
}
}
return sPageSizeOverride;
#else
return sysconf(_SC_PAGESIZE);
#endif
}
} // namespace ipc } // namespace ipc
} // namespace mozilla } // namespace mozilla