robvdpol / RaceControl

Race Control is a standalone, open source F1TV client for Windows, written in C# on the .NET platform.
GNU General Public License v3.0
1.19k stars 95 forks source link

[BUG] App crashes while loading streams #123

Open Tralapo opened 3 years ago

Tralapo commented 3 years ago

Describe the bug Race Control 2.2.0 sometimes crashes completely when loading my layout in the internal player. I have been opening/closing Spain P2 live like 10 times now since it started and about 4-5 times the crash happend. All video players and Race Control itself close, without an error message.

This issue is not happening with MPV.

Desktop (please complete the following information):

F1TV account

Additional context My Layout file:

{
  "Instances": [
    {
      "Top": 0.0,
      "Left": 0.0,
      "Width": 1280.0,
      "Height": 720.0,
      "FullScreen": false,    
      "ResizeMode": 0,
      "VideoQuality": 0,      
      "Topmost": true,
      "IsMuted": false,
      "Volume": 100,
      "Zoom": 0,
      "AudioTrack": "eng",
      "AspectRatio": "Keep",
      "ChannelName": "WIF"
    },
    {
      "Top": 720.0,
      "Left": 0.0,
      "Width": 640.0,
      "Height": 360.0,
      "FullScreen": false,    
      "ResizeMode": 0,
      "VideoQuality": 1,      
      "Topmost": true,
      "IsMuted": true,
      "Volume": 0,
      "Zoom": 0,
      "AudioTrack": "eng",
      "AspectRatio": "Keep",
      "ChannelName": "TRACKER"
    },
    {
      "Top": 720.0,
      "Left": 640.0,
      "Width": 640.0,
      "Height": 360.0,
      "FullScreen": false,    
      "ResizeMode": 0,
      "VideoQuality": 1,
      "Topmost": true,
      "IsMuted": true,
      "Volume": 0,
      "Zoom": 0,      
      "AudioTrack": "eng",
      "AspectRatio": "Keep",
      "ChannelName": "DATA"
    },
    {
      "Top": 0.0,
      "Left": 1280.0,
      "Width": 640.0,
      "Height": 360.0,
      "FullScreen": false,    
      "ResizeMode": 0,
      "VideoQuality": 1,      
      "VideoQuality": 1,      
      "Topmost": true,
      "IsMuted": false,
      "Volume": 90,
      "Zoom": 0,      
      "AudioTrack": "und",
      "AspectRatio": "Keep",
      "ChannelName": "Max Verstappen"
    },
    {
      "Top": 360.0,
      "Left": 1280.0,
      "Width": 640.0,
      "Height": 360.0,
      "FullScreen": false,    
      "ResizeMode": 0,
      "VideoQuality": 1,      
      "Topmost": true,
      "IsMuted": true,
      "Volume": 0,
      "Zoom": 0,      
      "AudioTrack": "eng",
      "AspectRatio": "Keep",
      "ChannelName": "Charles Leclerc"
    },
    {
      "Top": 720.0,
      "Left": 1280.0,
      "Width": 640.0,
      "Height": 360.0,
      "FullScreen": false,    
      "ResizeMode": 0,
      "VideoQuality": 1,      
      "Topmost": true,
      "IsMuted": true,
      "Volume": 0,
      "Zoom": 0,      
      "AudioTrack": "eng",
      "AspectRatio": "Keep",
      "ChannelName": "Lando Norris"
    },
  ]
}

And the error log, which does not seem to include any error or warning. This is from when I started the app, loaded the layout in the internal player and it crashed:

