Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deadlock on Dispose #576

Closed
2 tasks done
igvk opened this issue Oct 21, 2021 · 4 comments
Closed
2 tasks done

Deadlock on Dispose #576

igvk opened this issue Oct 21, 2021 · 4 comments
Labels

Comments

@igvk
Copy link

igvk commented Oct 21, 2021

Issue Title

Deadlock condition when Disposing CommandManager

Issue Categories

  • Bug

Version Information

  • Build From Master branch, Commit bae88aa

Steps to Reproduce

Open media file, then close the player

Code

There exists deadlock condition in CommandManager.OnDisposing and ExecuteDirectCommand when there IsDirectCommandPending.
PauseAsync eternally waits for the lock that is held by Dispose in the main thread.

WorkerBase.cs:

        protected virtual void Dispose(bool alsoManaged)
        {
            StopAsync().Wait();

            lock (SyncLock)
            {
            ...
                try { OnDisposing(); } catch { /* Ignore */ }
            ...
        }

        public Task<WorkerState> PauseAsync()
        {
            lock (SyncLock)
            {
            ...
        }


CommandManager.cs:

        protected override void OnDisposing()
        {
            ...
            // wait for any pending direct commands (unlikely)
            this.LogDebug(Aspects.EngineCommand, "Dispose is waiting for pending direct commands.");
            while (IsDirectCommandPending)
                Task.Delay(Constants.DefaultTimingPeriod).Wait();
            ...
        }


CommandManager.Direct.cs:

        private Task<bool> ExecuteDirectCommand(DirectCommandType command, Func<bool> commandDeleagte)
        {
            ...
                    PauseAsync().Wait();
            ...
        }
@dbruning
Copy link
Contributor

I've seen this in a couple of dump files from my customer. Mario, do you have any intention to do a bugfix pass on this library? I would be happy to pay towards your time!

dbruning pushed a commit to velogic/ffmediaelement that referenced this issue Dec 16, 2021
@arq606
Copy link

arq606 commented Feb 16, 2022

Just encountered the same issue. Any hope to get the fix?

@dbruning
Copy link
Contributor

I created a PR. If you can't wait for it to be included the main repo, and you want to build it yourself, my fork velogic/ffmediaelement has a couple of additional changes I had to make to build the dll on my machine.

@stale
Copy link

stale bot commented Apr 18, 2022

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants