Title: [214418] trunk/Source/WebCore
Revision
214418
Author
commit-qu...@webkit.org
Date
2017-03-27 10:48:22 -0700 (Mon, 27 Mar 2017)

Log Message

Further optimize checkWebRTCAvailability
https://bugs.webkit.org/show_bug.cgi?id=169147

Patch by Youenn Fablet <you...@apple.com> on 2017-03-27
Reviewed by Alex Christensen.

Tested locally by removing libwebrtc.dylib.
Replacing dlopen check by checking an exported symbol, rtc::LogMessage::LogToDebug.
This check is more efficient and accurate. It should work in more configurations than the previous one.

* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::isNullFunctionPointer):
(WebCore::LibWebRTCProvider::webRTCAvailable):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (214417 => 214418)


--- trunk/Source/WebCore/ChangeLog	2017-03-27 17:21:22 UTC (rev 214417)
+++ trunk/Source/WebCore/ChangeLog	2017-03-27 17:48:22 UTC (rev 214418)
@@ -1,3 +1,18 @@
+2017-03-27  Youenn Fablet  <you...@apple.com>
+
+        Further optimize checkWebRTCAvailability
+        https://bugs.webkit.org/show_bug.cgi?id=169147
+
+        Reviewed by Alex Christensen.
+
+        Tested locally by removing libwebrtc.dylib.
+        Replacing dlopen check by checking an exported symbol, rtc::LogMessage::LogToDebug.
+        This check is more efficient and accurate. It should work in more configurations than the previous one.
+
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
+        (WebCore::isNullFunctionPointer):
+        (WebCore::LibWebRTCProvider::webRTCAvailable):
+
 2017-03-27  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Implement format specifier for variation fonts

Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp (214417 => 214418)


--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp	2017-03-27 17:21:22 UTC (rev 214417)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp	2017-03-27 17:48:22 UTC (rev 214418)
@@ -170,6 +170,18 @@
 
     return createActualPeerConnection(observer, WTFMove(portAllocator));
 }
+
+static inline bool isNullFunctionPointer(void* functionPointer)
+{
+    void* result;
+    asm(
+        "mov %1, %0"
+        : "=r" (result)
+        : "r" (functionPointer)
+    );
+    return !result;
+}
+
 #endif // USE(LIBWEBRTC)
 
 bool LibWebRTCProvider::webRTCAvailable()
@@ -176,13 +188,7 @@
 {
 #if USE(LIBWEBRTC)
     static bool available = [] {
-        void* libwebrtcLibrary = dlopen("libwebrtc.dylib", RTLD_LAZY);
-        if (!libwebrtcLibrary) {
-            RELEASE_LOG(WebRTC, "Attempted to load libwebrtc without success: %s", dlerror());
-            return false;
-        }
-        dlclose(libwebrtcLibrary);
-        return true;
+        return !isNullFunctionPointer(reinterpret_cast<void*>(rtc::LogMessage::LogToDebug));
     }();
     return available;
 #else
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to