Title: [213074] trunk/Source/WebKit2
Revision
213074
Author
achristen...@apple.com
Date
2017-02-27 09:21:55 -0800 (Mon, 27 Feb 2017)

Log Message

Optimize checkWebRTCAvailability
https://bugs.webkit.org/show_bug.cgi?id=168913

Reviewed by Darin Adler.

We can optimize startup time by using RTLD_LAZY instead of RTLD_NOW because we don't need to load all the symbols.
We just need to check whether libwebrtc.dylib can be found and is a valid dylib for the current architecture.
Also, initialize a static bool so it only needs to be checked once.  Right now it's only used when initializing settings,
but if we use it for other things in the future there will be no need to reopen the dylib.

* UIProcess/WebPreferences.cpp:
(WebKit::checkWebRTCAvailability):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (213073 => 213074)


--- trunk/Source/WebKit2/ChangeLog	2017-02-27 17:20:29 UTC (rev 213073)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-27 17:21:55 UTC (rev 213074)
@@ -1,3 +1,18 @@
+2017-02-27  Alex Christensen  <achristen...@webkit.org>
+
+        Optimize checkWebRTCAvailability
+        https://bugs.webkit.org/show_bug.cgi?id=168913
+
+        Reviewed by Darin Adler.
+
+        We can optimize startup time by using RTLD_LAZY instead of RTLD_NOW because we don't need to load all the symbols.
+        We just need to check whether libwebrtc.dylib can be found and is a valid dylib for the current architecture.
+        Also, initialize a static bool so it only needs to be checked once.  Right now it's only used when initializing settings,
+        but if we use it for other things in the future there will be no need to reopen the dylib.
+
+        * UIProcess/WebPreferences.cpp:
+        (WebKit::checkWebRTCAvailability):
+
 2017-02-26  Wenson Hsieh  <wenson_hs...@apple.com>
 
         Unreviewed, revert all temporary build fixes for data interaction

Modified: trunk/Source/WebKit2/UIProcess/WebPreferences.cpp (213073 => 213074)


--- trunk/Source/WebKit2/UIProcess/WebPreferences.cpp	2017-02-27 17:20:29 UTC (rev 213073)
+++ trunk/Source/WebKit2/UIProcess/WebPreferences.cpp	2017-02-27 17:21:55 UTC (rev 213074)
@@ -199,11 +199,14 @@
 bool checkWebRTCAvailability()
 {
 #if USE(LIBWEBRTC)
-    void* libwebrtcLibrary = dlopen("libwebrtc.dylib", RTLD_NOW);
-    if (!libwebrtcLibrary)
-        return false;
-    dlclose(libwebrtcLibrary);
-    return true;
+    static bool available = [&] {
+        void* libwebrtcLibrary = dlopen("libwebrtc.dylib", RTLD_LAZY);
+        if (!libwebrtcLibrary)
+            return false;
+        dlclose(libwebrtcLibrary);
+        return true;
+    }();
+    return available;
 #else
     return true;
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to