2021-05-07 15:24:54.0976 INFO Settings loaded.
2021-05-07 15:24:54.1364 INFO Video dialog layout loaded.
2021-05-07 15:24:54.1364 INFO Found VLC installation at 'C:\Program Files\VideoLAN\VLC\vlc.exe'.
2021-05-07 15:24:54.1364 INFO Found MPV installation at 'C:\Program Files\Race Control\mpv\mpv.exe'.
2021-05-07 15:24:54.1804 INFO Credentials loaded from store.
2021-05-07 15:24:54.1804 INFO Sending authorization request for login 'xxxxxxxx'...
2021-05-07 15:24:54.6519 INFO Login successful.
2021-05-07 15:24:54.6623 INFO Credentials saved to store.
2021-05-07 15:24:54.6801 INFO Querying seasons...
2021-05-07 15:24:54.6801 INFO Querying vod genres...
2021-05-07 15:24:54.6950 INFO Refreshing live sessions...
2021-05-07 15:24:54.6950 INFO Querying live sessions...
2021-05-07 15:24:54.6950 INFO Checking for updates...
2021-05-07 15:24:54.6950 INFO Getting latest release from Github...
2021-05-07 15:24:54.8688 INFO No new release found.
2021-05-07 15:24:55.0274 INFO Querying events for season '2021 season'...
2021-05-07 15:24:57.2258 INFO Querying channels for session with UID '1000004018'...
2021-05-07 15:24:58.7838 INFO Getting tokenised URL for content-type 'Channel' and content-URL 'CONTENT/PLAY?contentId=1000004018'...
2021-05-07 15:25:00.0271 INFO Getting tokenised URL for content-type 'Channel' and content-URL 'CONTENT/PLAY?channelId=1003&contentId=1000004018'...
2021-05-07 15:25:01.1677 INFO Getting tokenised URL for content-type 'Channel' and content-URL 'CONTENT/PLAY?channelId=1004&contentId=1000004018'...
2021-05-07 15:25:02.2989 INFO Getting tokenised URL for content-type 'Channel' and content-URL 'CONTENT/PLAY?channelId=1009&contentId=1000004018'...
2021-05-07 15:25:03.4251 INFO Getting tokenised URL for content-type 'Channel' and content-URL 'CONTENT/PLAY?channelId=1008&contentId=1000004018'...
2021-05-07 15:25:04.5843 INFO Getting tokenised URL for content-type 'Channel' and content-URL 'CONTENT/PLAY?channelId=1016&contentId=1000004018'...
robvdpol commented 3 years ago

Please check the Event Viewer -> Windows Logs -> Application. There should be an error there.

Tralapo commented 3 years ago

I see two entries around that time:

RaceControl.exe 
   2.2.0.0 
   60513887 
   KERNELBASE.dll 
   10.0.19041.906 
   2f2f77bf 
   e0434352 
   0000000000034b59 
   38fc 
   01d743445cd208b1 
   C:\Program Files\Race Control\RaceControl.exe 
   C:\WINDOWS\System32\KERNELBASE.dll 
   791cde36-f095-4a28-9538-fc50b1294532 
Application: RaceControl.exe CoreCLR Version: 5.0.521.16609 .NET Version: 5.0.5 Description: The process was terminated due to an unhandled exception. Exception Info: System.NullReferenceException: Object reference not set to an instance of an object. at FlyleafLib.MediaFramework.MediaDecoder.AudioDecoder.ProcessAudioFrame(AVFrame* frame) at FlyleafLib.MediaFramework.MediaDecoder.AudioDecoder.DecodeInternal() at FlyleafLib.MediaFramework.MediaDecoder.DecoderBase.Decode() at FlyleafLib.MediaFramework.MediaDecoder.DecoderBase.<StartThread>b__34_0() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location --- at System.Threading.ThreadHelper.ThreadStart() 
SuRGeoNix commented 3 years ago

@robvdpol Even if this one also seems to be on my side in AudioDecoder.cs at the following lines

AudioFrame mFrame = new AudioFrame();
mFrame.pts = frame->best_effort_timestamp == AV_NOPTS_VALUE ? frame->pts : frame->best_effort_timestamp;
if (mFrame.pts == AV_NOPTS_VALUE) return null;
mFrame.timestamp = ((long)(mFrame.pts * AudioStream.Timebase) - AudioStream.StartTime) + cfg.audio.DelayTicks + (AudioStream.StartTime - decCtx.VideoDecoder.VideoStream.StartTime);

The problem seems to be the audio stream itself. It is either not full identify which means that you need to parse AVFormatOptions and increase the following values (Possible when a user opens a lot of players at the same time?)

config.demuxer.VideoFormatOpt.Add("probesize",(50 * (long)1024 * 1024).ToString());
config.demuxer.VideoFormatOpt.Add("analyzeduration",(10 * (long)1000 * 1000).ToString());

Note: if you increase those values possible you will have general delays opening urls, so do it only in cases that is actually needed

Or just a faulty audio stream that you shouldn't select possible check CodecName. You need to reproduce it.

robvdpol commented 3 years ago

Yes this happens when opening a layout with multiple players at the same time. I already have a 1 second delay between opening the players but I might even wait until the stream is playing before opening the next. Would that fix this issue?

SuRGeoNix commented 3 years ago

Yes, I think that would resolve it if that is the issue. However, you could even start them in parallel and increase only for those players the analyzeduration/probesize (30 seconds analyze duration maybe?) which will allow you to open them faster at the same time. You need to test those scenarios.