You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for creating this .NET implementation of Spout2. I'm not sure if it's my configuration or what, but I believe I've followed the instructions correctly and I am getting the following Error, at "sender.SendImage" when I try run it.
System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
Regularly I've seen that if the architecture was incorrect, but my build config is set to x64 per the ReadMe.
I get this too but at random. Some times I do, other times I dont. I'll try to figure out if theres a way to workaround it
Edit: Took a look and there is no consistent way to detect that it is broken. some times some values of the Spout instance are 01010101.... when its broken but not always. Some some times SendImage will not fail, but only send a black image anyways.
Something has to be going wrong in the construction phase of something because when it does work once, reusing the same instances will consistently work 100% of the time.
I have a similar issue. Although from the testing I have conducted on my machine so far, it seems that I can reliably make it work or crash. If I set Serilog to output to console Spout works, at least I did not yet have it throw the exception in this case. If I set it to output to a file, it will throw, also reliably as of my current observations.
I presume the different logging outputs change something about the timing, but I could not narrow it down any further as of yet.
I was unable to find an exact cause, but I have switched from using a managed byte array to using memory obtained by Marshal.AllocHGlobal. This has seemingly resolved my issue.
Specifically what I am now doing that seems to work is allocate using AllocHGlobal at the start of the program and retaining the memory, then LockBits of the bitmap, and copy that over into the allocated memory using Buffer.MemoryCopy, then UnlockBits and finally passing the pointer of the allocated memory to SendImage.
Specifically what I am now doing that seems to work is allocate using AllocHGlobal at the start of the program and retaining the memory, then LockBits of the bitmap, and copy that over into the allocated memory using Buffer.MemoryCopy, then UnlockBits and finally passing the pointer of the allocated memory to SendImage.
It's been a while, but I'm facing this issue as well. @YaF3li could you share the relevant parts of your code please?
@JanMisker I also eventually came up with that implementation and that does still error out occasionally for me - Tho it worked more consistently from what I remember
Activity
HolgerFoerterer commentedon Oct 22, 2022
I get the same issue here. Could you resolve the issue in February?
kinsi55 commentedon Feb 16, 2023
I get this too but at random. Some times I do, other times I dont. I'll try to figure out if theres a way to workaround it
Edit: Took a look and there is no consistent way to detect that it is broken. some times some values of the Spout instance are 01010101.... when its broken but not always. Some some times SendImage will not fail, but only send a black image anyways.
Something has to be going wrong in the construction phase of something because when it does work once, reusing the same instances will consistently work 100% of the time.
YaF3li commentedon Jun 3, 2023
I have a similar issue. Although from the testing I have conducted on my machine so far, it seems that I can reliably make it work or crash. If I set Serilog to output to console Spout works, at least I did not yet have it throw the exception in this case. If I set it to output to a file, it will throw, also reliably as of my current observations.
I presume the different logging outputs change something about the timing, but I could not narrow it down any further as of yet.
YaF3li commentedon Jun 7, 2023
I was unable to find an exact cause, but I have switched from using a managed byte array to using memory obtained by
Marshal.AllocHGlobal. This has seemingly resolved my issue.kinsi55 commentedon Jun 7, 2023
I already am kind of doing that - My sent pixels are obtained via LockBits
YaF3li commentedon Jun 7, 2023
Specifically what I am now doing that seems to work is allocate using
AllocHGlobalat the start of the program and retaining the memory, thenLockBitsof the bitmap, and copy that over into the allocated memory usingBuffer.MemoryCopy, thenUnlockBitsand finally passing the pointer of the allocated memory toSendImage.kinsi55 commentedon Jun 7, 2023
Seems like we're having different issues then (See my first comment above). This didnt fix my problem FWIW
nickhudson4 commentedon Dec 11, 2023
For me this happens when I try to convert my bitmap to a JPEG byte array like so
The solution was to change to Bmp format
JanMisker commentedon Sep 10, 2024
It's been a while, but I'm facing this issue as well.
@YaF3li could you share the relevant parts of your code please?
YaF3li commentedon Sep 10, 2024
@JanMisker These should be the relevant extracts:
JanMisker commentedon Sep 10, 2024
Thanks so much @YaF3li
I was doing some more debugging and in the end I managed to do it without an extra buffer, i.e. it's something like
And this works...
kinsi55 commentedon Sep 10, 2024
@JanMisker I also eventually came up with that implementation and that does still error out occasionally for me - Tho it worked more consistently from what I remember