Multithreading addon crashing in between window changes
#1
Hi, I've got multi-threading working for my visualization on Ubuntu x86. However, when running on imx6, Kodi crashes while changing windows. In other words, I can select a song and the visualization will work great. When I go back to the main menu the visualization is destroyed and is supposed to be recreated. But somewhere after the visualization being destroyed and before the new vis creation, Kodi crashes. crashlog

How can I go about troubleshooting this? My best guess is that when the vis unloads some threads are still working. When the vis reloads the same thread pool is used and there's a segfault. Any way to be sure and prevent this from happening? Is there a better way to off load the curl calls so they're not blocking the music and waveform?

Source here: visualization.wavforhue (pertinent code is in Main_gles.cpp.

Thanks!
Reply
#2
Status: Working on imx6 and Ubuntu. Crashing on Android randomly. Crashing on Windows after addon destroy.

Anyone know a good way to troubleshoot thread problems? The Android system log and the Kodi log are not helpful.

Binaries here: https://github.com/hardyt/visualization....tag/v0.0.3
Reply
#3
Anyone a threading guru here? I've tried seven different ways to implement this and all of them crash for various reasons.

Here is the barebones source code of multithreading in a visualization addon (it's a really easy read). https://github.com/hardyt/visualization....c/Main.cpp But even this fails... Is threading in a visualization not allowed in Kodi?

Thank you!
Reply
#4
I think your problem are the globals. You can't initialize globals in a shared lib like you do in this code.
Reply
#5
FernetMenta, thanks! That was insightful. But a quick test resulted in the same error. I even moved the thread initialization out of create / start, but I still get an abort from Kodi. The abort happens a little bit later.

Edit 1: I updated the code in post #3.
Edit 2: Just to clarify, every official visualization at https://github.com/xbmc/xbmc/tree/Isenga...alizations initializes globals outside of functions with the exception of what I looked at in Vortex. I'm not understanding why it would not work with an atomic bool, but have adjusted anyway as it was an excellent idea.
Edit 3: I updated the code in post #3 above. It appears I have multithreading working in a c++ visualization addon on Ubuntu 64-bit and imx6. It is failing due to a curl problem on Windows. Other platforms have not been tested. The problem was conceptualizing the states that Kodi uses for visualizations. From my viewpoint as a 3rd party, I have absolutely no idea what is going on! But safely checking the state of the thread in five different places seems to have worked.
Reply

Logout Mark Read Team Forum Stats Members Help
Multithreading addon crashing in between window changes0