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/libGLES_CM/libGLES_CM.hpp b/src/OpenGL/libGLES_CM/libGLES_CM.hpp index ae6237b..80ce1f2 100644 --- a/src/OpenGL/libGLES_CM/libGLES_CM.hpp +++ b/src/OpenGL/libGLES_CM/libGLES_CM.hpp
@@ -251,7 +251,7 @@ private: LibGLES_CMexports *loadExports() { - if(!libGLES_CM) + if(!loadLibraryAttempted && !libGLES_CM) { #if defined(_WIN32) #if defined(__LP64__) @@ -287,6 +287,8 @@ 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 @@ void *libGLES_CM = nullptr; LibGLES_CMexports *libGLES_CMexports = nullptr; + bool loadLibraryAttempted = false; }; #endif // libGLES_CM_hpp