Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Issue 430 Multiplayer Exceptions #474

Merged

Conversation

dilandau2001
Copy link
Contributor

@dilandau2001 dilandau2001 commented Oct 22, 2018

As pointed out by some users and suffered in my own projects there were some multithreading issues when multiple viewers are playing inside the same application.
I found most of the issues to be regarding access to very specific dictionaries.
These dictionaries were not thread-safe, and updates to them could end in errors like:
NullReferenceException.
Key not present in the dictionary
and memory access exceptions.

In particular access to:
LoadedMedias and RegisterEvents() in VlcMedia classs
and AllInstances inside VlcMediaInstance

I tested those changes inside an applicacion playing 32 streams simultaneously. Without the changes an exception was fired in less than 12 hours. With the changes the application does work longer. (my isses now are more related to libVlc leaking memory,)

…rder to make access to those resources, thread safe.
@jeremyVignelles
Copy link
Collaborator

Good work, never had time to fix that myself. Can you have a look at my comments and improve your PR?

I will need to test after that.

@jeremyVignelles
Copy link
Collaborator

Linking to possibly related issues #430 #460 #464

@dilandau2001
Copy link
Contributor Author

dilandau2001 commented Oct 23, 2018

You could have locked the list itself right? what's the best practice around this?

Well, my first go was just locking the list but I found that the call to "RegisterEvents" was also non thread safe it was redundant to have 2 locks around. Having a single lock into the constructor was enough.

Guillermo Alías Delgado added 4 commits October 23, 2018 19:28
Update with comments of the pull request.

Lock access to "LoadedMedias", RegisterEvents and "allInstances" in order to make access to those resources, thread safe.
…001/Vlc.DotNet into Issue430_MultiPlayerExceptions
@dilandau2001
Copy link
Contributor Author

Ok, I have updated the code with all the comments and squash it in the last commit.

@jeremyVignelles jeremyVignelles merged commit edf4cd8 into ZeBobo5:develop Oct 24, 2018
dilandau2001 added a commit to dilandau2001/Vlc.DotNet that referenced this pull request Oct 24, 2018
@dilandau2001 dilandau2001 deleted the Issue430_MultiPlayerExceptions branch October 25, 2018 15:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants