RetroArch icon indicating copy to clipboard operation
RetroArch copied to clipboard

[Wii]"Load failed (-32)" from retroachievements with most games (ps1 especially)

Open whatnowmax opened this issue 2 years ago • 11 comments

Description

After applying wii/gcn nightly build with feature request #14982, Receiving error when loading retroachievements achievements using supported .cue/bin files (verified files are good with 3 other devices that all work fine)

Expected behavior

After loading ps1 content, successful login to retroachievements, followed by the ability to see all achievements in the menu.

Actual behavior

Error in screen (screen is too small to read more than a few characters), then the achievements list is "unknown game". I've used three other devices to make sure that these files are legitimate, and the retroarch logs seem to confirm that as well.

Log file:

retroarch__2024_01_31__13_15_20.log

snip: [INFO] [RCHEEVOS]: WhatNowMaxTV logged in successfully [INFO] [RCHEEVOS]: Identified game: 11240 (bf7e0e90d8e8d5738c7332bc6af666da) [INFO] [RCHEEVOS]: Fetching data for game 11240 [INFO] [RCHEEVOS]: Load failed (-32): {"Success":true,"PatchData":{"ID":11240,"Title":"Castlevania: Symphony of the Night","ImageIcon":"\/Images\/085764.png","RichPresencePatch":"Lookup:Ch\r\n0=Alucard\r\n1=Richter\r\n\r\nLookup:AreaName\r\n0x189c=Bloodlines Final Stage \r\n0x187c=Entrance \r\n0x90ec=Entrance \r\n0x9504=Alchemy Laboratory \r\n0x37b8=Marble Gallery \r\n0x1a20=Outer Wall \r\n0x69ec=Outer Wall \r\n0xf160=Long Library \r\n0xa620=Underground Caverns \r\n0x6734=Underground Caverns \r\n0x5fb8=Royal Chapel \r\n0x6be4=Royal Chapel \r\n0xd660=Castle Keep \r\n0x9b84=Castle Keep \r\n0x8744=Olrox's Quarters \r\n0xc10c=Olrox's Quarters \r\n0x8704=Colosseum \r\n0x76a0=Colosseum \r\n0xdea4=Abandoned Mines \r\n0x6678=Abandoned Mines \r\n0xb6d4=Catacombs \r\n0x55d0=Catacombs \r\n0xc710=Clock Tower \r\n0x3ee0=Reverse Entrance \r\n0xcc34=Necromancy Laboratory \r\n0x5174=Necromancy Laboratory \r\n0x7354=Black Marble Gallery \r\n0x9ccc=Reverse Outer Wall \r\n0x8e3c=Reverse Outer Wall \r\n0x2b90=Forbidden Library \r\n0xced0=Reverse Clock Tower \r\n0xa214=Reverse Caverns \r\n0x5920=Reverse Caverns \r\n0x465c=Anti-Chapel \r\n0x31c8=Anti-Chapel \r\n0x2524=Reverse Keep \r\n0x6d20=Death Wing's Lair \r\n0x5f04=Death Wing's Lair \r\n0x6b70=Reverse Colosseum \r\n0xa094=Reverse Colosseum \r\n0xac24=Cave \r\n0x1ab0=Cave \r\n0x3f80=Floating Catacombs \r\n0x9dc8=Floating Catacombs \r\n0x8218=Teleport Room \r\n0xa198=Teleport Room \r\n0xe7c=Castle Center \r\n0x49c=Reverse Castle Center\r\n0x6fc0=Nightmare \r\n0x54ec=Final Fight \r\n\r\nFormat:Lv\r\nFormatType=VALUE\r\n\r\nFormat:Hr\r\nFormatType=VALUE\r\n\r\nFormat:Min\r\nFormat [INFO] [RCHEEVOS]: RetroAchievements game load failed: {"Success":true,"PatchData":{"ID":11240,"Title":"Castlevania: Symphony of the Night","ImageIcon":"\/Images\/085764.png","RichPresencePatch":"Lookup:Ch\r\n0=Alucard\r\n1=Richter\r\n\r\nLookup:AreaName\r\n0x189c=Bloodline

Steps to reproduce the bug

  1. Start wii
  2. Homebrew channel
  3. unplug gcc
  4. sync wii classic controller
  5. startup retroarch 1.17.0 git version c4c1fb1, build date Jan 28 2024
  6. Load content
  7. Navigate to .cue/bin files on usb
  8. click on .cue file
  9. Choose the core: Sony - Playstation (PCSX ReARMed)
  10. wait 30-60 seconds for game to load
  11. message will say login to retroarchievements successful
  12. press the retroarch menu button of choice to open the quick menu
  13. scroll down to Achievements
  14. "Unknown game"

Bisect Results

Really difficult to say. This was working at one point fully, with the same files. After some tweaking of settings and restarting to get the games working better performance-wise and aspect-wise, I found that retroachievements would no longer load the achievements, although I don't think this is what caused the problem as I reset the settings to default, re logged in.

I took everything out and installed the latest nightly and ps1 games don't even start up again so...yeah.

Version/Commit

  • RetroArch: retroarch 1.17.0 git version c4c1fb1, build date Jan 28 2024

Environment information

  • OS: wii

whatnowmax avatar Feb 01 '24 13:02 whatnowmax

-32 is RC_NO_RESPONSE

https://github.com/RetroAchievements/rcheevos/blob/c5f9a6412e55ef489c1769a52ee1d590e4abd64b/include/rc_error.h#L45

Which means the http_status_code was set to RC_API_SERVER_RESPONSE_CLIENT_ERROR (-1) or RC_API_SERVER_RESPONSE_RETRYABLE_CLIENT_ERROR (-2), or the body was null or empty.

https://github.com/RetroAchievements/rcheevos/blob/c5f9a6412e55ef489c1769a52ee1d590e4abd64b/src/rapi/rc_api_common.c#L326-L351

The provided log shows there was a body, so the http_status_code must be getting set to -1 or -2.

The RetroAchievements code isn't using the CLIENT_ERROR defines yet, so this must be coming from the http code.

https://github.com/libretro/RetroArch/blob/633dad5d6b2709be22f965360100dc00ed5032e1/cheevos/cheevos_client.c#L345-L349

It looks like the body is incomplete. The logged JSON stops in the middle of the RichPresencePatch field.

Jamiras avatar Feb 01 '24 14:02 Jamiras

In case this helps, I turned off "rich presence" in the achievements options in retroarch and same issue.

whatnowmax avatar Feb 01 '24 16:02 whatnowmax

Some additional information if it helps: 1.17.0 doesn't even launch ps1 games anymore. Big RIP. No versions of smb1 that I have work smb3 works Marble Madness works.

Can't help but wonder if anyone else has the same issue?

whatnowmax avatar Feb 05 '24 13:02 whatnowmax

I was able to reproduce the issue.

A few notes. On the real wii I noticed that there issues if you use retroarch without a SD card inserted both achievements and psx games don't work (@whatnowmax maybe thats whats happening to you).

On dolphin: Loading .cue PSX files just give a black screen, loading a .bin works fine.

No PSX achievements though. I will try to debug further now that I managed to replicate on Dolphin.

rafaelsamenezes avatar Feb 18 '24 18:02 rafaelsamenezes

Apparently the issue is that a recv call is asking too much memory for one call. So the recv call is failing with IPC_ENOMEM. I logged the calls and the value 65544 seems to be the issue (I logged other calls with 32776 which were fine).

  • libogc recv: https://github.com/devkitPro/libogc/blob/cae918ad56df870ef5e128673f24f993d9c128fd/libogc/network_wii.c#L929-L948

I guess the solution would be to try to split into multiple smaller recv calls when failing with IPC_ENOMEM.

rafaelsamenezes avatar Feb 19 '24 00:02 rafaelsamenezes

Indeed, splitting the recv (patch.txt) seems to solve the issue in Dolphin. I will test it later on the console.

rafaelsamenezes avatar Feb 19 '24 14:02 rafaelsamenezes

@rafaelsamenezes -- you're totally right about ejecting the sd card as being the cause of ps1 not loading. Very odd!

Can't wait for the patch! :D tytytyty

whatnowmax avatar Mar 07 '24 13:03 whatnowmax

@rafaelsamenezes any luck? I can test just not sure how

whatnowmax avatar Jun 30 '24 03:06 whatnowmax

@rafaelsamenezes any luck?

Sorry, had been busy for the last months.

The split did help in some cases (e.g., SOTN), but I did not had the same luck with other games. I also tried to only download chunks with the remaining memory available, it became too slow (and we run out-of-memory sometimes anyway).

I guess the next idea would be to use the SD card for memory somehow.

rafaelsamenezes avatar Jul 02 '24 06:07 rafaelsamenezes

@rafaelsamenezes oh wow super involved. I really really appreciate all your hard work with this. Is there any trend to knowing whether a game would work ahead of time? Achievement list is long or game name is long or anything I could spot from afar without going through the trouble to try?

I did also notice that the achievement list is REAL slow to load sometimes. I wonder if the wiiu is afflicted with similar issues (I don't own one). Probably that platform is superior to the wii for the use of retroachievements/retroarch I'd think (?).

whatnowmax avatar Jul 06 '24 12:07 whatnowmax

@rafaelsamenezes oh wow super involved. I really really appreciate all your hard work with this. Is there any trend to knowing whether a game would work ahead of time? Achievement list is long or game name is long or anything I could spot from afar without going through the trouble to try?

I did also notice that the achievement list is REAL slow to load sometimes. I wonder if the wiiu is afflicted with similar issues (I don't own one). Probably that platform is superior to the wii for the use of retroachievements/retroarch I'd think (?).

Ok, had a bit more time to focus in this issue. My testing shows two main issues:

  1. Recv calls that are over 64k.
  2. Lots of times the recv call will return with EAGAIN ("try again")

Both of these issues can be handled by having a special recv for wii

static inline s32 recv_split(s32 s, void *mem, s32 len, u32 flags) {
  // libogc network package has a custom allocator with
  // a hard limit of 64k (see devkitPro/libogc/issues/177).
  // This causes recv calls to fail with OOM (see
  // libretro/RetroArch/issues/16184)

  const s32 LIMIT = 48 * 1024;
  s32 max_tries = 1000;
  s32 res = 0;

  while(len) {
    s32 recv_length = len < LIMIT ? len : LIMIT;
    s32 recv_call_res = net_recv(s, mem, recv_length, flags);
 
    if (isagain(recv_call_res) && max_tries--)
      continue;    
    else if(recv_call_res < 0)
      return recv_call_res;
    
    mem = (char *)mem + recv_length;
    len -= recv_length;
    res += recv_call_res;
  }
  
  return res;
}

With this implementation SNES achievements seems to be way more consistent. Hopefully I will have time later this week to test PSX as well.

rafaelsamenezes avatar Aug 20 '24 20:08 rafaelsamenezes