designer-living / sunshine_utils

Apache License 2.0
69 stars 6 forks source link

Playnite crashing with Ultrawide monitor #5

Open clucas127 opened 11 months ago

clucas127 commented 11 months ago

The application seems to be working as it should on the PC end, but on my TV where I am running Playnite through Moonlight, the resolution quickly changes back to 5120x1440 and then the Moonlight session crashes

CorneliousJD commented 11 months ago

The application seems to be working as it should on the PC end, but on my TV where I am running Playnite through Moonlight, the resolution quickly changes back to 5120x1440 and then the Moonlight session crashes

I had this issue as well, but it was because the playnite desktop app was running on my PC.

I fixed this by adding another command to Sunshine to kill the desktop app first - that way it prevents this issue. taskkill /IM Playnite.DesktopApp.exe /F

image

CorneliousJD commented 11 months ago

Actually my above command only works IF playnite desktop is running, then it kills it properly and proceeds, if it's not running then it fails and the moonlight session doesn't start because it can't kill the process. I likely need to replace this with a script...

CorneliousJD commented 11 months ago

Ok, scripting it works.

My new DO command to kill the desktop is C:\Users\Corey\Documents\Moonlight\killplaynite.bat

@ECHO OFF
@ECHO Killing Playnite Desktop App
SET ThisScriptsDirectory=%~dp0
SET PowerShellScriptPath=%ThisScriptsDirectory%killplaynite.ps1
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%PowerShellScriptPath%'";

Then in the same directory of C:\Users\Corey\Documents\Moonlight\ I have a "killplaynite.ps1" (powershell script)

$playnite = %{
    $checkFullScreen = get-process "Playnite.FullscreenApp" -ErrorAction SilentlyContinue; 
    $checkDesktop = get-process "Playnite.DesktopApp" -ErrorAction SilentlyContinue;
    if ($checkFullScreen) {
        Write-Output "already running";
        }
    else {
        if ($checkDesktop) {
            Stop-Process -Force $checkDesktop.id;
            sleep -Seconds 5;
            }
    }
}

Thanks to /u/jimmt42 on reddit for his post here that led me in the right direction, and I just slightly modified his script. https://www.reddit.com/r/SteamDeck/comments/zomblc/comment/j8r96zc/?utm_source=reddit&utm_medium=web2x&context=3

image

clucas127 commented 11 months ago

@CorneliousJD awesome, thanks for your reply! I will test this out as soon as I can.

CorneliousJD commented 11 months ago

@CorneliousJD awesome, thanks for your reply! I will test this out as soon as I can.

No problem, sorry for all the back/forth on it, I was trying to overcome the same issue, but just re-tested a bunch with the .bat and .ps1 combo and that seems to be working great no matter how I start and kickoff the streaming, so far so good!

Let me know how it goes for you - if it works I'll probably upload it to a repo for others to find later for this exact case.

clucas127 commented 11 months ago

@CorneliousJD The resolution changed appropriately on my PC, but Playnite failed to start and I got error code-1.

CorneliousJD commented 11 months ago

@CorneliousJD The resolution changed appropriately on my PC, but Playnite failed to start and I got error code-1.

Is the error code -1 coming from moonlight or somewhere else?

If you're able to provide screenshots of your setup/config and scripts, etc, I might be able to help point you in the right direction for a fix.

clucas127 commented 11 months ago

@CorneliousJD it's coming from Moonlight. I am using Moonlight on an Nvidia Shield TV Pro connected to a 4K TV. My PC is connected to a 32:9, 5120x1440 monitor.

I have copied your scripts verbatim. Is there any other details I can provide? image

CorneliousJD commented 11 months ago

@CorneliousJD it's coming from Moonlight. I am using Moonlight on an Nvidia Shield TV Pro connected to a 4K TV. My PC is connected to a 32:9, 5120x1440 monitor.

I have copied your scripts verbatim. Is there any other details I can provide?

Can you swap your DO commands and UNDO commands?

DO Commands Line 1: C:\PATH\TO\killplaynite.bat Line 2: C:\PATH\TO\resolution_change.exe -p 800p (or whatever res you want)

UNDO Commands Line 1: Blank Line 2: C:\PATH\TO\resolution_change.exe -r

