Issues with the 32 bit support
mateberes opened this issue · 5 comments
HI tsihon!
Great library, I have a project in unreal in which I integrated this library. The 64bit version works flawlessly, I can stream to Discord (from browser) or to Google Meet. But I've realized that the standalone version of discord is still 32bit, so I've tried to add support for as that well.
But it just doesn't work and I'm not sure why. I can see the virtual camera option in the discord camera combobox and I checked the registry for the COM object and the path is correct.
There might be some kind of race condition with the initialization, because sometimes 1 out of 10 it starts working if I attach my VS to both of my running instances and debug it step by step. (Unreal and Discord)
Do you have any idea what could go wrong? Because I have no issues with the 64bit version. And I could even manage to run the 32bit version, but only if I debug it in VS.
I've found one problem where two threads get in a deadlock:
First this lock gets locked:
CAutoLock lock(m_pFilter->pStateLock()); source.cpp:340
ntdll.dll!77ea2a7c() Unknown Non-user code. Cannot find or open the PDB file.
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] Annotated Frame
KernelBase.dll!76d78e89() Unknown Non-user code. Cannot find or open the PDB file.
KernelBase.dll!76d78de2() Unknown Non-user code. Cannot find or open the PDB file.
softcam.dll!CAMEvent::Wait(unsigned long dwTimeout) Line 128 C++ Symbols loaded.
softcam.dll!CAMThread::CallWorker(unsigned long dwParam) Line 178 C++ Symbols loaded.
softcam.dll!CSourceStream::Stop() Line 140 C++ Symbols loaded.
> softcam.dll!CSourceStream::Inactive() Line 359 C++ Symbols loaded.
softcam.dll!CBaseFilter::Stop() Line 334 C++ Symbols loaded.
quartz.dll!205839e0() Unknown Non-user code. Cannot find or open the PDB file.
quartz.dll!20591f22() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!15825251() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!1582519b() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!1555038b() Unknown Non-user code. Cannot find or open the PDB ###file.
discord_voice.node!155558eb() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!154de991() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!154de5c8() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!154b500b() Unknown Non-user code. Cannot find or open the PDB file.
discord_voice.node!154a04f3() Unknown Non-user code. Cannot find or open the PDB file.
Discord.exe!02752332() Unknown Non-user code. Cannot find or open the PDB file.
Discord.exe!02752ae3() Unknown Non-user code. Cannot find or open the PDB file.
Then the other thread tries to access the framebuffer, but it's already locked:
DShowSoftcam.cpp:338
CAutoLock lock(&m_cStateLock);
Not Flagged 17136 0 Worker Thread webrtc_video_capture softcam.dll!CCritSec::Lock
ntdll.dll!77ea477c()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!77e8f999()
ntdll.dll!77e8f6ed()
ntdll.dll!77e7010a()
ntdll.dll!77e6ff59()
softcam.dll!CCritSec::Lock() Line 402
softcam.dll!CAutoLock::CAutoLock(CCritSec * plock) Line 98
softcam.dll!softcam::Softcam::getFrameBuffer() Line 338
softcam.dll!softcam::SoftcamStream::FillBuffer(IMediaSample * pms) Line 415
softcam.dll!CSourceStream::DoBufferProcessingLoop() Line 479
softcam.dll!CSourceStream::ThreadProc() Line 430
softcam.dll!CAMThread::InitialThreadProc(void * pv) Line 123
kernel32.dll!76a300c9()
ntdll.dll!77e97b1e()
ntdll.dll!77e97aee()
From the looks of it SourceStream tries to call Stop(), which is strange because I've just connected to it.
It also looks like SoftcamStream::FillBuffer() is called once but then never again. So this might be the issue, I'm just not sure what's causing it.
Thank you for a detailed report!
Based on your observation, I agree with your guess of a possible race condition.
And I agree that the call stacks are clearly indicating a deadlock!
Reading the code, the first thread gets a lock and waits for the second to respond, but simultaneously, the second attempts to get the lock.
I think the cause is not a 32-bit related.
I will investigate further.
Thank you!
Hi, @mateberes !
I think I have fixed the deadlock issue you spotted.
I hope the situation becomes better.
Hi tshino!
Just applied your change and it looks like it did indeed fix all of my issues. I can now stream to 32 / 64 bit discord clients without any issues.
Wow, you were very fast with the fix, thank you very much for your help!