Linking WebRTC to a C++17 application results in a crash during runtime

209 views
Skip to first unread message

Egor Krugletsov

unread,
Feb 19, 2023, 6:43:08 PM2/19/23
to discuss-webrtc
Hello.

I am developing an crossplatform application using native WebRTC via mediasoup. libmediasoupclient is currently expects us to use M94/4606 version of WebRTC. I configure it with following arguments.

> gn gen out/m94_debug --args="target_winuwp_family=\"desktop\" is_component_build=false rtc_include_tests=false rtc_use_h264=true use_rtti=true treat_warnings_as_errors=false is_debug=true is_clang=true use_custom_libcxx=false use_lld=false"

During configuration and compilation I encounter no errors whatsoever. After that, I am linking it to an empty application. Application is expected to use Qt and so its configutaion file looks like this:

> CONFIG += c++17
>
> INCLUDEPATH += src
> SOURCES += src/main.cpp
>
> # Abseil
> INCLUDEPATH +=   $$(ABSEIL_INCLUDE)/abseil-cpp
>
> # libwebrtc
> INCLUDEPATH +=   $$(LIBWEBRTC_INCLUDE)
> LIBS        += -L$$(LIBWEBRTC_LIB) -lwebrtc
>
> msvc {
>     QMAKE_CXXFLAGS_DEBUG += -MTd -D_ITERATOR_DEBUG_LEVEL=0
>     DEFINES              += WEBRTC_WIN NOMINMAX WIN32_LEAN_AND_MEAN
>     LIBS                 += -lWinmm -lAdvapi32 # -lSecur32 -lmsdmo -ldmoguids -lwmcodecdspuuid
> }

In main function I create object of type webrtc::PeerConnectionInterface::RTCConfiguration and application crashes during its destructor. Recompiling application with C++14 standard and running the same code doesn't result in a crash. I tried to compile M98/4758, M102/5005 and M106/5249 version of webrtc and saw no difference. I was trying different version because I am under impression M94/4606 is limited to C++14. I peeked into compilation arguments of different version and noticed that they were being compiled with C++17 but I still had the same results.

I am using VS2019 for this compiling M94/4606 because VS2022 didn't seem to work. I really do not want to downgrade application to C++14. Is there are a way to resolve this issue?

Thank you.

Egor Krugletsov

unread,
Feb 20, 2023, 4:12:35 AM2/20/23
to discuss-webrtc
Post took a week or so for it to be published, but I have resolved the isuee. The problem was due to absl::optional and std::optional mismatch. In my app, it was using an alias for std::optional and their own implementation in webrtc library. I have solved it by patching base/options.h to use absl::optional implementation regardless of standard used. More info and discussion on this topic can be found here: https://github.com/abseil/abseil-cpp/issues/264.

Petr Leontev (RaiaN)

unread,
May 21, 2023, 9:23:35 AM5/21/23
to discuss-webrtc

Thanks, forcing absl to use its implementation via base/options.h helped me as well!
Reply all
Reply to author
Forward
0 new messages