Previous topicNext topic

Magic crashes with multiple NDI sources

Questions, comments, feedback, etc.
Post Reply
Lima
Posts: 2
Joined: Wed Jan 27, 2021 10:52 pm

Magic crashes with multiple NDI sources

Post by Lima »

I have problems with NDI and Magic keeps crashing. Here are videos I recorded.

https://youtu.be/VQ-NRcUEWZs
In this video I added NDIMagicReceiver in more than one scene and it breaks the preview when I change the scenes it crashes.

https://youtu.be/-fylQwNSi10
In this video I added NDIMagicReceiver in Scene0 and added Scene0 to Scene1, it breaks the preview but doesn't crash.
However, when I try to add another scene it crashes.

Tried these but still crashes;
Uninstall and reinstalling Magic.
Current Magic Beta version is 2.31b1.
Safe mode with network.
Disabling audio input .
Update graphics drivers.

Tested with OBS NDI output and NDI test pattern.

I'm on Windows 10 64bit, 32GB Ram, AMD Ryzen 9 3900X, NVIDA GeForce RTX 2070 Super.

Hope these issues can be fixed. Please let me know if you need any other information.

Thank you so much for making such an amazing program. I have so much fun with it.
Stay safe!
Sadler
Posts: 1139
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Magic crashes with multiple NDI sources

Post by Sadler »

Same here, now I've checked. Given the error occurs in ntdll.dll, this might indicate a memory allocation bug in the NDI plugins. Given this functionality is an interaction between four systems (MMV, plugins, NDI, source) there's a 25% chance the issue is with Magic. But given Magic (and NDI) is well tested and the NDI plugins not, I'd place my bet on the plugins.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Magic crashes with multiple NDI sources

Post by Magic »

Yes, at some point there will be native support for NDI in Magic, but for now you might have to ask the developer of those NDI plugins (https://spout.zeal.co/). I'm not sure if he's still doing work on them though.
leadedge
Posts: 33
Joined: Fri Mar 06, 2015 6:47 am

Re: Magic crashes with multiple NDI sources

Post by leadedge »

Hello to all.

after I discovered this post, I tested things and found that I could reproduce the crash.

I traced the problem to "glClose" which the plugin gets when you change scenes. Here things were released but values were not set to zero, so they were never re-created and hence the crash.

After some brief testing I found that the rest of the plugin seems to stay alive. But it's not all that simple because NDI network discovery is slow. The plugin takes time to respond when changing scenes and the sender that was selected can change to another. In particular, the list of senders is not refreshed. If a solution is not possible in the plugin code, I think a "Refresh" button could solve that, but I am not sure about retaining the sender that was selected.

Anyway I can make a quick fix to avoid the crash by simply doing nothing on glClose. Although I am sorry to say that this will have to wait a little while. But I don't know what's happening with retaining the sender.

In the meantime, perhaps you could make use of multiple instances of "NDItoSpout.exe", each receiving from a different NDI source, and use the built-in "Spout Receiver" in each scene. Switch between scenes then instantly retains the selected sender.
leadedge
Posts: 33
Joined: Fri Mar 06, 2015 6:47 am

Re: Magic crashes with multiple NDI sources

Post by leadedge »

Here is an update :

https://github.com/leadedge/MagicNDI/re ... tag/v1.013

Please let me know here for either success or problems.

Details - refer to the source.
Sadler
Posts: 1139
Joined: Sat Aug 02, 2014 7:10 pm
Location: London, UK

Re: Magic crashes with multiple NDI sources

Post by Sadler »

More stable here but red and blue channels are swapped?
leadedge
Posts: 33
Joined: Fri Mar 06, 2015 6:47 am

Re: Magic crashes with multiple NDI sources

Post by leadedge »

OK, thanks for that. But I found reversed RGBA/BGRA for some reason, so I changed it pending investigation of NDI versions.

What I will do is change it back to what it was to start with and edit the release rather than doing another one. Stand by and I will advise

I still don't know what is happening though.
Magic
Site Admin
Posts: 3440
Joined: Wed Apr 09, 2014 9:28 pm

Re: Magic crashes with multiple NDI sources

Post by Magic »

Lynn, one thing to be aware of is that glClose is only meant for deleting the texture, not anything else like closing the network connection. The connection should stay alive until the module is deleted (and the destructor is called), or until a new connection is selected in the module. When the scene is changed, glClose is called on the old scene, and glInit is called on the new scene. Thus, glInit should create a new texture in exactly the same format as the previous one. The purpose of this is to manage graphics memory in such a way that only the current scene is loaded on the graphics card, in case the user has very complex scenes or many scenes and they can't all fit in graphics memory at the same time.

You may already be aware of this but I just wanted to put it out there. I haven't looked at your code recently.

Depending on how much work you feel like doing, another tip is that for modules like this which have a connection to something outside the program (like a video camera or a video stream), the connection should be static across all instances of the module. So let's say there are two modules which have the same NDI source -- then there should actually only be one connection that they both use. However, both modules should still have independent GL textures. Know what I mean? To manage the memory of any NDI-related objects, you would use a reference counter that keeps track of how many separate modules are using the same connection, and you only fully close/delete the connection when the count goes down to 0.
leadedge
Posts: 33
Joined: Fri Mar 06, 2015 6:47 am

Re: Magic crashes with multiple NDI sources

Post by leadedge »

Thanks Eric.

I mis-understood that glClose was meant to clean things up before the module closed.

Anyway I have it sorted now, and make sure that things are re-created. Also I discovered that the sender combo box was not refreshed when the second instance was created because there was no network change, so I force that update if glInit has been called.

The bgra/rgba issue has been a long-standing one with NDI and it seems to have re-surfaced. All I can do at the moment is change back to the original code, so I have done that and updated the binaries.

I can't do much more with these modules due to time limitations. If we can get them going OK at this time, hopefully they will do the job for a while.







.
Lima
Posts: 2
Joined: Wed Jan 27, 2021 10:52 pm

Re: Magic crashes with multiple NDI sources

Post by Lima »

I used the updated NDI receiver and it fixed it!! Thank you so so much!!!
Post Reply