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/22468 Tested-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/libEGL/libEGL.hpp b/src/OpenGL/libEGL/libEGL.hpp index 7019338..4a95a5f 100644 --- a/src/OpenGL/libEGL/libEGL.hpp +++ b/src/OpenGL/libEGL/libEGL.hpp
@@ -90,7 +90,7 @@ private: LibEGLexports *loadExports() { - if(!libEGL) + if(!loadLibraryAttempted && !libEGL) { #if defined(_WIN32) #if defined(__LP64__) @@ -126,6 +126,8 @@ auto libEGL_swiftshader = (LibEGLexports *(*)())getProcAddress(libEGL, "libEGL_swiftshader"); libEGLexports = libEGL_swiftshader(); } + + loadLibraryAttempted = true; } return libEGLexports; @@ -133,6 +135,7 @@ void *libEGL = nullptr; LibEGLexports *libEGLexports = nullptr; + bool loadLibraryAttempted = false; }; #endif // libEGL_hpp