brunoherbelin / vimix

Live Video Mixer
GNU General Public License v3.0
282 stars 27 forks source link

Vimix crashes from OSC data stream (from Chataigne) with "Segmentation fault (Core dumped)" #149

Open ThomZenTury opened 1 month ago

ThomZenTury commented 1 month ago

Hi again!

I don't know if this belongs here since it is a combination of Vimix and Chataigne. Chataigne is used with sequences to control some shader uniforms in Vimix. This works basically but most of the time as soon as I play a sequence in Chataigne vimix crashes with the error

Segmentation fault (Core dumped)

The same goes for an OSC stream of floats that are sent from an Android phone (Unity App that delivers Accelerator and Magnetic Field data from the sensors).

After a little research I came up with two ideas:

  1. maybe the OSC float data from Chataigne is just to long (> 15 digits after comma)
  2. maybe a sync problem as Chataigne is not sending in a special syncronized way as far as I can see

As for the length of the data I tried to shorten the floats by script in Chataigne but a simple JS "toFixed()" is not supported. I tried to get in contact with them last week but no answer so far.

For syncing I have no idea where to start.

I also thought that maybe @lupin3rd - whose Chataigne module I am using - had similar issues. Did you?

As always I would be highly grateful for some ideas where to dig for solutions.

Have a nice day!

brunoherbelin commented 1 month ago

Now looking at this issue, I must admit I didn't manage to replicate it.

This may be a good news as I did recently make an OSC compilation fix that was related to management of floating point parameters; the bug may be fixed.

However, if you still encounter it, I would need to replicate it. For doing stress-tests of OSC, I made this bash script;

#!/bin/bash

max=1
if (( $# > 0 )); then
    if (( $1 > 1 )); then
        max=$1
    fi
fi

while :
do
   echo -n "."
   for s in $(seq 0 $max); do
        oscsend localhost 7000 /vimix/#$s/alpha f "0.$((RANDOM%9999))"
        oscsend localhost 7000 /vimix/#$s/gamma f "0.$((RANDOM%9999))"
        sleep 0.01
   done
   sleep 0.1
done

To run it from the terminal, copy-paste the code into a text file, e.g. saved with the filename osc_test, and run it in the command line (with the max index of sources as argument), e.g.;

bash osc_test 5

This will indefinitely set random alpha and random gamma values for all sources until index #5.

Replacing the OSC target in the file allows testing different commands. I tested with uniform and it seems to work. Let me know if you still encounter the bug in the last Beta.

lupin3rd commented 1 month ago

Hi at all, i send a lot of OSC messages to Vimix on my shows with chataigne without problems:

https://github.com/user-attachments/assets/410748a9-bb9c-41c6-b81d-489e95a5bbff

ThomZenTury commented 1 month ago

Thank you for the very useful script! I did a few different testing scenarios today and I am still encountering this problem.

What I tested so far:

  1. Everything that I've tried with your handy script was successful in terms off no crashes, no hickups, nothing. I changed all sorts of sources, parameters, uniforms and even the timeout in the script to send the messages faster. Running it for 3-5 minutes per change, no crashes.

  2. Instead of Chataigne I was using "Open Stage Control" for quite a while now. With custom Javascript modules I successfully map incoming Midi Values from my hardware controllers to OSC messages in several directions, for example to Vimix. So I mapped my midi controller to custom uniforms in Vimix and there - after a while of turning the knobs - the "Segmentation fault" appeared again and Vimix crashed. I couldn't reproduce the crash when I mapped the midi knobs to vimix inbuilt parameters like "alpha" etc. Mapped to custom uniforms it's a question of time until the crash happens. Unfortunately not always the same amount of time.

  3. Just an observation and maybe not related: an already existing OSC message stream (e.g. from playing a uniform sequence from Chataigne or turning a midi knob constantly) while starting Vimix crashes Vimix immediately with the same segmentation error.

So, I would say it's not software specific outside of vimix. Both apps Chataigne and OpenStageControl lead to the same crashes. I would also say that it's not hardware specific as it happens both with the midi controller and e.g. sequences that are played from Chataigne.

Careful! Now it's about my "feeling" that I have about causing the crashes. It seems that it's liklier to happen if I control two custom uniforms simultaneously / at the same time. It does not happen immediately but pretty sure after some time (<2 minutes) of changing two uniforms / turning two knobs at the same time. The simple mind guesses: A sync problem? A sort of buffer that is filling up?

As always, I would be happy to read from you and get any idea how to proceed further.

Have a nice day!

brunoherbelin commented 1 month ago

Hello there!

There were indeed causes for error with asynchronous set of uniforms (your point 2, i.e. receiving OSC message is not happening in sync with rendering, therefore crashing if by bad luck, vimix is reading the uniform for rendering with opengl at the same time OSC is writing it). It is now resolved in Beta c4ad80f3b9bcb3d251b471676eb404647ae918f4 .

For point 3, there was another problem which is now fixed too. Thanks for your precise indications : this made it easy to replicate and fix!

And thanks for the tip with Open Stage Control : it is a neat piece of software that integrates well with vimix! If you have some examples to share, I could add it to the doc at https://github.com/brunoherbelin/vimix/wiki/OSC-Mapping

ThomZenTury commented 1 month ago

Hi again! I haven't tested so far but wanted to let you know that I finally started a little vimix tutorial series on youtube. Very beginner friendly I would say. https://www.youtube.com/watch?v=Vemf499wpUs&list=PLEky5KQSvdTiofKvdcbXkwmPlWi-lTPpT

Open Stage Control will be a part of that and as soon as I have some tidy presets I will gladly share them here.

I will check on the uniforms soon.

Have a nice day!

brunoherbelin commented 1 month ago

Thanks Thomas! Love it!

Making videos and recording myself is something I am not comfortable with, but it is a very good way to share online and many users find interesting info and guidelines for software on youtube! So thank you for that ! Also its a good idea to start with compiling, even if not everyone will need it, but it is good to have the tutorial video as not everyone would dare doing it even if its in fact not difficult! Well done! Looking forward to seeing the next episodes :+1:

PS: and yes I'm French :)

ThomZenTury commented 1 month ago

I'm really glad you like it!

I think after everything you offer here and how fast and thoroughly you treat our issues it is the least I could do (finally!). And besides, I wouldn't do these clips if Vimix wouldn't just be so much fun to work with. It fits perfectly to my weird process of combining all sorts of devices and approaches. Or better, it makes some of them possible in the first place. So, again, with all honesty, thank you, Bruno!

I still haven't tested the uniform issue, but I will as soon as I finish some more parts of the yt series.

Have a nice day!

brunoherbelin commented 1 month ago

Wouah! You have been busy !! I travelled for 2 days and there is now 10 video tutorials! This is so great!

I couldn't wait to add this to the wiki: https://github.com/brunoherbelin/vimix/wiki/Video-tutorials

Thanks a lot! Happy to reference more if you can :smile:

ThomZenTury commented 1 month ago

Hi Bruno!

Indeed there should be two more available now and I am looking forward to do even some more. I'm relly glad you like them. It encourages to do more.

Also, if you want me to show specific aspects of Vimix please let me know. On the list are:

Have a nice weekend!

P.S.: With the next clip I definitely will have a look into my uniform issue that started all the fun here.