1lann / lol-replay

A collection of Go (golang) packages to record and play back League of Legends games from the spectator endpoint.
MIT License
70 stars 16 forks source link

Recordings seem to be corrupted or incomplete. #7

Open gverri opened 5 years ago

gverri commented 5 years ago

First, thanks for writing this amazing project. Makes me want to learn and work with go myself.

Everything seems to be working fine and the recordings seem to be complete and valid. But when I start the game using the "replay 127.0.0.1:9000 ..." command I get the following error:

<unknown>(0xa98101c0): ERROR| Failed to extract information from command line string for normal game mode

If I try running it with the "spectator 127.0.0.1:9000 ..." command the replay starts at the last 30 seconds of the game and then ends.

In both cases I'm getting the following compression error at the start:

/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Common/ChunkCompression.cpp:50: Error: unsupported compressor 8 /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/Exceptions.plist' /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Common/ChunkCompression.cpp:50: Error: unsupported compressor 8 /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppleFSCompression/AppleFSCompression-96.30.2/Libraries/CompressData/CompressData.c:353: Error: Unknown compression scheme encountered for file '/System/Library/CoreServices/CoreTypes.bundle/Contents/Library/AppExceptions.bundle/Exceptions.plist'

Any idea on how to solve this?

1lann commented 5 years ago

Ah, you might be running the command line arguments a bit off? I'm not too sure, I haven't used my program in a long while, primarily because the League client has replays officially. Your best bet is to copy the OP.GG spectator script and modify it to contain the appropriate replay string.

Here's one for example:

cd /Applications/League\ of\ Legends.app/Contents/LoL/RADS/solutions/lol_game_client_sln/releases/ && cd $(ls -1vr -d */ | head -1) && cd deploy && chmod +x ./LeagueOfLegends.app/Contents/MacOS/LeagueofLegends && riot_launched=true ./LeagueOfLegends.app/Contents/MacOS/LeagueofLegends 8394 LoLLauncher "" "spectator f2.spectator.op.gg:80 RMrUoCOQaz3SPT+fo6/CWvds1N3FjXFe 2883306476 NA1"

I think when using spectator and it starts at the last 30 seconds is normal, because the client tries to seek as far forward as possible to be "realtime". In older versions of my code I supported using spectator by throttling the rate at which the client can retrieve the chunks so it starts at the start. Now, I use replay mode because it allows you to seek anywhere in the replay without having to wait for the throttling.

gverri commented 5 years ago

Hi @1lann, thanks for the answer!

I have already tried using the op.gg command as a base. That's where I got the idea of using the spectator client.

I'm running fish so the command is a little different:

cd /Applications/League\ of\ Legends.app/Contents/LoL/RADS/solutions/lol_game_client_sln/releases/; and cd (ls -1vr -d */ | head -1); and cd deploy; and chmod +x ./LeagueofLegends.app/Contents/MacOS/LeagueofLegends; and env riot_launched=true ./LeagueofLegends.app/Contents/MacOS/LeagueofLegends 8394 LoLLauncher "" "replay 127.0.0.1:9000 RAF8SGZj9X0TFvzZkbIKlYivY7hcqOQN 1486716130 BR1"

Maybe this is a problem with MacOS? I will try to run the server from a docker container to see if solves the problem.

Another thing that I noticed is that during the recording the server does not identify the type of game being recorded.

The error mentions a "normal game mode" but it is actually a ranked game. I don't know if that's what "normal game mode" is referring to but could be a lead.

When I run the replay file on the debugger tool everything seems to be normal:

