CrendKing / avisynth_filter

DirectShow filters that put AviSynth and VapourSynth into video playing
MIT License
106 stars 8 forks source link

Random hanging #41

Closed PhantomGamers closed 3 years ago

PhantomGamers commented 3 years ago

Environment

Describe the bug

After watching a video for a period of time (it doesn't seem very consistent, sometimes it happens within 5 minutes, sometimes within 15, ~15 minutes tends to be the longest), with madVR the video frame freezes but the audio continues to play, and pausing the video and replaying it causes it to start playing video again but no longer at the interpolated framerate (not positive what is happening here, is it SVP's script? avisynth filter? avisynth+? How can I find out?) When using EVR the entire player just crashes. I have zero problems using SVP with just ffdshow (well, as far as crashes/hanging goes).

I'd love to figure out how to get this working as the one major change over ffdshow that helps so much for the experience is that with ffdshow, the video will freeze for a bit after AR changes and SVP's black bar detection kicks in. With avisynth filter it transitions nearly seamlessly.

I thought maybe this could have been related to #24 but I've tried messing with the CPU and GPU queue sizes and it seems to happen regardless of what they are set to.

I should also mention that I tried it with the AvySynth+ version that gets installed by SVP (3.5 I think?), and it also occurred there, I manually updated it to 3.7.0 seeing that it had improvements for multithreading and thought maybe it would help, but alas it did not.

Checklist

avsf.zip (log file)

PhantomGamers commented 3 years ago

FYI, I fixed issue 24, which could help eliminating some hang. You might want to try.

With this version I get this error immediately on loading the video, and it pops up again immediately after if clicking continue.

ASSERT Failed height == abs(videoFormat.bmi.biHeight) At line 213 of D:\Development\C++\DirectShow\avisynth_filter\avisynth_filter\src\format.cpp

dump avsf.log

@ssssssbbb You can generate an avsf log file by following https://github.com/CrendKing/avisynth_filter/wiki/How-to-enable-logging As for the dump file, you have to use Visual Studio and go to the Debug tab at the top and then attach to process and select your video player process. Not sure if it matters but what I do is open the video player without any video, attach the debugger, and then load the video and reproduce the hang. After the hang, I press the pause button in the Visual Studio toolbar at the top and then go to the Debug menu and select "Save dump as" to save the dump file, and then I zip it up (because these files are usually very large) and upload it to mega. You can use any file host that can support the file size (google drive, mega, pixeldrain, etc)

CrendKing commented 3 years ago

Sorry. The issue 24 version has a bug. That could cause some crashes you guys experience and the ASSERT fail error.

Hopefully this should have fixed the problem. Let me know. avisynth_filter_64.zip

@ssssssbbb QQ和度盘海外速度实在太慢,抱歉。

@PhantomGamers Unless I explicitly request, you don't need to upload the huge dump file for issues other than hang.

PhantomGamers commented 3 years ago

That version seems to have fixed something as it no longer hangs in the specific part it was hanging in prior, and I can't even get it to hang 100% of the time throughout the entire section but sometimes it does. Here is one instance:

dump avsf.log

CrendKing commented 3 years ago

Thanks. It looks like madVR just hang for no apparent reason. Does EVR hang too?

ssssssbbb commented 3 years ago

@PhantomGamers Thanks, seems it's too complicated for me to create a dump file. I know nothing about Visual Studio. 0409.log

@CrendKing Here is the log, it didn't even start playing, PotPlayer freezed with OSD showing "Opening". It's a little different from the former versions, this time it didn't turn "no response" , after I closed PotPlayer through the taskbar icon, the UI was gone but the process kept active till I killed it.

Tried EVR and got same result.

PhantomGamers commented 3 years ago

Thanks. It looks like madVR just hang for no apparent reason. Does EVR hang too?

I played through the section a few times in EVR and could not seem to get it to hang

CrendKing commented 3 years ago

@ssssssbbb PotPlayer works fine here, so it could be a separate issue. Please create a new issue and follow the instruction to provide some info.

