emoacht/Monitorian

Calling from an external progams causes a failure

ajitid opened this issue · 6 comments

I am essentially calling monitorian /set <displayid> <num> command from Golang. And when I call it many times in succession I get this:

Named pipe client failed.
System.AggregateException: One or more errors occurred. ---> System.IO.IOException: Pipe is broken.
   at System.IO.Pipes.PipeStream.WinIOError(Int32 errorCode)
   at System.IO.Pipes.PipeStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Pipes.PipeStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.set_AutoFlush(Boolean value)
   at StartupAgency.PipeHolder.<ConnectServerAsync>d__17.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
   at System.Threading.Tasks.Task1.get_Result()
   at StartupAgency.PipeHolder.Create(String[] args)
---> (Inner Exception #0) System.IO.IOException: Pipe is broken.
   at System.IO.Pipes.PipeStream.WinIOError(Int32 errorCode)
   at System.IO.Pipes.PipeStream.WriteCore(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Pipes.PipeStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.set_AutoFlush

After which calling monitorian commands from CLI doesn't give me any output. I have to restart monitorian to get output. The tray windows work as usual though.

I have a monitor attached to a laptop and both have separate working screens.

Thank you for reporting.
How many and how often have you sent the commands?

I'm just pressing my keyboard arrows to invoke them so really not too many. The easiest way to reproduce this is to first call monitorian /get with a display id followed by a monitorian /set with an id and do this again and again. Another thing that I've noticed is sometimes monitorian /get gives -1 as the brightness during these invocations.

If you just want to change the brightness from keyboard, keyboard shortcut is more appropriate. -1 means the value cannot be obtained.

What are the possible causes when value can't be obtained (cli gives -1 even when monitorian is properly functioning)?

A monitor is unexpectedly delicate. It easily fails to respond to a command typically immediately after power on and resume. It all up to each monitor.

Ah ok. I don't have anything else to add beside that I was using SDL2 and when I put a logic to cap framerate, the issue stopped happening. So I can't pinpoint what causes this really apart from the symptoms I described above.

PS: I have deleted my comment on Defer change until stopped. Feel free to delete yours too.