Backed out changeset f56589462349 (bug 1887843) for causing Bug 1891667. CLOSED TREE

This commit is contained in:
Natalia Csoregi 2024-04-17 23:42:55 +03:00
parent c458c1c11a
commit 4d0948295c

View File

@ -7,10 +7,14 @@
#include "FFVPXRuntimeLinker.h"
#include "FFmpegLibWrapper.h"
#include "FFmpegLog.h"
#include "BinaryPath.h"
#include "mozilla/FileUtils.h"
#include "nsLocalFile.h"
#include "nsXPCOMPrivate.h"
#include "prmem.h"
#include "prlink.h"
#ifdef XP_WIN
# include <windows.h>
#endif
namespace mozilla {
@ -80,37 +84,29 @@ bool FFVPXRuntimeLinker::Init() {
sFFVPXLib.LinkVAAPILibs();
#endif
#ifdef XP_WIN
PathString path =
GetLibraryFilePathname(LXUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
#else
PathString path =
GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Init);
#endif
if (path.IsEmpty()) {
return false;
}
nsCOMPtr<nsIFile> libFile = new nsLocalFile(path);
if (libFile->NativePath().IsEmpty()) {
nsCOMPtr<nsIFile> libFile;
if (NS_FAILED(mozilla::BinaryPath::GetFile(getter_AddRefs(libFile)))) {
return false;
}
if (getenv("MOZ_RUN_GTEST")
#ifdef FUZZING
|| getenv("FUZZER")
#endif
) {
// The condition above is the same as in
// xpcom/glue/standalone/nsXPCOMGlue.cpp. This means we can't reach here
// without the gtest libxul being loaded. In turn, that means the path to
// libxul leads to a subdirectory of where the libmozav* libraries are, so
// we get the parent.
nsCOMPtr<nsIFile> parent;
if (NS_FAILED(libFile->GetParent(getter_AddRefs(parent)))) {
#ifdef XP_DARWIN
if (!XRE_IsParentProcess() &&
(XRE_GetChildProcBinPathType(XRE_GetProcessType()) ==
BinPathType::PluginContainer)) {
// On macOS, PluginContainer processes have their binary in a
// plugin-container.app/Content/MacOS/ directory.
nsCOMPtr<nsIFile> parentDir1, parentDir2;
if (NS_FAILED(libFile->GetParent(getter_AddRefs(parentDir1)))) {
return false;
}
if (NS_FAILED(parentDir1->GetParent(getter_AddRefs(parentDir2)))) {
return false;
}
if (NS_FAILED(parentDir2->GetParent(getter_AddRefs(libFile)))) {
return false;
}
libFile = parent;
}
#endif
if (NS_FAILED(libFile->SetNativeLeafName(MOZ_DLL_PREFIX
"mozavutil" MOZ_DLL_SUFFIX ""_ns))) {