medallyon / eso-discord-status

Sync your semi-live variables from your ESO client to your Discord Status using Rich Presence.
https://www.esoui.com/downloads/info2054-DiscordStatusUpdater.html
GNU Affero General Public License v3.0
12 stars 3 forks source link

ESO Client never appears after instantly closing Bethesda.net_Launcher.exe #35

Closed AngelusMortiel closed 2 years ago

AngelusMortiel commented 3 years ago

Hey @Medallyon,

I'm trying to see if I can capture some kind of evidence about what is happening here exactly on a technical level, but to explain the layman's observation on what I see happening:

  1. Launch Discord
  2. Launch ESO DRP client (set to auto-close ESO launcher and auto-close itself when ESO closes)
  3. Launch ESO "launcher" (via Steam)
  4. Click 'Play" in launcher.
  5. ESO does not appear to launch. Checking task manager shows ESO has launched but is "Suspended" in WIndows. DRP client is still running.
  6. Taskkill ESO and DRP client closes (as expected).

This does not happen under two conditions:

My theory here is that the function that kills the ESO launcher may need to simply have a delay added after the game is launched. I don't know C# very well specifically and don't know the inner workings of ESO, but I do know from my experience PowerShell scripting that sometimes adding a pause is needed to give time for a "launcher" application to pass an authentication/license token of some kind into the application proper before killing the launcher (e.g. verifying game is "authentic"). It could be that my system is possibly a bit slow and the DRP client kills the launcher before the ESO application received a "token" from the launcher. Thus, the ESO application suspends itself indefinitely, awaiting that "token" from the now-closed launcher.

<!--StartFragment-->
if (this.EsoIsRunning)
{
    this.EsoRanOnce = true;
    if ((bool)this.Settings.Get("CloseLauncher"))
    {
        processes = Process.GetProcessesByName("Bethesda.net_Launcher");
        if (processes.Length &gt; 0)
     <!--Insert a "Thread.Sleep()" or "Task.Delay()" here?-->
        processes[0].Kill();
    }
<!--EndFragment-->

Thoughts?

medallyon commented 3 years ago

Seems very plausible from your investigation. If you have the time, you could try contributing a fix for this. Otherwise, it may take a while for me to get around to this.

AngelusMortiel commented 3 years ago

@Medallyon I'm getting around to playing with this, although I'm not well-versed on C#... As I mentioned before, my experience comes from PowerShell (very different, but with similar elements). I'll run with the theory I posed originally to see if that works.

The change I'll be testing looks like this:

<!--StartFragment-->

if (this.EsoIsRunning)
{
    this.EsoRanOnce = true;

    if ((bool)this.Settings.Get("CloseLauncher"))
    {
        processes = Process.GetProcessesByName("Bethesda.net_Launcher");
        if (processes.Length > 0)
        {
            <!--Adding Thread.Sleep() method here-->
            Thread.Sleep(10000);
            processes[0].Kill();
        }
    }

    if (!this.JustMinimized)
    {
        this.JustMinimized = true;
        this.Minimize();
    }

    this.UpdateStatusField("ESO is running!\nYour status is being updated.", Color.LimeGreen);
}

<!--EndFragment-->
medallyon commented 2 years ago

Let me know if the newest release fixes this behaviour for you!

AngelusMortiel commented 2 years ago

@Medallyon So, yes, the issue appeared resolved with the 0.4.4 update.

Unfortunately, more recent updates have broken the client in different ways that are unrelated to this particular bug report. I opened a new issue report for that.