RetroAchievements / RALibretro

RALibretro is a multi-emulator used to develop RetroAchievements.
https://retroachievements.org
GNU General Public License v3.0
186 stars 37 forks source link

N64 Core Crashes when Screenshot is taken/Savestate is loaded. #379

Closed BoomEX-UK closed 1 year ago

BoomEX-UK commented 1 year ago

Describe the bug When running RALibretro v1.6 x64 using either Mupen64plus-Next or ParaLLEI N64 core, the screenshot button causes the video feed to crash. The game continues to run in the background but the screenshot is never saved to the folder. he crash also occurs when loading a Savestate. This issue was not present in v1.5

To Reproduce

  1. Open v1.6 of RALibretro
  2. Load any N64 Game using either Mupen64plus-Next or ParaLLEI N64 core
  3. When the game is loaded press the screenshot button
  4. The playback will freeze in place but music / sfx will continue as normal
  5. Repeat these steps in v1.5 and the issue is not present

Expected behavior I expect a screenshot to be saved to RALibretro/screenshots and the playback to continue

Screenshots Failed to Save Files: Failed to save Screenshots About: image

Desktop (please complete the following information):

Additional context Nothing more to add

Jamiras commented 1 year ago

I can't reproduce this at all with the Mupen64plus-Next core. I can reproduce with the ParaLLEl core, but only if another game was previously loaded. Given two copies of Mario 64 in my history (one for each core), loading one, then the other has the following results: 1) Mupen64plus-Next > Mupen64plus-Next : seems fine 2) Mupen64plus-Next > ParaLLEl : rendering issues, video failure on screenshot 3) ParaLLEl -> Mupen64plus-Next : seems fine 4) ParaLLEl -> ParaLLEl : rendering issues, video failure on screenshot.

Based on the video failures, and the user's comment that this doesn't happen in 1.5, I'm assuming that this is related to #367. @Jcw87 - Can you take a look?

image

BoomEX-UK commented 1 year ago

Thank you Jamiras. Interesting you mention the game switching as once I have loaded a game, if I select another from the recent menu or press Load Game.. RALibretro will crash trying to load it.

This was also not an issue for me on v1.5

Jcw87 commented 1 year ago

I'm not able to replicate any issues with taking screenshots. I do see a few issues with changing games, but only when the ParaLLEl core is involved. I am able to replicate the glitchy mario head, but annoyingly, it crashes whenever RenderDoc is monitoring it.

I don't really have the motivation to do a deep dive into this issue right now. I've been spending every moment of my spare time playing Tears of the Kingdom. If you need a quick fix, reverting #367 does seem to resolve these issues. You can always bring it back later when I find the time to fix it.

Jcw87 commented 1 year ago

I looked at this yesterday. All that I've been able to determine is that something messes up one of the OpenGL contexts.

As part of the #367 changes, RALibretro creates 2 OpenGL contexts. One for itself (_raContext), and one for the loaded core (_coreContext). While running ParaLLEl, if RALibretro tries to bind the framebuffer or texture on the _coreContext, it fails with GL_INVALID_OPERATION. Binding the texture (which is shared between contexts) on the _raContext still works, so I'm pretty sure that the _coreContext is breaking, and not the framebuffer or the texture. It also seems that the ParaLLEl core needs to be running for long enough before this happens. In Mario 64, everything is still fine on the opening logo, but as soon as the screen with the Mario head loads, it breaks. Unfortunately, I still don't have any idea what is causing it.

I did manage to replicate the screenshot issue, and I can implement a fix for that. But the underlying issue is still a mystery.

Edit: maybe the context isn't broken at all. Maybe the ParaLLEl core is causing an error on something else, and doesn't clear it. I'll have to check that later.

BoomEX-UK commented 1 year ago

Thank you for the update and continuing to look into this. I appreciate how busy you must be. If you are able to find a fix then it would greatly help the RALibretro Dev process on N64

Jcw87 commented 1 year ago

The 2 pull requests I just made should resolve most of the issues reported here. I think the only one remaining is the glitchy mario head. I did manage to get RenderDoc working (it was crashing in RA_Integration.dll, so I just deleted it). My only lead so far is a difference on the framebuffer.

image

Jcw87 commented 1 year ago

Found the cause, added the fix to one of the existing PRs.