-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework SingleProcess app code #1345
Conversation
…1 (so it works with our other libraries)
This PR conflicts with |
This PR doesn't conflict with |
src/NexusMods.ProxyConsole.Abstractions/NexusMods.ProxyConsole.Abstractions.csproj
Outdated
Show resolved
Hide resolved
tests/NexusMods.ProxyConsole.Tests/NexusMods.ProxyConsole.Tests.csproj
Outdated
Show resolved
Hide resolved
On Linux, the process doesn't exit after closing the main window. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the plan was to:
- If no arguments and no main ui process -> make current process Main and show UI
- If no arguments and a main ui process exists -> do nothing (we can have this open a new window in the future)
- If has cli arguments and there is no UI process -> start a second process to become main but don't show window, connect and wait for results
- if has cli arguments and there is a main UI process -> connect to that and wait for results.
Rather than requiring app to have UI running when CLI is invoked, I would actually do the opposite. CLI commands only work if UI is not present, which seems to me the more likely use case.
Then we do a separate executable for NXM Handling (I think you mentioned MacOS requires a separate binary anyways).
….Abstractions.csproj Co-authored-by: erri120 <erri120@fossmailer.de>
Co-authored-by: erri120 <erri120@fossmailer.de>
Co-authored-by: erri120 <erri120@fossmailer.de>
Co-authored-by: erri120 <erri120@fossmailer.de>
Co-authored-by: erri120 <erri120@fossmailer.de>
…s.csproj Co-authored-by: erri120 <erri120@fossmailer.de>
Dang it! You're right, there's nothing in these changes that should make that happen, so back to figuring that out I guess. |
-- So really it's about starting a new app when run from the commandline. I'm fine with getting some input on that from others. |
…lifetime management
Excluding NXM links, other CLI commands basically replicate what UI can do but through CLI. Main use case would be that you don't want to use UI or can't use UI. E.g. "uninstall" command that @Sewer56 is reimplementing that is required to clean up game installs at uninstall time. That command can't work if it requires app to be open during uninstall. Other CLI commands can be useful for Tests, where we don't really want the UI to be running. I think we want to support CLI commands without UI being already open, not necessarily in this PR, but specifically for Uninstall we are going to need this. |
Co-authored-by: erri120 <erri120@fossmailer.de>
Okay the app exits now, I had replaced the Avalonia lifetime before, and didn't remove it with this PR. Switched back to the normal lifetime and made sure that the app calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception when starting the App.
The capacity may not be smaller than the file size. (Parameter 'capacity'))
---> System.ArgumentOutOfRangeException: The capacity may not be smaller than the file size. (Parameter 'capacity')
at System.IO.MemoryMappedFiles.MemoryMappedFile.VerifyMemoryMappedFileAccess(MemoryMappedFileAccess access, Int64 capacity, SafeFileHandle fileHandle, Int64 fileSize, Boolean& isRegularFile)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateCore(SafeFileHandle fileHandle, String mapName, HandleInheritability inheritability, MemoryMappedFileAccess access, MemoryMappedFileOptions options, Int64 capacity, Int64 fileSize)
at System.IO.MemoryMappedFiles.MemoryMappedFile.CreateFromFile(FileStream fileStream, String mapName, Int64 capacity, MemoryMappedFileAccess access, HandleInheritability inheritability, Boolean leaveOpen)
at NexusMods.SingleProcess.MultiProcessSharedArray..ctor(AbsolutePath path, Int32 itemCount) in /ssd-pool/projects/NexusMods/app/code-review/src/NexusMods.SingleProcess/MultiprocessSharedArray.cs:line 65
at NexusMods.SingleProcess.SyncFile..ctor(ILogger`1 logger, ISettingsManager settingsManager) in /ssd-pool/projects/NexusMods/app/code-review/src/NexusMods.SingleProcess/SyncFile.cs:line 21
I think this code doesn't work: NexusMods.App/src/NexusMods.SingleProcess/MultiprocessSharedArray.cs Lines 39 to 46 in ce5ec8f
|
The exception gets thrown when the file already exists, but the file size is greater than what we desire. Ideally, the code should resize the file, but it doesn't do that. |
NXM handler also doesn't work anymore. It did before. |
This was a strange one, but I got it fixed, it really has nothing to do with the size of the file, but that the memory map routine demands that we map the whole file. Switched that out and it no logner errors |
Also did a ton of testing of how the protocol handler code worked, we were putting the sync file in a strange place (temp folder) so I moved it into app local on windows. Also cleaned up how we did the mapping and got rid of a struct. It all works now, or at least it does on Windows and it didn't when I started. |
Good point on the uninstall command, I'll add in the options for no-gui and starting the main app from the CLI in the morning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NXM handler seems to be working again, and the process now exists properly 5 seconds after the window closes.
{ | ||
var lower = (ulong)port; | ||
var upper = (ulong)processId << 32; | ||
Value = lower & upper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that this should've been |
which is why the code wasn't working 😅. Sad to see the struct go, but whatever.
This PR conflicts with |
Since this PR has been open for 2 days at this point, I'm going to merge it and open the remaining two items as a new item/PR: #1360 |
This PR doesn't conflict with |
What this PR does:
CommandLineConfigurator
and hands it any CLI requests it gets. No bouncing between threads handlers, etc. Infact the entire Director/handler system is goneThe workflow (at least for now) is:
Error cases:
Tested on Windows and OSX to make sure we still run the main window from the main thread (this is a unique error case in OSX)
Resolves #965.