@PhantomGamers Good to hear. The last dump you uploaded basically shows that avsf delivered a video frame to madVR. madVR internally called some functions and eventually waited for some locks. Since madVR is not open sourced, we don't know what's happening. You could do two things:

1) Try to capture another dump and upload. We can see if we could spot a different cause of hang. 2) Send that dump to madVR somehow (they used to have an issue tracker). They might be able to figure it out.

PhantomGamers commented 3 years ago

I opened up a bug report with madVR here: http://bugs.madshi.net/view.php?id=667

So we'll see what they say. I'll post another dump next time I trigger a hang.

CrendKing commented 3 years ago

I managed to find a way to repro the hang you experienced. It is because unlike EVR, when being queried for media type change, madVR calls to source filter (most likely LAV Splitter) for its connection media type. This call tries to acquire LAV filter's lock, and consequently form a chain of dead lock.

Specifically,

Main thread: holds LAV m_csFilter, blocked on LAV m_csReceive Streaming thread: holds LAV m_csReceive, blocked on avsf m_csReceive avsf worker thread: holds avsf m_csReceive, blocked on LAV m_csFilter <- this is where the hang occurred

In contrast, EVR doesn't seem to make that call, thus no dead lock formed.

Now, I'm not saying this is a bug in madVR. They could do it for good reason. On my hand, I could change my logic to do output format change differently. It may take some time to try different approaches. So I might release a new version with this as a known issue.

Again, if you happen to find a hang with different cause, please follow up.

ssssssbbb commented 3 years ago

I found some detials, it seems to be related to the video encode format? 2 HVC1 encoded clips hang here and another hang randomly. H264 and AVC1 clips hang randomly just like before. All random hanging become much more frequent when switching among play/pause, minimize/fullscreen, forward/backward and haste/slow, I used hotkey.

Maybe it's still the same source with this issue, since it didn't stuck with HVC1 clips in that version I mentioned before.

Should I upload the magnent link of the trouble clips here?

PhantomGamers commented 3 years ago

madshi requested that I use the debug symbols for avisynth filter in order to make a freeze report more useful to them.

Is the codebase on github up to date? Can I just build it rn and use the debug symbols and ax from my build? If not can you post the debug symbols for the version you want me to be testing on?

CrendKing commented 3 years ago

I believe I fixed all hangs in this version, including the one madVR one I just mentioned. Please try.

avisynth_filter_64.zip

@ssssssbbb If the clip is copyrighted, please do not upload here. You could send me private message in Doom9.

ssssssbbb commented 3 years ago

H264 is OK now. HVC1 is still the same. 0411.log

Email sent failed, maybe due to the GFW...

I will contact U in ThemeX.

Go forward/backward in H264 clips very frequently and got this. If U can't find out what's wrong, ignore it since it's not a common problem CatchC3F9(04-11-19-00-46)

CrendKing commented 3 years ago

@ssssssbbb Fixed the bug. Try the link above again.

ssssssbbb commented 3 years ago

@CrendKing Quick test is OK now. I will do more tests. Thanks!!!

Error sometimes occurs when going Forward/backward, the hex address is identical each time. 1

CrendKing commented 3 years ago

avisynth_filter_64.zip might fix it. "Might" because I don't know the cause of that unless you can give me more info (in a separate issue please).

ssssssbbb commented 3 years ago

avisynth_filter_64.zip might fix it. "Might" because I don't know the cause of that unless you can give me more info (in a separate issue please).

It's worse, hangs much easier.

New issue created.

PhantomGamers commented 3 years ago

I believe I fixed all hangs in this version, including the one madVR one I just mentioned. Please try.

I managed to catch a hang with this version as well: dump avsf.log

CrendKing commented 3 years ago

This is the other madVR hang that I can't do anything about. You might want to report to madshi.

I will upload a whole package with debug symbols, so that you can give them more info, when I release the next version.

For now, if no other hang happens anymore, and EVR works without problem, please close the issue for me.

CrendKing commented 3 years ago

You can find the debug package here: https://github.com/CrendKing/avisynth_filter/releases/tag/v0.10.0