For example mine are DO C:\Users\Corey\Documents\Moonlight\killplaynite.bat C:\Users\Corey\Documents\Moonlight\resolution_changer\resolution_change.exe -p 800p -d "\.\DISPLAY1" --detach-other-monitor

UNDO -blank- C:\Users\Corey\Documents\Moonlight\resolution_changer\resolution_change.exe -r

clucas127 commented 11 months ago

@CorneliousJD this works briefly but then the resolution switches right back and the Moonlight session ends :/ I really appreciate all your help by the way!

CorneliousJD commented 11 months ago

If you start with Playnite desktop closed (check your systray by your clock to make sure it's not running there at all) does it work when launching the first time (you can take the killplaynite.bat out of the loop for this test)

If you're still having trouble with playnite closed to start off then something else is going on and unrelated to what I thought it might be.

My specific issue was that it would fail if playnite was open, but work if it was closed to start off, thus the script to force-kill playnite first so it would work 100% of the time.

So give that a test and try first to make sure we're seeing the same problem here, if not then you have something else going on and I've been leading you on a wild chase for nothing ;)

clucas127 commented 11 months ago

@CorneliousJD no my Playnite is set to close after I launch an app anyways so it's not normally running in the background. I tested taking the bat out of the loop and saw the same result, so definitely unrelated haha

foxy82 commented 11 months ago

Do the sunshine logs give you any clues?

Specifically for my app you can add --debug then the window won't close after you urn it so you can see if there are any errors there.

clucas127 commented 11 months ago

@foxy82 when I put the debug in the Do command it stopped moonlight from connecting and playnite from starting. When I put it in the undo I saw the same thing happen, where the resolution updates but then immediately switched back and then Moonlight said the connection was terminated. Here's what the debug window said: image So it seems to me like it is running the Undo command directly after the Do command, even though Playnite is still open.

foxy82 commented 11 months ago

That suggests my util is working so I think the answer would be in the Sunshine logs. You can see these by clicking the "Troubleshooting" menu bar in the Sunshine web interface.

clucas127 commented 11 months ago

@foxy82 This looks like the relevant section:

2023:09:26:10:37:25: Info: SDR color coding Rec. 709: Info: Color range: [JPEG]

2023:09:26:10:37:25: Info: // Ignore any errors mentioned above, they are not relevant. //

2023:09:26:10:37:25: Info: Found encoder nvenc: h264_nvenc, hevc_nvenc: Info: Executing Do Cmd: C:\Program Files\Sunshine\resolution_change.exe -p 4k: Info: C:\Program Files\Sunshine\resolution_change.exe -p 4k running with PID 17672 2023:09:26:10:37:31: Info: Executing: ["C:\Users\CLuca\AppData\Local\Playnite\Playnite.DesktopApp.exe" --hidesplashscreen] in "C:\Users\CLuca\AppData\Local\Playnite": Info: "C:\Users\CLuca\AppData\Local\Playnite\Playnite.DesktopApp.exe" --hidesplashscreen running with PID 21548 2023:09:26:10:37:31: Info: CLIENT CONNECTED 2023:09:26:10:37:31: Info: Executing Undo Cmd: C:\Program Files\Sunshine\resolution_change.exe -r --debug: Info: C:\Program Files\Sunshine\resolution_change.exe -r --debug running with PID 5284

I can paste more if necessary, but the above seems to reflect my theory that it is running the Undo command right away, right?

clucas127 commented 11 months ago

@foxy82 I was able to partially resolve my issue. I mistakenly had the desktop.exe in place of the fullscreenapp.exe. Now Playnite launches in 4K resolution as I would like it too, however when I launch a game the aspect ratio is squished for some reason.

foxy82 commented 11 months ago

Is that all games or just a particular game? Do you only have one monitor?

clucas127 commented 11 months ago

I only have one monitor, but you're right it seems to be on a case-by-case basis. Which is still annoying given I was originally testing with the game I'm currently playing. I do know this game supports both resolutions though, because I've played in both already.

clucas127 commented 11 months ago

I found this reddit thread with some alternative options that are working out better for me. Posting it here for any other's who may come here with the same problem. I appreciate everyone's help!