WebRTC native (C++) example (peer_connection & video_loop) fails (&capture_checker_)->IsCurrent() check on Windows 10

1,251 views
Skip to first unread message

cifang_bifang

unread,
Sep 24, 2019, 1:47:48 AM9/24/19
to discuss-webrtc

I compiled the WebRTC native code (C++) and I'm playing with peerconnection server and client examples (under `src\talk\examples\peerconnection`).

Everything went well until I set up the second client and try to connection them. They will crush.
I tried to catch the breakpoint  and found it exited because (&capture_checker_)->IsCurrent() check failed.
Error Message:
#
# Fatal error in: ../../modules/video_capture/windows/sink_filter_ds.cc, line 723
# last system error: 0
# Check failed: (&capture_checker_)->IsCurrent()
#
Call Stack:
KernelBase.dll!00007ffec7f90192()
peerconnection_client.exe!rtc::webrtc_checks_impl::FatalLog(const char * file, int line, const char * message, const rtc::webrtc_checks_impl::CheckArgType * fmt, ...) Line 163
at C:\Project\webrtc\src\rtc_base\checks.cc(163)
[Inline Frame] peerconnection_client.exe!rtc::webrtc_checks_impl::LogStreamer<>::Call(const char * file, const int line, const char * message) Line 222
at C:\Project\webrtc\src\rtc_base\checks.h(222)
[Inline Frame] peerconnection_client.exe!rtc::webrtc_checks_impl::FatalLogCall<0>::operator&(const rtc::webrtc_checks_impl::LogStreamer<> & streamer) Line 294
at C:\Project\webrtc\src\rtc_base\checks.h(294)
peerconnection_client.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample * media_sample) Line 723
at C:\Project\webrtc\src\modules\video_capture\windows\sink_filter_ds.cc(723)
[External Code]




I don't know what's wrong with it. So I decide to run other example fisrt. But the video_caputre_tests / video_engine_test / video_loopback crushed too.
PS: for video_loopback example I can see the camera screen appear for a moment.

I also tried to catch the breakpoint and found It exted because same check failed: (&capture_checker_)->IsCurrent()

Error Message:
#
# Fatal error in: ../../modules/video_capture/windows/sink_filter_ds.cc, line 723
# last system error: 0
# Check failed: (&capture_checker_)->IsCurrent()
#

Call Stack:
KernelBase.dll!00007ffec7f90192()
video_loopback.exe!rtc::webrtc_checks_impl::FatalLog(const char * file, int line, const char * message, const rtc::webrtc_checks_impl::CheckArgType * fmt, ...) Line 163
      at C:\Project\webrtc\src\rtc_base\checks.cc(163)
[Inline Frame] video_loopback.exe!rtc::webrtc_checks_impl::LogStreamer<>::Call(const char * file, const int line, const char * message) Line 222
       at C:\Project\webrtc\src\rtc_base\checks.h(222)
[Inline Frame] video_loopback.exe!rtc::webrtc_checks_impl::FatalLogCall<0>::operator&(const rtc::webrtc_checks_impl::LogStreamer<> & streamer) Line 294
 at C:\Project\webrtc\src\rtc_base\checks.h(294)
video_loopback.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample * media_sample) Line 723
   at C:\Project\webrtc\src\modules\video_capture\windows\sink_filter_ds.cc(723)
[External Code]

I tried these examples on two computers(both windows 10 system) and get same results. And I didn't found same issues on Google or Google Groups.

Any idea how to properly fix this?

Thank you.

cifang_bifang

unread,
Sep 24, 2019, 10:03:17 PM9/24/19
to discuss-webrtc
I add breakpoint to debug it.

When the IsCurrent() check failed, Call Stack of check is:
```
video_loopback.exe!rtc::IsThreadRefEqual(const unsigned long & a, const unsigned long & b) Line 53
at C:\Project\webrtc\src\rtc_base\platform_thread_types.cc(53)
video_loopback.exe!webrtc::SequenceCheckerImpl::IsCurrent() Line 55
at C:\Project\webrtc\src\rtc_base\synchronization\sequence_checker.cc(55)

video_loopback.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample * media_sample) Line 723
at C:\Project\webrtc\src\modules\video_capture\windows\sink_filter_ds.cc(723)
[External Code]
```

For path "...\webrtc\src\rtc_base\synchronization\sequence_checker.cc(55)", code is:
```
bool SequenceCheckerImpl::IsCurrent() const {
const TaskQueueBase* const current_queue = TaskQueueBase::Current();
const rtc::PlatformThreadRef current_thread = rtc::CurrentThreadRef();
...);
....
return rtc::IsThreadRefEqual(valid_thread_, current_thread);
}
```
the `valid_thread` in my case is 159100, the `current_thread` is 27624, so it fails for sure.

But I don't know why it will be different everytime and why it should crush when this check failed....
-------------------------------------------------------------------------------------------------
I try to forbidden the camera, the program didn't crush!
And show some color screen.
-------------------------------------------------------------------------------------------------
I try to comment out the code of `IsCurrent check` in `...\webrtc\src\rtc_base\checks.h(294)
video_loopback.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample * media_sample) Line 723`,
For camera, It also didn't crush. And only show black screen but not camera screen.
If forbidden the camera, it still show color screen.

So it seems that the problem is about the camera? Is it right?

cifang_bifang

unread,
Sep 25, 2019, 2:28:18 AM9/25/19
to discuss-webrtc
I found that if we comment out the code of `IsCurrent check` in `...\webrtc\src\rtc_base\checks.h(294)
video_loopback.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample * media_sample) Line 723`, example can run normally.

So I don't know why we need this check there....

Barry

unread,
Oct 17, 2019, 4:37:11 AM10/17/19
to discuss-webrtc
I had the same problem. I also want to know,why we need this check there....

在 2019年9月25日星期三 UTC+8下午2:28:18,cifang_bifang写道:

Wesley Lee

unread,
Oct 17, 2019, 7:34:10 AM10/17/19
to discuss...@googlegroups.com
Just build webrtc with release mode with is_debug = false,or debug mode and disable  RTC_DCHECK_IS_ON by #define RTC_DCHECK_IS_ON 0  

Barry <8707...@qq.com> 于2019年10月17日周四 下午4:37写道:
--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/74e1e087-6d34-4b01-9709-919b0b9e4c6e%40googlegroups.com.

Barry

unread,
Oct 17, 2019, 10:14:22 AM10/17/19
to discuss-webrtc
Thank you for your reply,I think I need debug and RTC_DCHECK_IS_ON.
To solve this problem, I just need //RTC_DCHECK_RUN_ON(&capture_checker_);
i want to know why we need this check there....
webrtc bug?


在 2019年10月17日星期四 UTC+8下午7:34:10,Wesley(晓帆)写道:
Just build webrtc with release mode with is_debug = false,or debug mode and disable  RTC_DCHECK_IS_ON by #define RTC_DCHECK_IS_ON 0  

Barry <8707...@qq.com> 于2019年10月17日周四 下午4:37写道:
I had the same problem. I also want to know,why we need this check there....

在 2019年9月25日星期三 UTC+8下午2:28:18,cifang_bifang写道:
I found that if we comment out the code of `IsCurrent check` in `...\webrtc\src\rtc_base\checks.h(294)
video_loopback.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample * media_sample) Line 723`, example can run normally.

So I don't know why we need this check there....

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss...@googlegroups.com.

Harald Alvestrand

unread,
Oct 17, 2019, 10:46:04 AM10/17/19
to discuss...@googlegroups.com, cifang_bifang
Den 24.09.2019 04:07, skrev cifang_bifang:
>
> I compiled the WebRTC native code (C++) and I'm playing with
> peerconnection server and client examples (under
> `src\talk\examples\peerconnection`).
>
> Everything went well until I set up the second client and try to
> connection them. They will crush.
> I tried to catch the breakpoint  and found it exited
> because *(&capture_checker_)->IsCurrent()* check failed.
> Error Message:
> |
> #
> # Fatal error in: ../../modules/video_capture/windows/sink_filter_ds.cc,
> line 723
> # last system error: 0
> # Check failed: (&capture_checker_)->IsCurrent()
> #

What this means is that the function you are calling is being called
from a different thread than the one that the code expects.
WebRTC code is heavily dependent on functions being called from the
right thread (to avoid use of locks), so there's a lot of DCHECKs that
say "are we on the right thread?"

Sometimes this gets mighty confusing because callbacks are frequently
called on different threads than the one considered "main", so you need
to jump threads before you can call more functions - a few words about
this are written in api/DESIGN.md

I'd recommend checking what thread you're executing on, and trying to
avoid this error rather than disabling the DCHECK.