`--- Recording properties --- Has game metadata: true Has user metadata: true Is recording complete: true

--- Game information --- Platform: BR1 Game version: 1.82.156 Record time Mon, 08 Oct 2018 17:07:51 -0300 Encryption key: jNRH8I4SsjT0i6UQpTx4nF08MG/oeuqC

--- Metadata information --- {"gameKey":{"gameId":1486768863,"platformId":"BR1"},"gameServerAddress":"","port":0,"encryptionKey":"","chunkTimeInterval":30000,"startTime":"Oct 8, 2018 1:05:21 PM","gameEnded":false,"lastChunkId":6,"lastKeyFrameId":3,"endStartupChunkId":1,"delayTime":180000,"pendingAvailableChunkInfo":[{"id":1,"duration":2239,"receivedTime":"Oct 8, 2018 1:04:33 PM"},{"id":2,"duration":45417,"receivedTime":"Oct 8, 2018 1:05:20 PM"},{"id":3,"duration":30006,"receivedTime":"Oct 8, 2018 1:05:51 PM"},{"id":4,"duration":29999,"receivedTime":"Oct 8, 2018 1:06:19 PM"},{"id":5,"duration":30002,"receivedTime":"Oct 8, 2018 1:06:51 PM"},{"id":6,"duration":30003,"receivedTime":"Oct 8, 2018 1:07:20 PM"}],"pendingAvailableKeyFrameInfo":[{"id":1,"receivedTime":"Oct 8, 2018 1:05:49 PM","nextChunkId":3},{"id":2,"receivedTime":"Oct 8, 2018 1:06:50 PM","nextChunkId":5},{"id":3,"receivedTime":"Oct 8, 2018 1:07:50 PM","nextChunkId":7}],"keyFrameTimeInterval":60000,"decodedEncryptionKey":"","startGameChunkId":3,"gameLength":0,"clientAddedLag":0,"clientBackFetchingEnabled":false,"clientBackFetchingFreq":1000,"interestScore":2722,"featuredGame":false,"createTime":"Oct 8, 2018 1:04:32 PM","endGameChunkId":-1,"endGameKeyFrameId":-1} --- Chunk information --- First chunk information: {"chunkId":3,"availableSince":0,"nextAvailableChunk":0,"keyFrameId":1,"nextChunkId":3,"endStartupChunkId":1,"startGameChunkId":3,"endGameChunkId":85,"duration":30000} Last chunk information: {"chunkId":85,"availableSince":0,"nextAvailableChunk":0,"keyFrameId":42,"nextChunkId":85,"endStartupChunkId":1,"startGameChunkId":3,"endGameChunkId":85,"duration":30000}

--- Chunk and key frame data --- Chunks found: 1: size: 2224 2: size: 21224 3: size: 32792 4: size: 12104 5: size: 40520 6: size: 145752 7: size: 195984 8: size: 216400 9: size: 222952 10: size: 186408 11: size: 202672 12: size: 198592 13: size: 196104 14: size: 250696 15: size: 180872 16: size: 227456 17: size: 179664 18: size: 201624 19: size: 220912 20: size: 215280 21: size: 235080 22: size: 185120 23: size: 217272 24: size: 200408 25: size: 188032 26: size: 205016 27: size: 250432 28: size: 210408 29: size: 268008 30: size: 185336 31: size: 204672 32: size: 199896 33: size: 261072 34: size: 210936 35: size: 202032 36: size: 261416 37: size: 216464 38: size: 220744 39: size: 174800 40: size: 315568 41: size: 205648 42: size: 236312 43: size: 210272 44: size: 225680 45: size: 269864 46: size: 204504 47: size: 207256 48: size: 277464 49: size: 226464 50: size: 209720 51: size: 224984 52: size: 224432 53: size: 241288 54: size: 223192 55: size: 192248 56: size: 278792 57: size: 290568 58: size: 295216 59: size: 220696 60: size: 224032 61: size: 366336 62: size: 222752 63: size: 253864 64: size: 238528 65: size: 243560 66: size: 231584 67: size: 303616 68: size: 221288 69: size: 210960 70: size: 220592 71: size: 238584 72: size: 203136 73: size: 279888 74: size: 309336 75: size: 334528 76: size: 197624 77: size: 230496 78: size: 244624 79: size: 272960 80: size: 280464 81: size: 284896 82: size: 248720 83: size: 381904 84: size: 319728 85: size: 51552 Key frames found: 1: size: 11528 2: size: 20376 3: size: 32512 4: size: 33512 5: size: 33320 6: size: 34040 7: size: 36080 8: size: 36600 9: size: 35784 10: size: 37648 11: size: 36080 12: size: 35448 13: size: 38376 14: size: 40976 15: size: 37984 16: size: 40856 17: size: 39992 18: size: 39688 19: size: 38088 20: size: 40040 21: size: 41912 22: size: 37536 23: size: 40248 24: size: 42448 25: size: 38592 26: size: 39736 27: size: 38344 28: size: 41776 29: size: 42016 30: size: 40368 31: size: 39928 32: size: 45912 33: size: 42752 34: size: 37608 35: size: 41360 36: size: 42816 37: size: 42744 38: size: 43088 39: size: 40624 40: size: 45472 41: size: 44400 42: size: 44608

--- End of report ---`

gverri commented 5 years ago

I tried from Docker, Windows, Linux Vm, etc... It seems like there is no way to use the replay client to run the recordings. OP.GG is using the spectator client and it seems to be having the same issue of games being incomplete and not starting at the start.

This is a core feature for my project. I need to be able to save and replay third party games, so it's not possible to get .rofl files. Maybe this is a roadblock for this project... Do you think there's anything I can do to make it work?

1lann commented 5 years ago

Thanks a tonne for taking your time to test it out on those platforms, it's useful to know that it doesn't work on any platform.

The ROFL file format is actually standardized and developed before Riot Games made them AFAIK. I kinda unfortunately in this case decided to not use the ROFL file format, but perhaps it is possible to encode the data into the ROFL format, which may work with the client? Although I semi-doubt it at the same time because this issue implies that Riot changed something partly fundamental to the spectator endpoint.

You can try to reverse engineer the protocol yourself, that is afterall how I developed this project in the first place. I did this by using Wireshark, and spectating someone normally. Then I looked at the data sent in Wireshark and wrote some code to try to replicate the HTTP endpoint behavior. Experiment and repeat this a bunch of times until you figure the whole thing out. I did a partial write-up about how it works here: https://gist.github.com/1lann/885f6b85b99d19b88bec

If you're not already on the Riot Games API Discord server, you can drop in and ask, there are lots of people there with different experiences in working with replays who may have more up to date knowledge about the spectator endpoints now: https://discord.gg/uYW7qhP

gverri commented 5 years ago

Thank you, for taking your time to write this project and answer me.

I think reverse engineering the API is beyond me, but I'll dig into it anyway.

It seems that even the normal client is having some issues with the spectator endpoint, I will wait to see if this is a patch bug or if they indeed changed something fundamental.