zkxs / NeosHighPriority

A Neos VR mod to set the process to high priority
GNU General Public License v3.0
2 stars 1 forks source link

Mod crashes on native Linux #1

Open Scary-Guy opened 1 year ago

Scary-Guy commented 1 year ago

Just for fun I tried it on Linux. This pops up in the log...

4:25:26 PM.477 ( 0 FPS) [ERROR][NeosModLoader] mod NeosHighPriority from ~/.neosvr/nml_mods/NeosHighPriority.dll threw error from OnEngineInit(): System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file

Obviously it wont work for the Linux/Mac crowd and should probably state that in the readme file.

zkxs commented 1 year ago

This is intended to work on all platforms. Is that the full stacktrace? Are you using native Linux, or WINE?

Scary-Guy commented 1 year ago

This is on native Linux, and yeah that is the full error from the Neos log.

zkxs commented 1 year ago

I've got a new build which adds a bunch of debug logging to hopefully figure out what line is throwing the exception, as that stack trace is nearly useless.

This was built on Ubuntu 22.04.2 LTS, not that it should matter, but who knows what M$ is up to.

Anyways: the build

Scary-Guy commented 1 year ago

Here is the relevant part it threw when it tried to load the mod:

10:50:59 PM.015 (  0 FPS)   [ERROR][NeosModLoader] mod NeosHighPriority from /home/user/.neosvr/nml_mods/NeosHighPriority.dll threw error from OnEngineInit():
System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file
  at System.Diagnostics.Process.set_PriorityClass (System.Diagnostics.ProcessPriorityClass value) [0x00049] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.set_PriorityClass(System.Diagnostics.ProcessPriorityClass)
  at NeosHighPriority.NeosHighPriority.OnEngineInit () [0x0002b] in <4c9687694ed84d94ae8a2455c680fe3d>:0 
  at NeosModLoader.ModLoader.HookMod (NeosModLoader.LoadedNeosMod mod) [0x00078] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 

  at System.Environment.get_StackTrace () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0.<Start>b__0 (System.String str) [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at BaseX.UniLog.Log (System.String message, System.Boolean stackTrace) [0x00000] in <8571c37c42c64e4c884b24cd6def6710>:0 
  at NeosModLoader.Logger.LogInternal (System.String logTypePrefix, System.Object message, System.String source) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.Logger.ErrorInternal (System.String message) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ModLoader.HookMod (NeosModLoader.LoadedNeosMod mod) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ModLoader.LoadMods (HarmonyLib.Harmony harmony) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.HarmonyWorker.LoadModsAndHideModAssemblies (System.Collections.Generic.HashSet`1[T] initialAssemblies) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ExecutionHook..cctor () [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at System.Reflection.MonoField.SetValueInternal (System.Reflection.FieldInfo fi, System.Object obj, System.Object value) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngine.EngineInitializer.InitializeConnectorFields (System.Type type, System.Type connectorType, System.Boolean connectorMandatory, System.Type defaultConnector) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.EngineInitializer.InitializeConnectorFields (System.Type type, System.Boolean connectorMandatory, System.Type defaultConnector) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.EngineInitializer.InitializeFrooxEngine (FrooxEngine.Engine engine) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.Engine+<Initialize>d__298.MoveNext () [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngine.Engine.Initialize (System.String appPath, System.String dataPath, System.String cachePath, FrooxEngine.ISystemInfo systemInfo, FrooxEngine.IInternalResource resources, System.Boolean verboseInit) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0+<<Start>b__3>d.MoveNext () [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0.<Start>b__3 () [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecutionContextCallback (System.Object obj) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
zkxs commented 1 year ago

They discuss a similar issue in https://github.com/dotnet/msbuild/issues/5365, and it may be that Linux doesn't let you elevate process priorities without sudo. But if that were the case I'd expect System.ComponentModel.Win32Exception : Permission denied versus the System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file that we're seeing here.

I'm not really able to debug this, as the System.Diagnostics.Process implementation in my System.dll is very clearly Windows-only, implying your System.dll has a completely different implementation.

However, you can test the theory using NeosLowPriority, which helpfully already exists for meme reasons.

Also, I've made another release which adds some more error handling. Don't use 1.0.2, 1.0.3 is where it's at. We now try twice to set the priority. Truly the peak of priority changing software has been reached here. Also, if the issue is High priority not being a real thing on Linux it should emit some interesting logs.

Scary-Guy commented 1 year ago
6:54:39 AM.177 (  0 FPS)    [ERROR][NeosModLoader/NeosHighPriority] Unable to change process priority from BelowNormal to High: System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file
  at System.Diagnostics.Process.set_PriorityClass (System.Diagnostics.ProcessPriorityClass value) [0x00049] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.set_PriorityClass(System.Diagnostics.ProcessPriorityClass)
  at NeosHighPriority.NeosHighPriority.ChangePriority (System.Diagnostics.Process process, System.Diagnostics.ProcessPriorityClass targetPriority, System.String targetPriorityName) [0x00057] in <6dcdff8a09cc4b76aebc815a30c4e69f>:0 

  at System.Environment.get_StackTrace () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0.<Start>b__0 (System.String str) [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at BaseX.UniLog.Log (System.String message, System.Boolean stackTrace) [0x00000] in <8571c37c42c64e4c884b24cd6def6710>:0 
  at NeosModLoader.Logger.LogInternal (System.String logTypePrefix, System.Object message, System.String source) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.Logger.ErrorExternal (System.Object message) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.NeosMod.Error (System.String message) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosHighPriority.NeosHighPriority.ChangePriority (System.Diagnostics.Process process, System.Diagnostics.ProcessPriorityClass targetPriority, System.String targetPriorityName) [0x00000] in <6dcdff8a09cc4b76aebc815a30c4e69f>:0 
  at NeosHighPriority.NeosHighPriority.OnEngineInit () [0x00000] in <6dcdff8a09cc4b76aebc815a30c4e69f>:0 
  at NeosModLoader.ModLoader.HookMod (NeosModLoader.LoadedNeosMod mod) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ModLoader.LoadMods (HarmonyLib.Harmony harmony) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.HarmonyWorker.LoadModsAndHideModAssemblies (System.Collections.Generic.HashSet`1[T] initialAssemblies) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ExecutionHook..cctor () [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at System.Reflection.MonoField.SetValueInternal (System.Reflection.FieldInfo fi, System.Object obj, System.Object value) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngine.EngineInitializer.InitializeConnectorFields (System.Type type, System.Type connectorType, System.Boolean connectorMandatory, System.Type defaultConnector) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.EngineInitializer.InitializeConnectorFields (System.Type type, System.Boolean connectorMandatory, System.Type defaultConnector) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.EngineInitializer.InitializeFrooxEngine (FrooxEngine.Engine engine) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.Engine+<Initialize>d__298.MoveNext () [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngine.Engine.Initialize (System.String appPath, System.String dataPath, System.String cachePath, FrooxEngine.ISystemInfo systemInfo, FrooxEngine.IInternalResource resources, System.Boolean verboseInit) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0+<<Start>b__3>d.MoveNext () [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0.<Start>b__3 () [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecutionContextCallback (System.Object obj) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
6:54:39 AM.180 (  0 FPS)    [ERROR][NeosModLoader/NeosHighPriority] Unable to change process priority from BelowNormal to AboveNormal: System.ComponentModel.Win32Exception (0x80004005): Cannot find the specified file
  at System.Diagnostics.Process.set_PriorityClass (System.Diagnostics.ProcessPriorityClass value) [0x00049] in <ef151b6abb5d474cb2c1cb8906a8b5a4>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.set_PriorityClass(System.Diagnostics.ProcessPriorityClass)
  at NeosHighPriority.NeosHighPriority.ChangePriority (System.Diagnostics.Process process, System.Diagnostics.ProcessPriorityClass targetPriority, System.String targetPriorityName) [0x00057] in <6dcdff8a09cc4b76aebc815a30c4e69f>:0 

  at System.Environment.get_StackTrace () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0.<Start>b__0 (System.String str) [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at BaseX.UniLog.Log (System.String message, System.Boolean stackTrace) [0x00000] in <8571c37c42c64e4c884b24cd6def6710>:0 
  at NeosModLoader.Logger.LogInternal (System.String logTypePrefix, System.Object message, System.String source) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.Logger.ErrorExternal (System.Object message) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.NeosMod.Error (System.String message) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosHighPriority.NeosHighPriority.ChangePriority (System.Diagnostics.Process process, System.Diagnostics.ProcessPriorityClass targetPriority, System.String targetPriorityName) [0x00000] in <6dcdff8a09cc4b76aebc815a30c4e69f>:0 
  at NeosHighPriority.NeosHighPriority.OnEngineInit () [0x00000] in <6dcdff8a09cc4b76aebc815a30c4e69f>:0 
  at NeosModLoader.ModLoader.HookMod (NeosModLoader.LoadedNeosMod mod) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ModLoader.LoadMods (HarmonyLib.Harmony harmony) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.HarmonyWorker.LoadModsAndHideModAssemblies (System.Collections.Generic.HashSet`1[T] initialAssemblies) [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at NeosModLoader.ExecutionHook..cctor () [0x00000] in <309a66cbf7eb42ac970cb1512cd67fd2>:0 
  at System.Reflection.MonoField.SetValueInternal (System.Reflection.FieldInfo fi, System.Object obj, System.Object value) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.MonoField.SetValue (System.Object obj, System.Object val, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Globalization.CultureInfo culture) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object value) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngine.EngineInitializer.InitializeConnectorFields (System.Type type, System.Type connectorType, System.Boolean connectorMandatory, System.Type defaultConnector) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.EngineInitializer.InitializeConnectorFields (System.Type type, System.Boolean connectorMandatory, System.Type defaultConnector) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.EngineInitializer.InitializeFrooxEngine (FrooxEngine.Engine engine) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngine.Engine+<Initialize>d__298.MoveNext () [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngine.Engine.Initialize (System.String appPath, System.String dataPath, System.String cachePath, FrooxEngine.ISystemInfo systemInfo, FrooxEngine.IInternalResource resources, System.Boolean verboseInit) [0x00000] in <a6ff441fca7c4a97bc5b9dca720b524b>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0+<<Start>b__3>d.MoveNext () [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at FrooxEngineRunner+<>c__DisplayClass38_0.<Start>b__3 () [0x00000] in <491392836cc24711bb9f621bd82c72f4>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecutionContextCallback (System.Object obj) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecuteWithThreadLocal (System.Threading.Tasks.Task& currentTaskSlot) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.ExecuteEntry (System.Boolean bPreventDoubleExecution) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.Tasks.Task.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0 
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <9577ac7a62ef43179789031239ba8798>:0

Low priority works though? Or at the very least it's not throwing an error.

6:58:18 AM.975 (  0 FPS)    [INFO] [NeosModLoader/NeosLowPriority] Changed process priority from BelowNormal to Idle

When you get yours working I'll try both for giggles and let them fight it out.

zkxs commented 1 year ago

That confirms this is some sort of Linux permission issue. The hack is to run Neos as root. You can probably also do some sort of arcane Linux configuration to let non-root users elevate process priority.