streetpea / chiaki-ng

Next-Generation of Chiaki (the open-source remote play client for PlayStation)
https://streetpea.github.io/chiaki-ng/
GNU Affero General Public License v3.0
1.16k stars 75 forks source link

Remote play on console has crashed #38

Closed khalara84 closed 9 months ago

khalara84 commented 1 year ago

Was using chiaki4deck since Christmas, and just a day or two ago it starts giving me this error when trying to connect to my ps5. I haven't seen anyone else talking about the issue, so I thought I'd see if there was anything up here. I've tried uninstalling it from the deck, restarting the ps5, router, and pc. I hope I can get this sorted out!

EDIT Okay, so I tested remote play from my PC with the official app and it worked just fine. Went back to my steam deck and chiaki worked just fine. No idea what is goin on with that.

streetpea commented 1 year ago

@jbaiter have you seen anything like / have an idea what would cause this from reverse engineering the protocol to support haptics?

jbaiter commented 1 year ago

I've been getting this two or three times when reversing the haptics protocol, but I could never reliably reproduce it. Putting the console manually into rest mode and then powering it on again always fixed it for me, but this is ofc not always possible. This is probably going to be pretty hard to debug without a reliable way of reproducing it 😬

@khalara84 If you can find a way to reliably trigger this crash, could you maybe enable debug logging before triggering another crash and upload that somewhere? Maybe we can find something in there that gives us a clue to what is happening.

cgarst commented 1 year ago

I'm getting this error a ton this week with Chiaki4deck too. It seems that once I get it with Chiaki4deck, I'm unable to connect with official iOS app until the PS5 rests. Otherwise, the iOS app is still working.

streetpea commented 1 year ago

@cgarst you have described 2 things

  1. Launching chiaki4deck is causing remote play on the console to crash
  2. Once the remote play server on the console crashes, remote play can’t be used until you reset the console

Afaik (2) is unavoidable bc once the remote play server on the console crashes, it doesn’t reset automatically. Chiaki, the official PlayStation app, etc. are all clients for that server so if the server isn’t working they are sol.

Based on the reports in this issue, the remote play server crashing in the 1st place (1) seems to be due to an issue with Chiaki (most likely related to the upgrades to add haptics in chiaki/chiaki4deck).

Unfortunately, I am not able to currently replicate the issue. @cgarst since you can semi-reliably replicate the issue it would be very helpful if you could enable debug logging (clicking the check mark in the gui) and post a log of when the remote play server crashes (logs should be in the directory: /home/deck/.var/app/re.chiaki.Chiaki4deck/data/Chiaki/Chiaki/log). This would need to be when the crash happens instead of after the crash when you can’t connect. This would help us figure out the cause of the issue and fix it.

cgarst commented 1 year ago

Naturally I turned on logging after hours of crashing the server and now it's worked several times in a row haha.

I'll keep this on and watch for it.

khalara84 commented 1 year ago

chiaki_session_2023-01-29_01-53-14-121121.log

khalara84 commented 1 year ago

Not sure if my log will be any help. Sorry if it isn't. I hope this can be fixed!

jbaiter commented 1 year ago

@khalara84

khalara84 commented 1 year ago

Can you lead me through this process for debug? I only turned on logging and gave the log on what happens when I try to remote play. I'll see about the other conditions later when I can get to it.

charsu commented 1 year ago

hi , I can confirm the above issue too on my PS5 . it started happening after version 1.2.x + (1.3.x) was released in mid December (including gyro...) .

As far I can tell , it is related to the PS5 automatically going to sleep due to power saving settings and afterwards trying to connect for remote play with chiaki4deck , leads to a brief connection the the PS5 ( eg i can see the screen showing the ps5 background) then an error message and afterwards unable to use remote play on that PS5 with no other client (eg chiaki, chiaki4deck , PS official remote client app , other android apps (probably based on chiaki code) ....) , so in other words it seems to kill the PS5 remote service ...

Important bits :

side note : really great work on getting this done and honestly am impressed by the high standard of setting it up (docs + release + feature implementation and dedication )

streetpea commented 1 year ago

@khalara84 would it be possible to attach a log of it working to compare to on your system?

I noticed from the verbose messages that you already have debug logging on in your log and It seems like the only thing that could cause this crash that comes from chiaki itself would be the session request. Since ctrl hasn't even started when remote play crashes on the server (and it is remote play crashing on the PlayStation server not Chiaki) as the session request is rejected because of the crash causing a 403 server error, I don't think anything else can really come into play yet. It may be helpful to see if maybe something is changing in the session request from a good session to a bad session. Normally, the session requests should stay the same given the same connection which is why comparing a good / bad run of yours could make sure there isn't a change.

Note: I let my PS5 go into sleep mode via power saving and woke it up, based on the comment from @charsu but didn't get the crash.

Another possibility could be that something caused a crash and this error is just surfacing information about the crash so the previous session log (right before the crash) would be helpful to rule that out.

streetpea commented 1 year ago

@jbaiter I was able to reproduce this locally after many attempts and it does seem like the following:

Another possibility could be that something caused a crash and this error is just surfacing information about the crash so the previous session log (right before the crash) would be helpful to rule that out. is indeed what is happening.

The crash actually seems to happen here: chiaki failed log remote play crashes

You can see the connection refused in this log. After this occurs, I keep on getting the remote play has crashed (whether using Chiaki or official PS Remote Play) in any subsequent session attempts similar to the log posted by @khalara84 above. Then, after I put the console to sleep and wake it up (restarting the remote play server which crashed) it works again. Here is a successful log from a successful run after sleeping the console.

From the log it looks like the stream session never successfully launches (crashing instead) in the failed log. However, the stream launch spec is identical so I’m not sure what exactly is causing this (maybe it’s something to do with the ps console itself?) I also noticed in the spec that ps3 and ps4 (see log launchspec code and stream connection code) are mentioned but not ps5 but that’s also the case for the successful launch so it doesn’t explain the intermittent remote play server crash. However, I guess it could result in some fallback code that works sometimes but not other times or there is some sort of threading issue where a mutex isn't being properly locked and so bad/conflicting data is being sent at some point


Additionally, I get the following error on the PlayStation console itself from the session that ends in session refused (the session I posted the error log titled “chiaki failed log remote play crashes”):

Error Code: CE-108262-9
Date: 2/5/2023 12:42 PM
App: NPXS40102
NAT type: Checking

System Software: 22.02-06.50.00.10-00.00.00.0.1
Message: Something went wrong with the system software.

In other words, it does seem Chiaki is being disrupted by a failure from the remote play server on the PlayStation itself crashing on launch but I can’t seem to see exactly why it’s failing (Chiaki sending something wrong or a bug in remote play server) from my initial look at the log. I also tried changing the launch spec to be incorrect and that results in a different error saying the server failed to launch with “Nagare could not init” so it doesn’t seem to be that though I guess it could be something that’s allowed but not working properly.

khalara84 commented 1 year ago

This log is from a working session. I hope this helps in some way. chiaki_session_2023-02-07_14-36-22-311311.log

Geier97332 commented 1 year ago

I had this problem today every time I used chiaki4deck in my home network.

I put my PS5 in rest mode and used the built in script in game mode to start the remote session. It didn't work. Every time I had to restart the PS5.

Usually I use it to play outside my home network, but at the moment it's not useable because I can't be certain that it does work. When the session crashes I have no opportunity to restart the PS5 outside my home network.

So, please solve this problem. I keep my fingers crossed and keep up your amazing work. You devs are absolute genius.

streetpea commented 1 year ago

@Geier97332 unfortunately based on the information above, the crash is actually happening on the PlayStation 5 itself. Something is triggering this bug on the server, so since we can't update the server directly to patch the bug we have to figure out what is potentially triggering the code path that is leading to the bug. This will likely require some reverse engineering. In general, it seems like the only things that could have caused this are either upgrades to the takion protocol / streamsession made to enable haptics/adaptive triggers or some change to the remote play server itself in a PlayStation firmware update (with the former seeming more likely atm).

As far as a temporary workaround (while waiting for the issue to be fixed) you could use a prior version of chiaki4deck such as v1.2.0 (obviously you will lose any features added for v1.3.0) but things like touchpad support and the automation will work fine (see features added by release here with everything up to 1.2.0 being included in version 1.2.0). If the issue is indeed related to the v1.3.0 changes this will avoid the issue.

In order to do that you can use the following command:

flatpak update --user --commit 45455a2634dd8537741d5b1f4f4d9b154c772018512b2ea397a215956eb42adc re.chiaki.Chiaki4deck

and then mask re.chiaki.Chiaki4deck so you aren't prompted to upgrade back to v1.3.0 in the discover gui with:

flatpak --user mask re.chiaki.Chiaki4deck

As an aside you can see all available commits to cherry pick one with:

flatpak remote-info --log chiaki4deck-origin re.chiaki.Chiaki4deck

The commit I used in the command above is for version 1.2.0. For more info see the flatpak documentation on this.

Geier97332 commented 1 year ago

Thank you!

Now it's working again, except all the good new stuff of course. 😉

khalara84 commented 1 year ago

Every time I try to revert to the older version it just installs the newer version, not sure how to revert to 1.2.0

streetpea commented 1 year ago

@khalara84 If you run the first 2 commands above it should work:

flatpak update --user --commit 45455a2634dd8537741d5b1f4f4d9b154c772018512b2ea397a215956eb42adc re.chiaki.Chiaki4deck

And then


flatpak --user mask re.chiaki.Chiaki4deck

(the first will install the older version and the second will hide updates so it doesn’t update to the newer version)

khalara84 commented 1 year ago

When I try those commands, it says Looking for updates
 error: re.chiaki.Chiaki4deck not installed I've tried with and without it installed . Sorry for all the trouble! with it installed I get Looking for updates
 Nothing to do.

streetpea commented 1 year ago

Please try

flatpak remote-info --log chiaki4deck-origin re.chiaki.Chiaki4deck
streetpea commented 1 year ago

Also if you have masked it already you will have to unmask with:

flatpak --user  --remove mask re.chiaki.Chiaki4deck

get to the right version and then mask

If it’s currently masked you won’t get updates because updates are masked

Check your version once done with

flatpak info re.chiaki.Chiaki4deck 
khalara84 commented 1 year ago

For some reason, it wouldn't show me the app version in console, but I masked and it shows as 1.2.0 now. Thank you for so much help!

ApexAftermath commented 1 year ago

Not that it helps any, but I seem to be able to get it to consistently work if I put the PS5 back in rest mode manually and bring it back out of rest mode manually. Then I am able to connect. If it has been woken up by Chiaki it does not like it.

Geier97332 commented 1 year ago

Not that it helps any, but I seem to be able to get it to consistently work if I put the PS5 back in rest mode manually and bring it back out of rest mode manually. Then I am able to connect. If it has been woken up by Chiaki it does not like it.

I use Chiaki only if I'm away from home, so this approach isn't convenient. But thanks for the info!

Edit: Is there a way to only wake up the console with the Steam Deck? Then this approach would be doable.

AxelTerizaki commented 1 year ago

Don't know if that'll help b ut I am consistently able to reproduce the issue.

Today I wanted to try out the experimental haptics feature so I checked it. I connected to my console but didn't pay attention if haptics worked (I suppose not or else I'd have noticed, I play FF16 lately.). I then put the console to sleep again and went to do other stuff. Then I tried to get the console out of rest mode via Chiaki and that didn't work but I didn't get the "crashed" message. Only when I tried it again.

Here are my logs.

Hope that helps. I can reproduce this anytime.

chiaki_logs.tar.gz

Sn0wCrack commented 1 year ago

This is unrelated to chiaki4deck specifically, but I've been playing around with a build of Chiaki Master with Qt6 on Windows and have faced the same problem when enabling Extended DualSense support.

Pretty always goes the same: send wake up packet, connect, screen stays black for a while then get an unknown error, attempt to connect again and get the message saying remote play has crashed on the console. Until I restart the console fully I cannot access remote play again, and I can reproduce it 100% of the time.

The main thing I've noticed when DualSense support is enabled are three additional packets are sent over the control protocol from the PS5 back to Chiaki that are not handled:

My only assumption is there's some kind of "acknowledgement" packet potentially not being sent to one of these that is directly causing that crash, the 0x16 one seems the most obvious.

Unfortunately out of my wheel house on reversing this sort of stuff, especially with all the layers of encryption in the way, so I've attached my log files from these attempts (some may not be entirely relevant)

chiaki.zip

MadHalaster commented 1 year ago

Just wanted to confirm that I see the same thing as Sn0wCrack on the PC Build with the DualSense support, 100% of the time.

I found that if I wake up the console, and connect to it first with the official remote play application, then disconnect that one and connect with Chiaki after, it works. If I wake up the console and connect with Chiaki though it crashes.

streetpea commented 1 year ago

@AxelTerizaki do you have a specific method to cause this issue (you mentioned being able to reproduce)? If you do I would like to know it so I can use it to reproduce on my system for testing.

AxelTerizaki commented 1 year ago

@streetpea As mentionned above, on July 12th, this is easy to reproduce :

I haven't tried in a while though.

streetpea commented 1 year ago

@AxelTerizaki oh I saw that but I'm not able to reproduce like that so was wondering if there was something else to it. Since it sounds like there isn't, if you are able to consistently reproduce like that would you be willing to see if a change stopped the issue from occurring? It's hard for me to test this because the issue only occurs for me a very small percentage of the time. For example, while doing testing I launched the client over 100 times and it failed only once with this issue. Thus, if what I did fixed the issue it would be hard to confirm because it's possible the issue is just not occurring yet. Based on what was changed it seems there are only a few things that could be causing this so I would like to test out which one it is if possible. Hence my question about reproducibility.

AxelTerizaki commented 1 year ago

I'll check that out this weekend, I'm not at my place at the moment (and didn't set up chiaki for real remote play :) )

SteveMJones commented 11 months ago

Can confirm when using the experimental features for haptics it messes up my ps5 remote play service and i need to turn it off on chiaki4deck and restart the ps5 to not crash.

TsukikoChan commented 10 months ago

Can confirm that this still happens with the experimental features but also mostly for me against my ps4 (ps5 remote play worked ok for me yesterday) - will follow suggestions here of trying without the haptic tickbox (after a ps4 restart) or using an earlier version.

(Latest chiaki4deck against ps4pro and ps5 latest firmwares using steamdeck lcd).

willnix86 commented 10 months ago

+1 for @TsukikoChan - same for me

r52 commented 9 months ago

I just discovered this fork and thread and realized I may have independently investigated this exactly issue on mainline Chiaki desktop a while ago, which culminated in a workaround in https://github.com/r52/chiaki/commit/1efc98a7ced4adaf424851e08f10beb6ed26e825.

My findings:

To add to these findings:

Based on these findings, I theorize that the only logical reason as to why the PS5 does not produce a valid GMAC at that point in time in the handshake cycle is if its own encryption threads have not yet finished its initialization.

Since the the PS5 does not signal when it has finished initializing its internal processes, the only way I could think of testing out this theory is by inserting a small delay after Big Bang finalization but before stream_connection_send_controller_connection is called. And to my surprise, it actually works.

I wouldn't know how to go about fixing this 'properly', or if a proper fix is even possible, but with a just small 100ms delay the server crash has no longer been reproducible for me ever since.

Hope this helps

streetpea commented 9 months ago

@r52 thanks for chiming in. Maybe it will be setup when the bang is received. Right now, we are sending potentially before bang. If we move to streaminfo function like #240 maybe this fixes it? I can't test to make sure because I can't reproduce on my system reliably (I tried directly connecting to ethernet but it didn't work. Maybe you could try?)

r52 commented 9 months ago

@streetpea I just tested #240 on a local build and indeed it seems like moving the send to the streaminfo block works perfectly.

As a sanity check I made sure that the 1.6.2 release consistently crashes my PS5 server, and it does.

Looks good to me 👍

LucyDemooon commented 3 months ago

chiaki 2.2 and chiaki-ng 1.8 i get this error every time.

installed the flatpak and appimage on arch linux

`0x80108b15

[2024-08-07 19:34:52:307307] [I] Starting session request for PS5 [2024-08-07 19:34:52:307307] [I] Trying to request session from 192.168.150.150:9295 [2024-08-07 19:34:52:307307] [I] Connected to 192.168.150.150:9295 [2024-08-07 19:34:52:307307] [I] Sending session request [2024-08-07 19:34:52:307307] [E] Reported Application Reason: 0x80108b15 (Remote Play on Console crashed) [2024-08-07 19:34:52:307307] [I] Session has quit [2024-08-07 19:34:53:308308] [I] Starting session request for PS5 [2024-08-07 19:34:53:308308] [I] Trying to request session from 192.168.150.150:9295 [2024-08-07 19:34:53:309309] [I] Connected to 192.168.150.150:9295 [2024-08-07 19:34:53:309309] [I] Sending session request [2024-08-07 19:34:53:309309] [E] Reported Application Reason: 0x80108b15 (Remote Play on Console crashed) [2024-08-07 19:34:53:309309] [I] Session has quit [2024-08-07 19:34:54:309309] [I] Starting session request for PS5 [2024-08-07 19:34:54:309309] [I] Trying to request session from 192.168.150.150:9295 [2024-08-07 19:34:54:309309] [I] Connected to 192.168.150.150:9295 [2024-08-07 19:34:54:309309] [I] Sending session request [2024-08-07 19:34:54:310310] [E] Reported Application Reason: 0x80108b15 (Remote Play on Console crashed) [2024-08-07 19:34:54:310310] [I] Session has quit `

streetpea commented 3 months ago

@LucyDemooon You likely got a crash using chiaki since the patch that fixed this in chiaki-ng is not in chiaki and need to reset remote play for it to work again by putting the console to sleep. Chiaki-ng should work again after that.