0neGal / viper

Launcher+Updater for TF|2 Northstar
https://0negal.github.io/viper
GNU General Public License v3.0
151 stars 21 forks source link

bug: Invalid config file #211

Closed mikko0808 closed 11 months ago

mikko0808 commented 11 months ago

whenever i open viper to launch northstar it either tells me that the config file has been edited, wich is impossible considering that i don't know where it is, or it doesn't recognize that northstar is installed and it prompts me to install it, and when i try to launch it it doesn't work

0neGal commented 11 months ago

The config file problems is a known problem, and I've yet to find a fix, due to me being unable to reproduce the issue on my own machine. But generally, either click the "OK" button in the popup and it should delete the config file, which resets the config. Or you can manually delete it at %APPDATA%/viper.json

As for Northstar not being detected as installed, is it possible it's trying to auto-detect your Titanfall install and picking an older install or similar? Either way, you can manually select the game path in the Viper tab in the side (first icon), then click "Change Game Path", and afterwards find and select your game path.

Also, make sure your Windows user (assuming you're on Windows) has write access to wherever the game is.

mikko0808 commented 11 months ago

I've tried doing both, but even that didn't work, so i also unins9and reinstalled both Northstar and viper but that doesn't fix it either

0neGal commented 11 months ago

I currently cant really help with the config file problem, as it is an ongoing bug that I myself cant reproduce (if I could, would've been fixed ages ago), when the alert of it not being able to load it correctly pops up, could you however check if the file (%APPDATA%/viper.json) even exists, and if so, copy and paste the content of it in here. And if it doesn't exist, just let me know as such.

As for the game not launching, when clicking the launch button, could you check in the task manager to confirm whether anything is being launched, such as NorthstarLauncher.exe, the EA App (or Origin if you're still using that), or Titanfall itself. And further, does it work if you simply manually open the NorthstarLauncher.exe program inside the folder for the game, manually.

mikko0808 commented 11 months ago

I'll try, if i can help in any way with figuring the config file issue out tell me

Thanks for your time

0neGal commented 11 months ago

When the error alert comes up, go ahead (without closing the alert) and check if a file named viper.json exists in the %APPDATA% folder, if it does, copy paste it's contents here (simply open it in Notepad), and if it doesn't just let me know as such.

That's about the best you can really do to help, but any help is appreciated!

mikko0808 commented 11 months ago

Viper.json seems to not exist in the %APPDATA% folder. I am currently reinstalling Titanfall 2.

AndyDandyMan commented 11 months ago

Just chiming in but I'm experiencing the same issues as OP in regards to Viper reporting my config file as corrupt upon initial launch, and failing to recognize Northstar's install location. My Viper installation also prompts me to install Northstar every time I launch it. Clicking "Install" though causes it to recognize it...and the application fails to fully close itself out, so each time I have to find its entry in the Task Manager and force quit it.

These happen both upon initial launch, as well as each subsequent launch, and have persisted across several clean install attempts (The "corrupt config file" issue though so far only appears the first time after a clean install for me).

Below are the contents of my viper.json file, which I could find at C:\Users\\AppData\Roaming (I neglected to confirm whether this file was present prior to me launching Viper for the first time or not. If that's an issue please let me know and I will attempt another clean install):

{
    "gamepath": "",
    "lang": "en-US",
    "nsupdate": true,
    "autolang": true,
    "forcedlang": "en",
    "autoupdate": true,
    "originkill": false,
    "nsargs": "-multiple",
    "zip": "/northstar.zip",
    "excludes": [
        "ns_startup_args.txt",
        "ns_startup_args_dedi.txt"
    ]
}

Screenshot 2023-09-08 185415 Screenshot 2023-09-08 185512

TBirdSoars commented 11 months ago

My game at least launches with Viper, but I'm getting the same config file and Install button problems. The config issue happens roughly every 4th or 5th launch of Viper, so I decided to delete the file then watch how it gets created and edited in notepad++:

  1. Deleted viper.json, launched Viper. viper.json is created with the following:

    {"gamepath":"","lang":"en-US","nsupdate":true,"autolang":true,"forcedlang":"en","autoupdate":true,"originkill":false,"nsargs":"-multiple","zip":"/northstar.zip","excludes":["ns_startup_args.txt","ns_startup_args_dedi.txt"]}
  2. Closed Viper and reopened. viper.json is edited with the following:

{"gamepath":"","lang":"en-US","nsupdate":true,"autolang":true,"forcedlang":"en","autoupdate":true,"originkill":false,"nsargs":"-multiple","zip":"C:\\Users\\Terry\\AppData\\Roaming\\vipertmp\\northstar.zip","excludes":["ns_startup_args.txt","ns_startup_args_dedi.txt"]}
  1. Closed Viper and reopened, file was edited but remained the same:
{"gamepath":"","lang":"en-US","nsupdate":true,"autolang":true,"forcedlang":"en","autoupdate":true,"originkill":false,"nsargs":"-multiple","zip":"C:\\Users\\Terry\\AppData\\Roaming\\vipertmp\\northstar.zip","excludes":["ns_startup_args.txt","ns_startup_args_dedi.txt"]}
  1. Closed Viper and reopened. Now I get the error: Screenshot 2023-09-11 182431

Also, after doing this and closing Viper, there's often at least one Viper process that continues running at ~10% CPU usage.

Edit: I can't reproduce this when running from npm run start 🤷

TBirdSoars commented 11 months ago

Looks like the issue, at least for the Install button, is related to https://github.com/0neGal/viper/commit/4dce627ee4c74c16c0e4cba3d974458da4d5700d

I reverted that commit and I get the following in viper.json upon installing:

{
    "gamepath": "F:\\ORIGIN\\Titanfall2\\",
    "lang": "en-US",
    "nsupdate": true,
    "autolang": true,
    "forcedlang": "en",
    "autoupdate": true,
    "originkill": false,
    "nsargs": "-multiple",
    "zip": "C:\\Users\\Terry\\AppData\\Roaming\\vipertmp\\northstar.zip",
    "excludes": [
        "ns_startup_args.txt",
        "ns_startup_args_dedi.txt"
    ]
}

and subsequent debug runs display the Launch button instead. Using the latest release eventually breaks it with the config error.

0neGal commented 11 months ago

My current guess (I've yet to test this completely), is that the renderer and main process are trying to read and or write to the config file at the same time. Testing is needed to confirm this.

Were this to be the issue, then it could easily be fixed by never reading the config file in the renderer, and instead simply getting it through IPC.

I however dont quite know why this commit https://github.com/0neGal/viper/commit/4dce627ee4c74c16c0e4cba3d974458da4d5700d is causing further breakage... More investigation would be needed.

0neGal commented 11 months ago

The errors that appear in the invalid config alert have never really made sense, as the config files that I've gotten never have any errors in their formatting, so it's quite likely that it fixes itself in some form or fashion by the time the user is checking the config file.

This build has an extra part added to that alert, that part being what the renderer read the config file as, which likely does in fact contain an error in it. If someone could cause the alert to appear, and then screenshot or copy the contents of the alert, then that'd be helpful.

Once again, I have never been able to reproduce this bug myself, it's likely due to sheer luck and or a race condition based around the main and renderer process both doing things with the config file. So others helping with this bug is quite important :p

0neGal commented 11 months ago

Edit: I can't reproduce this when running from npm run start 🤷

Huh, I guess this explains everything then, running the AppImage for me will eventually cause the error (albeit not in any way shape or form predictably)

I only use Viper through npm run, thanks for this observation... With the build above (tho as an AppImage) the new part of the alert is empty, aka, the file is "empty", likely due to the main process writing to it...

0neGal commented 11 months ago

The latest couple commits should now fully fix all the issues in here and more, but please, do test that, as I could've easily missed something. An up-to-date build is available here

TBirdSoars commented 11 months ago

If I delete viper.json and start fresh with that build, I get:

{
    "gamepath": "F:\\ORIGIN\\Titanfall2\\",
    "lang": "en-US",
    "nsupdate": true,
    "autolang": true,
    "forcedlang": "en",
    "autoupdate": true,
    "originkill": false,
    "nsargs": "",
    "zip": "/northstar.zip",
    "excludes": [
        "ns_startup_args.txt",
        "ns_startup_args_dedi.txt"
    ]
}

on the first launch. It gives me the Install button, which doesn't seem to change anything since Northstar is already installed, and then it becomes the Launch button.

Running again retains the Launch button and viper.json gets this:

{
    "gamepath": "F:\\ORIGIN\\Titanfall2\\",
    "lang": "en-US",
    "nsupdate": true,
    "autolang": true,
    "forcedlang": "en",
    "autoupdate": true,
    "originkill": false,
    "nsargs": "-multiple",
    "zip": "C:\\Users\\Terry\\AppData\\Roaming\\vipertmp\\northstar.zip",
    "excludes": [
        "ns_startup_args.txt",
        "ns_startup_args_dedi.txt"
    ]
}

I've also rerun the latest release until the error appears, breaking viper.json, then running this new build, which restores the gamepath.

This build seems to work. The startup is slower, but maybe that's just because I normally use the install version? Hopefully @AndyDandyMan and @mikko0808 can test this as well.

0neGal commented 11 months ago

This build seems to work. The startup is slower, but maybe that's just because I normally use the install version?

Great that it seems to fix the issues!

I do believe the portable builds created by electron-builder are inherently slower on startup, as I believe they extract the app's resources to a temporary folder on disk. This is of course an extra thing that has to be done on startup, and is therefore slower.

However, I don't fully know whether that's the answer to this problem, as I don't know all the ins and outs of electron-builder, you could however test the speed of npm run start, or similar to somewhat confirm or deny this.

AndyDandyMan commented 11 months ago

So I completely uninstalled Viper, as well as my copy of Titanfall 2 + northstar, did a fresh reinstall of TF2 and launched it once to test it....and then installed the new Viper build.

Launched Viper the first time, and made copies of viper.json before & after clicking "Install": both had the same output:

{
    "gamepath": "D:\\Steam\\steamapps\\common\\Titanfall2",
    "lang": "en-US",
    "nsupdate": true,
    "autolang": true,
    "forcedlang": "en",
    "autoupdate": true,
    "originkill": false,
    "nsargs": "",
    "zip": "/northstar.zip",
    "excludes": [
        "ns_startup_args.txt",
        "ns_startup_args_dedi.txt"
    ]
}

I then close and reopen Viper: no prompt to relocate my install location or any error prompt(s), and the "Launch" button is present, as it should be, install of the "Install" button. I then made copies again of viper.json before & after clicking the "Launch" button: both had the same output:

{
    "gamepath": "D:\\Steam\\steamapps\\common\\Titanfall2",
    "lang": "en-US",
    "nsupdate": true,
    "autolang": true,
    "forcedlang": "en",
    "autoupdate": true,
    "originkill": false,
    "nsargs": "-multiple",
    "zip": "C:\\Users\\<MyUserName>\\AppData\\Roaming\\vipertmp\\northstar.zip",
    "excludes": [
        "ns_startup_args.txt",
        "ns_startup_args_dedi.txt"
    ]
}

Maybe something will break again after enough tries, but so far so good.

0neGal commented 11 months ago

Given the consensus seems to be that the issue is now resolved, I'll be closing this, and creating a new release with this fix, hopefully fixing the problem once and for all.

Remember not to stay on the debugging builds shared in here, they do not auto update, and should not be considered a regular version of Viper! :)

Edit: 1.8.5 has now been released with the fix for this!