I see some changes were made recently to the C# bindings, but I still can’t get the PlayGif example to run.
There are issues with some of the others, but I managed to work around them. I thought I would post here rather than making a GitHub issue, as I guess it is probably known (Or it could just be an issue my end). Here is what works and what doesn’t:
BoxesBoxesBoxes - works
FontExample - not tried
MatrixRain - missing System.Threading
This seems to be due to the Console.CancelKeyPresscode -if I comment that out, it works
MinimalExample - works
PlayGIF - missing System.Collections.Concurrent
PulsingBrightness - missing System.Threading (as per MatrixRain)
Otherwise works
Rotating3DCube - missing System.Threading (as per MatrixRain)
inconsistent variable name - leds rather than matrix as other examples use
Otherwise works
The only one I really care about though is PlayGif - would love to see this working.
I am mainly curious if it will play a stream (As created with the -O flag of the led-image-viewer util), or could easily be modified to do so.
OK, so I made some progress on this, I did make some comments on the issue, but I am wary of spamming the issue, so I will post here.
TLDR, it seems like the reason that some of the examples are giving a FileNotFoundException (eg for System.Collections.Concurrent), even though the required DLLs are in the folder is that the library is dropping privs
I was running as root.
I just tried switching to a non-root user (dietpi), but dotnet was installed as root, so dietpi could not run it.
So I tried logging in as dietpi instad, re-installing dotnet (it was installed as root), re-building the library, and trying again, and still the same issue.
However, I did set up dotnet as a “global” install - one copy in /usr/local/share/dotnetand configured things such that dietpi could access this one copy of dotnet.
I am wondering if that is maybe the issue, but at this point I have been trying to fix this for 10 hours when I could have been coding, and I am a bit demoralized.
Can anyone maybe try and see if they get the same issue with PlayGif? Curious if it’s just me.
UserLogger.LogUser("Before maxtrix initialization:");
using var matrix = new RGBLedMatrix(32, 2, 1);
UserLogger.LogUser("After maxtrix initialization:");
Result:
root@DietPi:~/rpi-rgb-led-matrix/bindings/c#/examples/PlayGIF/bin/Debug/net8.0/linux-arm64/publish# sudo ./PlayGIF
Before maxtrix initialization:: User=root, UID=0, EUID=0
Suggestion: to slightly improve display update, add
isolcpus=3
at the end of /boot/cmdline.txt and reboot (see README.md)
After maxtrix initialization:: User=daemon, UID=1, EUID=1
Unhandled exception. System.TypeInitializationException: The type initializer for 'SixLabors.ImageSharp.Configuration' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections.Concurrent, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
--led-no-drop-privs is a universal option. All flags prefixed with --led are. As long as the program is internally calling rgb_matrix::ParseOptionsFromFlags within the executional pathway, it should be supported by all programs including C# samples. That happens in most programs at the top of the main method when they instantiate RGBMatrix and Canvas objects.
EDIT: Actually, just from my quick search of the codebase, it is possible you discovered a bug with the C# bindings. But you’ll have to confirm that with the maintainer or by yourself. But here’s what I see:
Here in the C++, it collects the led-no-drop-privs option as expected.
Here in the C# bindings in these two files, I don’t see this flag being consumed.
So it’s quite possible the bindings for C# have become out-of-date. The last commit for the files was 2 years, ago in C#. For the C++ file, it was 3 weeks ago.
Just from my own experience, I find in terms of quality you will see it goes C++ -> Python -> C# in terms of what’s supported best.
But you may have your issue happening there, and it would require filing a bug to fix it. Preferably linked with this: