Commit 1147fc2a by Alexis Hetu Committed by Alexis Hétu

Prevent repeatedly trying to load a non-existent library

A hang in Chromium on MacOS seems related to attempting to load libGLES_CM repeatedly, since it doesn't exist. While dlopen() probably shouldn't be this slow, it could also be related to a sandboxing issue. In any case, this cl attempts to go around the issue by never trying to load a library twice. Bug chromium:904346 Change-Id: I65122f0fc9acb4f8db2a606437c61796464f72ad Reviewed-on: https://swiftshader-review.googlesource.com/c/22468Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 635c9b33
......@@ -90,7 +90,7 @@ public:
private:
LibEGLexports *loadExports()
{
if(!libEGL)
if(!loadLibraryAttempted && !libEGL)
{
#if defined(_WIN32)
#if defined(__LP64__)
......@@ -126,6 +126,8 @@ private:
auto libEGL_swiftshader = (LibEGLexports *(*)())getProcAddress(libEGL, "libEGL_swiftshader");
libEGLexports = libEGL_swiftshader();
}
loadLibraryAttempted = true;
}
return libEGLexports;
......@@ -133,6 +135,7 @@ private:
void *libEGL = nullptr;
LibEGLexports *libEGLexports = nullptr;
bool loadLibraryAttempted = false;
};
#endif // libEGL_hpp
......@@ -251,7 +251,7 @@ public:
private:
LibGLES_CMexports *loadExports()
{
if(!libGLES_CM)
if(!loadLibraryAttempted && !libGLES_CM)
{
#if defined(_WIN32)
#if defined(__LP64__)
......@@ -287,6 +287,8 @@ private:
auto libGLES_CM_swiftshader = (LibGLES_CMexports *(*)())getProcAddress(libGLES_CM, "libGLES_CM_swiftshader");
libGLES_CMexports = libGLES_CM_swiftshader();
}
loadLibraryAttempted = true;
}
return libGLES_CMexports;
......@@ -294,6 +296,7 @@ private:
void *libGLES_CM = nullptr;
LibGLES_CMexports *libGLES_CMexports = nullptr;
bool loadLibraryAttempted = false;
};
#endif // libGLES_CM_hpp
......@@ -276,7 +276,7 @@ public:
private:
LibGLESv2exports *loadExports()
{
if(!libGLESv2)
if(!loadLibraryAttempted && !libGLESv2)
{
#if defined(_WIN32)
#if defined(__LP64__)
......@@ -312,6 +312,8 @@ private:
auto libGLESv2_swiftshader = (LibGLESv2exports *(*)())getProcAddress(libGLESv2, "libGLESv2_swiftshader");
libGLESv2exports = libGLESv2_swiftshader();
}
loadLibraryAttempted = true;
}
return libGLESv2exports;
......@@ -319,6 +321,7 @@ private:
void *libGLESv2 = nullptr;
LibGLESv2exports *libGLESv2exports = nullptr;
bool loadLibraryAttempted = false;
};
#endif // libGLESv2_hpp
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment