SuRGeoNix / Flyleaf

Media Player .NET Library for WinUI 3/ WPF/WinForms (based on FFmpeg/DirectX)
GNU Lesser General Public License v3.0
716 stars 102 forks source link

multiplayer sometimes will hang on and crash #107

Closed swimfish09 closed 2 years ago

swimfish09 commented 2 years ago

multiplayer open rtmp stream, after some time later, the application hang on.

SuRGeoNix commented 2 years ago

Hey @swimfish09, I've never tried rtmp and I can't find easily a sample url for testing. Can you provide one? (even private drop me an email)

If you can't, try to find more information. Check ffmpeg's rtmp protocol options and Master.RegisterFFmpeg with 64/AV_LOG_MAX_OFFSET.

Update: Managed to found this one rtmp://62.113.210.250/medienasa-live/rbw_high , currently works fine with single and I will try multiplayer as well (with same url though) (how much time after?)

Find one more rtmp://62.113.210.250/medienasa-live/ok-merseburg_high and tested those two with Test/FlyleafMultiplayer for 5 minutes so far with 4 players no issues... I will let it play about 30'

image

Couldn't find any issue, give me some more information to know where to look at (which version did you use? master or nuget latest?)

swimfish09 commented 2 years ago

I use nuget latest version. Maybe it's my ffmpeg version is 4.3.1,I will change it and check later.

SuRGeoNix commented 2 years ago

You shouldn't use different version from ffmpeg.autogen that library uses (it's 4.4+ now). Re-open this if you have issues but provide more details.

swimfish09 commented 2 years ago

Hi @SuRGeoNix, I tried the latest code with Test/FlyleafMultiplayer, and set debug on. Only the first player debug message is correct., others seems wrong. image

SuRGeoNix commented 2 years ago

Hi @swimfish09, yep that was another bug with master thread. Just fixed it.

Do you still have hang issues?

swimfish09 commented 2 years ago

Actually still exist. Especially when i open 16 players and switch windows back and forth to maximize restore. With intel graphics card is good, with nvidia graphics card the window will hang on.

SuRGeoNix commented 2 years ago

Have you tried any other application with 16 players and worked properly? You could try to Pause them all before Full/Normal screen. You could also try to reduce video frame even more to 2 if you have VRAM issues. If you provide more details about the 'hang on', event logs / flyleaf logs (from the debugger) I might be able to help.

swimfish09 commented 2 years ago

Ok, I will keep investigating it.

swimfish09 commented 2 years ago

Windows log


System.Collections.Generic.KeyNotFoundException
   System.ThrowHelper.ThrowKeyNotFoundException()
   System.Collections.Generic.Dictionary`2[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].get_Item(Int32)
   FlyleafLib.MediaFramework.MediaDemuxer.Demuxer.UpdateCurTime()
   FlyleafLib.MediaFramework.MediaDemuxer.Demuxer.RunInternal()
   FlyleafLib.MediaFramework.RunThreadBase.Run()
   System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   System.Threading.ThreadHelper.ThreadStart()
SuRGeoNix commented 2 years ago

Some other people come up with this issue at the past again. But I wasn't able to identify why it is happening. This is the related line code:-

if (CurPackets.TryPeek(out IntPtr firstPacketPtr) && ((AVPacket*)firstPacketPtr)->dts != AV_NOPTS_VALUE)
   firstPacketTs = (long) (((AVPacket*)firstPacketPtr)->dts * AVStreamToStream[((AVPacket*)firstPacketPtr)->stream_index].Timebase);

Can you help me reproduce it to understand what is going on exactly? I could add the try/catch again but I would prefer to understand why is this happening because it could cause more issues.

You use latest nuget and your rtmp or the rtmp urls that I sent you? Does this happening only with multiplayers?

Update: I think I see it now. It's probably a race condition between the Demuxer and the Decoder packet. I will fix it with the next update.

swimfish09 commented 2 years ago

Yes I use latest nuget. From now, it's happened only with multiplayers, Especially with 16 players.