ffmpeginteropx / FFmpegInteropX

FFmpeg decoding library for Windows 10 UWP and WinUI 3 Apps
Apache License 2.0
210 stars 53 forks source link

How to solve a crash when calling Dispose #348

Closed ZzzzzzzSkyward closed 1 year ago

ZzzzzzzSkyward commented 1 year ago
Exception thrown at 0x00007FF8A4B31F70 (FFmpegInteropX.dll) in BiliLite.exe: 0xC0000005: Access violation writing location 0x0000000000000028.

Relevant code:

{
        FFmpegInteropX.FFmpegMediaSource interopMSS;
        readonly MediaPlayer mediaPlayer;
        private async Task SetPlayer(string url)
        {
            try
            {
                PlayerLoading.Visibility = Visibility.Visible;
                PlayerLoadText.Text = "加载中";
                if (mediaPlayer != null)
                {
                    mediaPlayer.Pause();
                    mediaPlayer.Source = null;
                }
                if (interopMSS != null)
                {
                    interopMSS.Dispose();
                    interopMSS = null;
                }
                interopMSS = await FFmpegMediaSource.CreateFromUriAsync(url, _config);
                mediaPlayer.AutoPlay = true;
                mediaPlayer.Source = interopMSS.CreateMediaPlaybackItem();
                player.SetMediaPlayer(mediaPlayer);
            }
            catch (Exception ex)
            {
                Utils.ShowMessageToast("播放失败" + ex.Message);
            }

        }
        private void StopPlay()
        {
            if (mediaPlayer != null)
            {
                mediaPlayer.Pause();
                mediaPlayer.Source = null;
            }
            if (interopMSS != null)
            {
                  interopMSS.Dispose();
                  interopMSS = null;
            }
}
yikuo123 commented 1 year ago

https://www.nuget.org/packages/FFmpegInteropX/1.1.0-pre42

Did you have a try with 1.1.0-pre42?

brabebhin commented 1 year ago

Unfortunately i cannot report with this code sample. Can you provide a complete sample?

As mentioned above, try the latest preview package. It contains a bunch of bug fixes over the official version and it's practically just as stable.

ZzzzzzzSkyward commented 1 year ago

I updated to 1.1.0-pre42 and there is no crash. Thanks.

https://www.nuget.org/packages/FFmpegInteropX/1.1.0-pre42

Did you have a try with 1.1.0-pre42?