> |
> Call Stack:
> |
> KernelBase.dll!00007ffec7f90192()
> peerconnection_client.exe!rtc::webrtc_checks_impl::FatalLog(const char *
> file, int line, const char * message, const
> rtc::webrtc_checks_impl::CheckArgType * fmt, ...) Line 163
> at C:\Project\webrtc\src\rtc_base\checks.cc(163)
> [Inline Frame]
> peerconnection_client.exe!rtc::webrtc_checks_impl::LogStreamer<>::Call(const
> char * file, const int line, const char * message) Line 222
> at C:\Project\webrtc\src\rtc_base\checks.h(222)
> [Inline Frame]
> peerconnection_client.exe!rtc::webrtc_checks_impl::FatalLogCall<0>::operator&(const
> rtc::webrtc_checks_impl::LogStreamer<> & streamer) Line 294
> at C:\Project\webrtc\src\rtc_base\checks.h(294)
> peerconnection_client.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample
> * media_sample) Line 723
> at
> C:\Project\webrtc\src\modules\video_capture\windows\sink_filter_ds.cc(723)
> [External Code]
>
> |
>
>
>
> I don't know what's wrong with it. So I decide to run other example
> fisrt. But the video_caputre_tests / video_engine_test / video_loopback
> crushed too.
> *PS: for video_loopback example I can see the camera screen appear for a
> moment.*
>
> I also tried to catch the breakpoint and found It exted because same
> check failed: *(&capture_checker_)->IsCurrent()*
>
> Error Message:
> |
> #
> # Fatal error in: ../../modules/video_capture/windows/sink_filter_ds.cc,
> line 723
> # last system error: 0
> # Check failed: (&capture_checker_)->IsCurrent()
> #
> |
>
> Call Stack:
> |
> KernelBase.dll!00007ffec7f90192()
> video_loopback.exe!rtc::webrtc_checks_impl::FatalLog(constchar*file,intline,constchar*message,constrtc::webrtc_checks_impl::CheckArgType*fmt,...)Line163
>       at C:\Project\webrtc\src\rtc_base\checks.cc(163)
> [InlineFrame]video_loopback.exe!rtc::webrtc_checks_impl::LogStreamer<>::Call(constchar*file,constintline,constchar*message)Line222
>        at C:\Project\webrtc\src\rtc_base\checks.h(222)
> [InlineFrame]video_loopback.exe!rtc::webrtc_checks_impl::FatalLogCall<0>::operator&(constrtc::webrtc_checks_impl::LogStreamer<>&streamer)Line294
>  at C:\Project\webrtc\src\rtc_base\checks.h(294)
> video_loopback.exe!webrtc::videocapturemodule::CaptureInputPin::Receive(IMediaSample*media_sample)Line723
>    at
> C:\Project\webrtc\src\modules\video_capture\windows\sink_filter_ds.cc(723)
> [ExternalCode]
> |
>
> I tried these examples on two computers(both windows 10 system) and get
> same results. And I didn't found same issues on Google or Google Groups.
>
> Any idea how to properly fix this?
>
> Thank you.
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "discuss-webrtc" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to discuss-webrt...@googlegroups.com
> <mailto:discuss-webrt...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/discuss-webrtc/1fd3bd5a-3379-4727-9c12-b88ef445149e%40googlegroups.com
> <https://groups.google.com/d/msgid/discuss-webrtc/1fd3bd5a-3379-4727-9c12-b88ef445149e%40googlegroups.com?utm_medium=email&utm_source=footer>.

Arnon Kahani

unread,
May 26, 2020, 1:19:36 PM5/26/20
to discuss-webrtc
Hi,

I ran into the same problem in video_loopback.exe.

In release build I don't experience this kind of problems, only in debug build.


I run the code from the terminal in the exact same way for the 2 builds.

Any suggestions?

Matilda R Harper

unread,
Sep 30, 2020, 2:27:23 AM9/30/20
to discuss-webrtc
Hi, 
I met this same problem, I have 2 webcams( 1 old webcam and 1 new webcam just bought ). the old webcam works fine. but once I switched to the new camera. webrtc crashed on 
CaptureInputPin::Receive()
RTC_DCHECK_RUN_ON(&capture_checker_);   <----- this line.

After checking, I confirm that on windows 10, sometimes, CaptureInputPin::Receive will run on difference thread. at beginning, it runs on 'A' thread, but after a seconds, the 'A' thread exits and 'B' thread call in.

so, I think this is a webrtc bug.

Rafael Soares

unread,
Oct 30, 2024, 4:52:29 AMOct 30
to discuss-webrtc
Yeah, i also found this error in WebRTC source code when using windows video capturer native implementation in debug, its clear a bug in native webrtc source code.

I'm using version m98
Reply all
Reply to author
Forward
0 new messages