Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running PCSX games with bios crash kodi #13

Closed
matejmosko opened this issue Jul 16, 2018 · 42 comments
Closed

Running PCSX games with bios crash kodi #13

matejmosko opened this issue Jul 16, 2018 · 42 comments

Comments

@matejmosko
Copy link

matejmosko commented Jul 16, 2018

This behaviour started after libretroí compatiblity was upgraded to 1.0.38.107. Before, games worked quite fine.

Starting any game results in black screen, kodi freezing not responding to any buttonclicks and eventually to rebooting. I have tried to delete .sav and .xml files - no change. This is a regression. It worked fine before.

Important: Before the upgrade every first run of a game resulted in a black screen, but kodi didn't freeze. All consecutive runs of a game were successful. Therefore this is not the same as #9

Kodi: Libreelec (Milhouse's build 715)
System: RPi3
Kodi log
Crash log

@garbear
Copy link
Member

garbear commented Jul 17, 2018

I think I fixed this a while ago, but can't find the commit now. IIRC the problem was that audio packets were arriving too early. @lrusak did you hang onto that commit?

@garbear
Copy link
Member

garbear commented Jul 18, 2018

xbmc/xbmc#14194

@matejmosko
Copy link
Author

Unfortunately, it didn't help. I upgraded to milhouse's 718 and the result is same.

Log: http://paste.kodi.tv/vimorayoze
Crash log: http://paste.kodi.tv/sikokekahi

@garbear
Copy link
Member

garbear commented Jul 20, 2018

Can you try xbmc/xbmc#14203?

@GTechAlpha
Copy link

Also libretro/pcsx_rearmed#178 .

@matejmosko
Copy link
Author

matejmosko commented Jul 21, 2018

Ok, so I will wait until cores are updated again sometime in future.

@matejmosko
Copy link
Author

matejmosko commented Aug 2, 2018

Bad news. It didn't help. All necesary PRs are finally in milhouse's libreelec build (pcsx is updated as well), but psx games still freeze and crash kodi on libreelec.

Kodi log: http://paste.kodi.tv/atutaxuviy
Crash log: http://paste.kodi.tv/hadamusepi

@garbear, @GTechAlpha, any ideas?

@GTechAlpha
Copy link

GTechAlpha commented Aug 2, 2018

The stack trace in your log is identical to what I experienced before libretro/pcsx_rearmed#178 was applied. I think the fix somehow didn't make it in to the build you're using.

@matejmosko
Copy link
Author

matejmosko commented Aug 3, 2018

I am not sure how it is possible. According to this commit LibreELEC/LibreELEC.tv@88dc980 pcsx in libreelec now includes all commits including yours. I have double checked, my pcsx addon is updated to this version.

Moreover my latest kodi log is different to what it was before the update of pcsx addon.

@cdu13a
Copy link

cdu13a commented Aug 10, 2018

For consistency I just tried this on milhouse's latest build for the pi #0809. I got the same crash and restart behavior.

This behavior only happens if the bios file is located. If you delete the bios file then the game plays, but occasionally has issues, where after a bit of game play framerate drops to frames per minute(or sometimes screen just goes black and game play stops) and the cpu usage spikes. Will Try to get a complete log of this alternate behavior using the milhouse build. edit: Log from when bios is not found

Logs and Configs: http://ix.io/1jPQ

@matejmosko
Copy link
Author

matejmosko commented Aug 11, 2018

Thanks @cdu13a, renaming bios folder so games run without bios makes them work on milhouse's libreelec. I haven't encountered any stuttering yet. However it probably depends on the game.

EDIT: Stuttering is here :)

@matejmosko
Copy link
Author

matejmosko commented Aug 16, 2018

Just for future reference, ghizzu reported similar issue on retroplayer forums (windows build) post 2080

Ghizzu's log

@garbear
Copy link
Member

garbear commented Aug 17, 2018

Ghizzu's error is fixed: xbmc/xbmc#14313

@cdu13a
Copy link

cdu13a commented Aug 17, 2018

thanks, @garbear
Just did a test build and xbmc/xbmc#14313 fixes the games crash on launch problem.

@garbear
Copy link
Member

garbear commented Aug 17, 2018

Nice. Can this be closed?

@matejmosko
Copy link
Author

matejmosko commented Aug 17, 2018

Not yet confirmed on libreelec. Tomorrow I will test new milhouse's build and report.

@cdu13a
Copy link

cdu13a commented Aug 17, 2018

@matejmosko sorry I wasn't more specific. it was a build of libreelec I tested this on.

@matejmosko
Copy link
Author

matejmosko commented Aug 18, 2018

@garbear, this issue is not solved for me.

I have tested milhouse's build 817 now. For me it didn't help at all. The behaviour is still the same. Playing with bioses crashes kodi, playing without them suffer from stuttering. @cdu13a , have you done anything else except upgrading?

Logs with bios (game freezing after a second, than kodi crashing)

Logs without bios (game runs, but stuttering makes it unplayable)

The game was working fine on the same device (RPi3) back in ~ march releases.

@matejmosko
Copy link
Author

matejmosko commented Aug 18, 2018

I have found a way to make psx games with libreelec to temporarily work. Even though the stuttering - random slow downs and bursts of quick movement - is still an issue even with a bios. In march releases I have not encountered such behaviour in psx games on same device.

  1. Start Kodi
  2. Uninstall pcsx-rearmed
  3. Install pcsx-rearmed
  4. Start any psx game to force the core to create folder in addon_data The game works (with stuttering)
  5. Exit game.
  6. Move bioses in correct folder.
  7. Start any psx game. The game works. (With stuttering)
  8. Exit game and reboot kodi.
  9. Start any psx game. Kodi crashes after a second.

Kodi log for steps 1-7

Kodi Log for steps 8-9
Crash Log for steps 8-9

@cdu13a
Copy link

cdu13a commented Aug 18, 2018

@matejmosko I just did the same thing on milhouse #817 as I did on my own test build.

deleted the .sav files
uninstalled the game addons(removing settings)
updated libreelec
reinstalled game.libretro and game.libretro.pcsx-rearmed both from the libreelec addons repo
added bios files,
loaded several different games, played a bit. (all games bin/cue format)
played crash bandicoot for 30 min

This was on a pi2. So did not get full speed from the games. A bit of a lag and some audio issues. However other cores also don't hit full speed on the same device, and other parts of kodi are slow as well so that's probably not pcsx specific. (At least not while using a bios file)

@matejmosko
Copy link
Author

matejmosko commented Aug 18, 2018

Some news on the issue.

  1. Stuttering is probably related to undervoltage of my adaptor. Whenever the game slows down, RPi complains about low power. High power demand is probably related to cpu hogging (~160%) of pcsx emulation. Consider this unrelated to bios issue.

  2. I have found out that I don't have to reinstall pcsx everytime after reboot. But what I have to do is really strange. First I have to delete all bios files, then start any psx game without bios, exit game, move bios files into right folder and then run the game. If I don't do this after each reboot, psx games with bios crash kodi immediately.

First I thought the problems were in settings part, now I really don't know what can cause such a weird behaviour.

@garbear
Copy link
Member

garbear commented Aug 18, 2018

A confounding factor could be both in-game saves and memory saves (savestates). In-game saves are placed in userdata, savestates next to the ROM. Maybe the presence of either of these is affecting the results?

@matejmosko
Copy link
Author

Ok, I have tried to delete savestates as well as ingame saves now. No difference. Game with bios crashes kodi.

@garbear
Copy link
Member

garbear commented Aug 18, 2018

OK, next step we cut kodi out of the equation. Can this be reproduced on RetroArch?

@matejmosko
Copy link
Author

I don't have retroarch set up on the RPi, so I tried it on ubuntu (snap version) with same game and same bioses. Retroarch works flawlessly. Is it necessary to try it on the RPi3?

@garbear
Copy link
Member

garbear commented Aug 18, 2018

I'll try to reproduce on desktop Ubuntu with Kodi

@cdu13a
Copy link

cdu13a commented Aug 18, 2018

I didn't think of testing after a reboot, to see if it changed anything. After all why should a reboot change anything.

Possibly related is that pcsx-rearmed doesn't respect it's settings, on reset of the core. So it is possible to have the bios/boot logo in the savestate, when the core is not set to show it, which results in a crash on launch of the game. edit: Reset of the core without the bios also results in crashing.

@matejmosko matejmosko changed the title PCSX games crashes kodi Running PCSX games with bios crash kodi Sep 3, 2018
@GTechAlpha
Copy link

Reverting xbmc/xbmc@2bbd26f fixes it for me.

@garbear
Copy link
Member

garbear commented Oct 24, 2018

Reverting the commit fixes the crash when running PCSX games with a bios? I can look into this, but there seems to be several problems listed in this issue.

@garbear garbear closed this as completed Oct 24, 2018
@garbear garbear reopened this Oct 24, 2018
@GTechAlpha
Copy link

Reverting the commit fixes the crash when running PCSX games with a bios?

Yes.

@garbear
Copy link
Member

garbear commented Oct 24, 2018

OK. The bug is logged in garbear/xbmc#80. I'm actually starting a new job soon so time might be a little too tight for me. But at least you identified the offending commit.

@KOPRajs
Copy link

KOPRajs commented Nov 9, 2018

Hi,
I've come here to fill in a bug report but it seems I'm late to the party. It looks like the PCSX-rearmed core needs to be initialized without BIOS for the first time. After first run without BIOS you can place the BIOS back and everything works until next Kodi restart. If there is a BIOS file present upon first run it crashes while trying to load it. It seems like there is an uninitialized variable related to BIOS loading.

Users see black screen because LibreELEC launches gdb in background to create a core dump and it takes a while.

@hansbogert
Copy link

Hi,
I've come here to fill in a bug report but it seems I'm late to the party. It looks like the PCSX-rearmed core needs to be initialized without BIOS for the first time. After first run without BIOS you can place the BIOS back and everything works until next Kodi restart. If there is a BIOS file present upon first run it crashes while trying to load it. It seems like there is an uninitialized variable related to BIOS loading.

Users see black screen because LibreELEC launches gdb in background to create a core dump and it takes a while.

You sure? In my case just seems to crash on the fact that there is savestate (not in-game)

@KOPRajs
Copy link

KOPRajs commented Nov 21, 2018

I'm still not 100% sure what's the root cause of the problem but it seems that moving Streams().Initialize() back to InitializeGameplay() solves it.

@garbear Please look at the patch. If it is safe I can create a PR.
KOPRajs/xbmc@66df811

Also I've discovered another code path where the current master crashes with PCSX-rearmed and BIOS:

  1. Restart Kodi.
  2. Run any PSX game without controllers connected.
  3. Press back on the controllers info screen.
  4. Select Exit in the game OSD.

In this case Kodi crashes on RetroPlayer deinitialization. The above patch seems to fix this as well.

P.S. Possibly the BIOS itself is not the cause, more likely the lack of BIOS triggers an error during initialization and that changes the code path and avoids the crash.

P.P.S. From the original PR #14146 description: "A second fix for a potential segfault (only observed while testing) is also included." Not very helpful but that is probably the cause of this issue.

@KOPRajs
Copy link

KOPRajs commented Nov 22, 2018

@garbear Do you remember what was the reason to move the Streams().Initialize() from the InitializeGameplay() to OpenFile() in xbmc/xbmc#14146?

@garbear
Copy link
Member

garbear commented Nov 22, 2018

Kind of. The libretro API is underspecified as to when these functions should be called. See what information you gleam: https://github.com/kodi-game/game.libretro/blob/master/src/libretro/libretro.h

To see if your patch is correct, you need to map it to which libretro API calls happen when. At the end of the day it's all about libretro. Try to follow the existing code to libretro calls and see if the order violates libretro specification or conflicts with the order expected by the core.

@garbear
Copy link
Member

garbear commented Nov 22, 2018

I just re-read the PR and it seems I was very explicit in why the function was moved. Check the individual commit messages. If you still need help I don't have any development hardware but I can follow and explain the source code.

@KOPRajs
Copy link

KOPRajs commented Nov 22, 2018

I've read both the PR description and the individual commit messages. It seems that most of it applies to the split of the CGameClientInput::Initialize() to CGameClientInput::Start() and CGameClientInput::Deinitialize() to CGameClientInput::Stop() and to the changed order of related calls to solve the segfault caused by connecting the controllers too early. The above patch does not revert anything of that.

Then there is a statement saying: "This commit also corrects the order of init/deinit for other game add-on resources."
I believe it applies to the move of Streams().Initialize(), Streams().Deinitialize() and a few playstate variables. I can see why the Streams().Deinitialize() and the playstate variables were moved to the if statement but it is not clear why Streams().Initialize() was moved from InitializeGameplay() to OpenFile().

The above patch only reverts the Streams().Initialize(), the rest of the original commit is left intact.

@KOPRajs
Copy link

KOPRajs commented May 16, 2021

Since everything works for some time now I would consider closing this as solved.

Or are there any known drawbacks related to the revert?

@garbear
Copy link
Member

garbear commented May 17, 2021

Shall I close?

@KOPRajs
Copy link

KOPRajs commented May 17, 2021

We have moved Streams().Initialize() back to InitializeGameplay() before Leia release more than 2 years ago and I haven't heard about any related problems since then.

Maybe it is going to be revised when we finally get GL support (I really hope for this to happen as soon as possible).

@KOPRajs
Copy link

KOPRajs commented Nov 28, 2023

@garbear Well, it's been 5 years since we fixed this. Time to close? ;-)

@garbear garbear closed this as completed Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants