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

PPSSPP libretro core crashes on wayland #12145

Closed
G-Ray opened this issue Jun 30, 2019 · 21 comments
Closed

PPSSPP libretro core crashes on wayland #12145

G-Ray opened this issue Jun 30, 2019 · 21 comments
Labels
Libretro Issue on Libretro but not all ports.

Comments

@G-Ray
Copy link

G-Ray commented Jun 30, 2019

What happens?

Using PPSSPP core, starting a game results in a crash:

[INFO] [GL]: Using 1 textures.
[INFO] [GL]: Loaded 1 program(s).
[INFO] [GL]: Initializing HW render (2048 x 2048).
[INFO] [GL]: Max texture size: 16384 px, renderbuffer size: 16384 px.
[INFO] [GL]: Supports FBO (render-to-texture).
[INFO] [Joypad]: Found joypad driver: "sdl2".
[INFO] [Font]: Using font rendering backend: bitmap.
[INFO] [Video]: Found display server: null
[libretro INFO] [G3D] Context reset
[libretro ERROR] [G3D] glewInit() failed.

The issue only occurs on Wayland.

What should happen?

ppsspp's core should not crash under wayland.

What hardware, operating system, and PPSSPP version?

Fedora 30, tested with multiple ppsspp cores versions from http://buildbot.libretro.com/nightly/linux/x86_64/

I guess this could be due to the version of glew headers installed on the buildbot ? But I can't find any documentation about the libretro's buildbot.

@orbea
Copy link
Contributor

orbea commented Jul 14, 2019

I guess this could be due to the version of glew headers installed on the buildbot ? But I can't find any documentation about the libretro's buildbot.

Does it happen if you build the core yourself?

@G-Ray
Copy link
Author

G-Ray commented Jul 19, 2019

I guess this could be due to the version of glew headers installed on the buildbot ? But I can't find any documentation about the libretro's buildbot.

Does it happen if you build the core yourself?

Yes, I built RetroArch and the core from sources, and get the same error log

@i30817
Copy link

i30817 commented Sep 16, 2019

Same experience. Build the one from here and from libretro, running it on a self compiled RA with :

./configure --enable-wayland --disable-discord --disable-x11 --disable-xinerama --disable-xvideo --disable-caca --disable-qt --enable-kms --enable-zlib --enable-7zip

So a setup without X11 (it slows down the very weak video card unacceptably in gnome 3 probably because it's running in XWayland).

I'm using the udev input driver though, and don't use sdl drivers 1 or 2.

@i30817
Copy link

i30817 commented Oct 4, 2019

https://www.khronos.org/opengl/wiki/OpenGL_Loading_Library#GLEW_.28OpenGL_Extension_Wrangler.29

GLEW up to version 1.13.0 has a problem with core contexts. It calls glGetString(GL_EXTENSIONS), which causes GL_INVALID_ENUM on GL 3.2+ core context as soon as glewInit() is called. It also doesn't fetch the function pointers. GLEW version 2.0.0+ uses glGetStringi instead. The only fix for earlier versions is to use glewExperimental:

edit: but:

apt-cache policy libglew-dev
libglew-dev:
  Installed: 2.1.0-4
  Candidate: 2.1.0-4
  Version table:
 *** 2.1.0-4 500
        500 http://pt.archive.ubuntu.com/ubuntu disco/universe amd64 Packages
        100 /var/lib/dpkg/status

@unknownbrackets
Copy link
Collaborator

If using a core profile, SetGLCoreContext(true) must be called to let PPSSPP know about this as noted here #10784 (comment). Not sure if libretro stuff is doing this properly.

-[Unknown]

@i30817
Copy link

i30817 commented Oct 5, 2019

Ah, if i disable EGL on the retroarch compile i need to also disable KMS. I'll try to disable both and build to see if that works.

Not that it helps the poor users that don't build, but hey.

edit: blackscreen, aka: 'null' driver. Of course. I'm pretty sure gl worked without falling back to egl before on this ancient gpu but...

@i30817
Copy link

i30817 commented Oct 7, 2019

Ok the 'root' cause of this and the other openlara problem is probably this (if you're using wayland like i am):

https://unix.stackexchange.com/questions/511134/why-wayland-is-using-opengl-es-instead-of-opengl

to remove awkward dependencies (X11), wayland uses currently only opengl-es, which probably means RA is probably using it in 'on the sly' my case where i compiled without X11 (X11 emulation slowed down the menu) and with wayland support and i still used video_driver="gl" on the config.

When i just now tried to remove even opengl-es (and leave opengl) with --disable-egl RA couldn't even start graphics

[WARN] Failed to bind API (#1, version 0.0) on context driver "wayland".
[INFO] [GL]: Found GL context: null
[WARN] Failed to bind API (#1, version 0.0) on context driver "wayland".
[INFO] [GL]: Found GL context: null

Which looks to be supporting evidence that the 'gl' driver is more like a 'gles/egl' driver on this situation and as was already mentioned by @unknownbrackets , PPSSPP doesn't like that without a further setup.

@unknownbrackets
Copy link
Collaborator

Well, in theory we detect GLES if we're given such a context. We should support either. In fact, on Windows you need only enable this flag:

static const int simulateGLES = false;

And you'll be able to use a GLES context. That doesn't actually require setting the core context flag (a core context is a desktop GL concept.)

That said, the libretro code seems to only try glew when USING_GLES2 is not defined, so I assume it isn't:

#if !defined(IOS) && !defined(USING_GLES2)

The libretro code never sets experimental:
https://github.com/hrydgard/ppsspp/search?q=glewexperimental&unscoped_q=glewexperimental

CheckGLExtensions() ought to do the right thing if given a GLES context, but glewInit() won't without setting that.

-[Unknown]

@i30817
Copy link

i30817 commented Oct 10, 2019

I tried

glewExperimental = true;
if (glewInit() != GLEW_OK) {
     ERROR_LOG(G3D, "glewInit() failed.\n");
     return;
}

in LibretroGLContext.cpp

But it didn't work, so i'm giving up and leaving this to someone that knows what they're doing debugging. Bug manifests in a terrible card on a RA compile without X11 and with wayland running a recently compiled ppsspp core got from libretro-super.

I also tried compiling retroarch with X11 support, but that also didn't work. Which might not be surprising since it said this [INFO] [GL]: Found GL context: wayland.

I didn't try to run it on GNOME3 on X11 yet, but i expect it to work. edit: it does... until it crashes on savestate but that is another bug already reported.

I wish RA was a rust project...

@i30817
Copy link

i30817 commented Nov 20, 2019

Heads up, it's also possible to avoid this bug by building RA with wayland disabled and x11 enabled, though the cores will be slower (because they're running in XWayland)

Both enabled won't work, because RA always chooses the 'native' driver backend.

So now i have two retroarch executables with different bash Aliases for when i want to run ppsspp. Meh.

@i30817
Copy link

i30817 commented Jul 22, 2020

Tried this again. Now the core doesn't work even on the X11 compile. Both crash in the same way.

If i disabled egl in the retroarch configure, both blackscreen (but the game is running which is easy to see with the menu sound) and present this (didn't bother with full logs):

ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
I: gpu_features.cpp:175: GPU Vendor : X.Org ; renderer: AMD RV710 (DRM 2.50.0 / 5.3.0-62-generic, LLVM 9.0.0) version str: 3.0 Mesa 19.2.8 ; GLSL version str: 1.30
I: GLRenderManager.cpp:201: Running first frame (0)
I: GLRenderManager.cpp:230: GL submission thread paused. Frame=0
I: GLRenderManager.cpp:138: ThreadEnd
I: GPU_GLES.cpp:312: GPU_GLES: DeviceLost

@soredake
Copy link

@tbocek can you create a pull request with your commit?

@tbocek
Copy link
Contributor

tbocek commented Oct 29, 2020

Created a pull request, please test first! -> #13598

@tbocek
Copy link
Contributor

tbocek commented Oct 31, 2020

@soredake @i30817, did you test this pull request: #13598 does it work? My last testing was back in May, so its not up to date.

@i30817
Copy link

i30817 commented Oct 31, 2020

I cannot test atm, my main computer and drive had a mechanical failure.

@unknownbrackets
Copy link
Collaborator

This issue is being closed because it hasn't been updated with feedback.

It's hard to tell when fixes in PPSSPP might fix other games, and sometimes certain settings or cheats may cause bugs that can't be fixed.

If you have more information or can confirm it still happens in the latest git builds, please reply to this issue and it'll be reopened. If you have a new issue with the same game, just create a new issue instead.

-[Unknown]

@xade93
Copy link

xade93 commented Jan 22, 2022

Can confirm the issue persists on my Arch, with retroarch v1.9.14 and libretro-ppsspp 31516-1.
On my Wayland, retroarch still crash when attempting to load ppsspp core.

@unknownbrackets
Copy link
Collaborator

I'm not sure what "31516-1" means, and 31516 doesn't seem to be a commit.

I'll reopen, but since someone already made a change to fix this it'd be best to provide additional information.

-[Unknown]

@i30817
Copy link

i30817 commented Jan 22, 2022

I have a new computer and i'm running on X so this might not mean anything but i can run gl now without falling back to glcore.

I usually force vulkan but i renamed the config/PPSSPP dir for this run, changed the main RA driver to gl, turned off ' cores can change driver ' RA option, quit and started RA again and started a psp game. It ran and the driver was gl in retroarch settings.

I'm in x. Since ubuntu lts is on x.

Restarting or closing the core crashes though.

Anyway, output:

output
i3@sleipnir:~/.config/retroarch/system$ retroarch 
[INFO] RetroArch 1.9.14 (Git 87c5720988)
[INFO] === Build =======================================
[INFO] CPU Model Name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
[INFO] Capabilities:  MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE4.2 AES AVX
[INFO] Built: Jan  8 2022
[INFO] Version: 1.9.14
[INFO] Git: 87c5720988
[INFO] =================================================
[INFO] [Input]: Found input driver: "x".
[INFO] [Environ]: SET_PIXEL_FORMAT: RGB565.
[INFO] [Core]: Version of libretro API: 1, Compiled against API: 1
[INFO] [Audio]: Set audio input rate to: 48000.00 Hz.
[INFO] [Video]: Set video size to: fullscreen.
[INFO] [GLX]: GLX_EXT_swap_control_tear supported.
[INFO] [GL]: Found GL context: "x".
[INFO] [GL]: Detecting screen resolution: 1920x1080.
[INFO] [GLX]: Window manager is GNOME Shell.
[INFO] [XINERAMA]: Xinerama version: 1.1.
[INFO] [XINERAMA]: Xinerama screens: 1.
[INFO] [GLX]: Using Xinerama on screen #0.
[INFO] [GLX]: X = 0, Y = 0, W = 1920, H = 1080.
[INFO] [GLX]: Using windowed fullscreen.
[INFO] [GLX]: Found swap function: glXSwapIntervalEXT.
[INFO] [GL]: Vendor: NVIDIA Corporation, Renderer: NVIDIA GeForce MX150/PCIe/SSE2.
[INFO] [GL]: Version: 4.6.0 NVIDIA 470.86.
[INFO] [GL]: Using resolution 1920x1080.
[INFO] [GL]: Default shader backend found: glsl.
[INFO] [Shader driver]: Using GLSL shader backend.
[INFO] [GLSL]: Checking GLSL shader support ...
[WARN] [GL]: Stock GLSL shaders will be used.
[INFO] [GLSL]: Found GLSL vertex shader.
[INFO] [GLSL]: Found GLSL fragment shader.
[INFO] [GLSL]: Linking GLSL program.
[INFO] [GLSL]: Found GLSL vertex shader.
[INFO] [GLSL]: Found GLSL fragment shader.
[INFO] [GLSL]: Linking GLSL program.
[INFO] [GLSL]: Found GLSL vertex shader.
[INFO] [GLSL]: Found GLSL fragment shader.
[INFO] [GLSL]: Linking GLSL program.
[INFO] [GL]: Using 4 textures.
[INFO] [GL]: Loaded 1 program(s).
[INFO] [GL]: Using GL_RGB565 for texture uploads.
[INFO] [Joypad]: Found joypad driver: "udev".
[INFO] [Font]: Using font rendering backend: "freetype".
[INFO] [X11]: Suspending screensaver (X11, xdg-screensaver).
[INFO] [Video]: Found display server: "x11".
[INFO] [PulseAudio]: Requested 24960 bytes buffer, got 18720.
[INFO] [Display]: Found display driver: "gl".
[INFO] [SRAM]: SRAM will not be saved.
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_history.lpl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_music_history.lpl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_video_history.lpl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_image_history.lpl".
[INFO] [Playlist]: Loading favorites file: "/home/i3/.config/retroarch/content_favorites.lpl".
[INFO] [Input]: Grab mouse state => ON
[INFO] [PulseAudio]: Pausing.
[INFO] [GLX]: Resized fullscreen resolution to 1920x1080.
[INFO] [Playlist]: Written to playlist file: /home/i3/.config/retroarch/playlists/Sony - PlayStation Portable.lpl
[INFO] [Core]: Using content: "/media/i3/Mordred/Games/Sony - PlayStation Portable/Final Fantasy IV - The Complete Collection (USA) (En,Ja,Fr) (PSP) (PSN)/Final Fantasy IV - The Complete Collection (USA) (En,Ja,Fr) (PSP) (PSN).iso".
[INFO] [Core]: Content ran for a total of: 00 hours, 00 minutes, 00 seconds.
[INFO] [Core]: Unloading core..
[INFO] [Core]: Unloading core symbols..
[INFO] [XINERAMA]: Xinerama version: 1.1.
[INFO] [XINERAMA]: Xinerama screens: 1.
[INFO] [XINERAMA]: Saved monitor #0.
[INFO] [Video]: Does not have enough samples for monitor refresh rate estimation. Requires to run for at least 4096 frames.
[INFO] RetroArch 1.9.14 (Git 87c5720988)
[INFO] === Build =======================================
[INFO] CPU Model Name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
[INFO] Capabilities:  MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4 SSE4.2 AES AVX
[INFO] Built: Jan  8 2022
[INFO] Version: 1.9.14
[INFO] Git: 87c5720988
[INFO] =================================================
[INFO] [Input]: Found input driver: "x".
[INFO] [Core]: Loading dynamic libretro core from: "/home/i3/.config/retroarch/cores/ppsspp_libretro.so"
[INFO] [Overrides]: No core-specific overrides found at "/home/i3/.config/retroarch/config/PPSSPP/PPSSPP.cfg".
[INFO] [Overrides]: No content-dir-specific overrides found at "/home/i3/.config/retroarch/config/PPSSPP/Final Fantasy IV - The Complete Collection (USA) (En,Ja,Fr) (PSP) (PSN).cfg".
[INFO] [Overrides]: No game-specific overrides found at "/home/i3/.config/retroarch/config/PPSSPP/Final Fantasy IV - The Complete Collection (USA) (En,Ja,Fr) (PSP) (PSN).cfg".
[INFO] [Environ]: SET_VARIABLES.
[INFO] [Remaps]: Remap directory: "/home/i3/.config/retroarch/remaps".
[INFO] [Overrides]: Redirecting save file to "/home/i3/.config/retroarch/saves/Final Fantasy IV - The Complete Collection (USA) (En,Ja,Fr) (PSP) (PSN).srm".
[INFO] [Overrides]: Redirecting save state to "/home/i3/.config/retroarch/states/Final Fantasy IV - The Complete Collection (USA) (En,Ja,Fr) (PSP) (PSN).state".
ThreadManager::Init(compute threads: 8, all: 12)
[INFO] [Environ]: SET_INPUT_DESCRIPTORS:
[INFO] [Environ]: GET_LOG_INTERFACE.
[libretro ERROR] [IO] Missing filesystem for lang/.ini
[libretro INFO] [G3D] Longest display side: -1 pixels. Choosing scale 1
[libretro ERROR] [IO] Missing filesystem for 'langregion.ini'
[libretro ERROR] [LOADER] Failed to read /controls.ini. Setting controller config to default.
[INFO] [Environ]: GET_USERNAME: "".
[INFO] [Environ]: SYSTEM_DIRECTORY: "/home/i3/.config/retroarch/system".
[INFO] [Environ]: GET_SAVE_DIRECTORY.
[INFO] [Content]: Content loading skipped. Implementation will load it on its own.
[INFO] [Environ]: SET_PIXEL_FORMAT: XRGB8888.
[INFO] [Environ]: GET_PREFERRED_HW_RENDER, video driver name: gl.
[INFO] [Environ]: GET_PREFERRED_HW_RENDER - Context callback set to RETRO_HW_CONTEXT_OPENGL.
[INFO] [Environ]: SET_HW_RENDER, context type: gl.
[INFO] Requesting OpenGL context.
[INFO] Reached end of SET_HW_RENDER.
[INFO] [Environ]: GET_LANGUAGE: "0".
[INFO] [State]: found_last_state_slot: #0
[INFO] [SRAM]: Skipping SRAM load.
[INFO] [Core]: Version of libretro API: 1, Compiled against API: 1
[INFO] [Audio]: Set audio input rate to: 44149.88 Hz.
[INFO] [Video]: Set video size to: fullscreen.
[INFO] [Video]: Using HW render, OpenGL driver forced.
[INFO] [Video]: Using configured "gl" driver for GL HW render.
[INFO] [GLX]: GLX_EXT_swap_control_tear supported.
[INFO] [GL]: Found GL context: "x".
[INFO] [GL]: Detecting screen resolution: 1920x1080.
[INFO] [GLX]: Window manager is GNOME Shell.
[INFO] [XINERAMA]: Xinerama version: 1.1.
[INFO] [XINERAMA]: Xinerama screens: 1.
[INFO] [GLX]: Using Xinerama on screen #0.
[INFO] [GLX]: X = 0, Y = 0, W = 1920, H = 1080.
[INFO] [GLX]: Using windowed fullscreen.
[INFO] [GLX]: Creating shared HW context.
[INFO] [GLX]: Found swap function: glXSwapIntervalEXT.
[INFO] [GL]: Vendor: NVIDIA Corporation, Renderer: NVIDIA GeForce MX150/PCIe/SSE2.
[INFO] [GL]: Version: 4.6.0 NVIDIA 470.86.
[INFO] [GL]: Using resolution 1920x1080.
[INFO] [GL]: Default shader backend found: glsl.
[INFO] [Shader driver]: Using GLSL shader backend.
[INFO] [GLSL]: Checking GLSL shader support ...
[WARN] [GL]: Stock GLSL shaders will be used.
[INFO] [GLSL]: Found GLSL vertex shader.
[INFO] [GLSL]: Found GLSL fragment shader.
[INFO] [GLSL]: Linking GLSL program.
[INFO] [GLSL]: Found GLSL vertex shader.
[INFO] [GLSL]: Found GLSL fragment shader.
[INFO] [GLSL]: Linking GLSL program.
[INFO] [GLSL]: Found GLSL vertex shader.
[INFO] [GLSL]: Found GLSL fragment shader.
[INFO] [GLSL]: Linking GLSL program.
[INFO] [GL]: Using 1 textures.
[INFO] [GL]: Loaded 1 program(s).
[INFO] [GL]: Initializing HW render (512x512).
[INFO] [GL]: Max texture size: 32768 px, renderbuffer size: 32768 px.
[INFO] [GL]: Supports FBO (render-to-texture).
[INFO] [Joypad]: Found joypad driver: "udev".
[INFO] [Font]: Using font rendering backend: "freetype".
[INFO] [X11]: Suspending screensaver (X11, xdg-screensaver).
[INFO] [Video]: Found display server: "x11".
[INFO] [PulseAudio]: Requested 24960 bytes buffer, got 18720.
[INFO] [Display]: Found display driver: "gl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_history.lpl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_music_history.lpl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_video_history.lpl".
[INFO] [Playlist]: Loading history file: "/home/i3/.config/retroarch/content_image_history.lpl".
[INFO] [Playlist]: Loading favorites file: "/home/i3/.config/retroarch/content_favorites.lpl".
[INFO] [Playlist]: Written to playlist file: /home/i3/.config/retroarch/content_history.lpl
[INFO] [Video]: Frame delay reset to 8.
[INFO] [GLX]: Resized fullscreen resolution to 1920x1080.
[libretro ERROR] [SCEUTIL] 80111102=sceUtilityLoadModule(00000300): already loaded
[libretro ERROR] [SCEUTIL] 80111102=sceUtilityLoadModule(00000301): already loaded
[libretro ERROR] [SCEUTIL] 80111102=sceUtilityLoadModule(00000302): already loaded
[INFO] [Video]: Frame delay decrease by 1 to 7 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 6 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 5 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 4 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 3 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 2 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 1 due to frame time: 24996 > 16664.
[INFO] [Video]: Frame delay decrease by 1 to 0 due to frame time: 24996 > 16664.
[libretro ERROR] [SCEUTIL] 80111102=sceUtilityLoadModule(00000303): already loaded
[libretro ERROR] [SCEKERNEL] 80020197=sceKernelTerminateThread(352): cannot terminate current thread
[libretro ERROR] [SCEKERNEL] 80020197=sceKernelTerminateThread(349): cannot terminate current thread
[INFO] [PulseAudio]: Pausing.
[INFO] [Core]: Content ran for a total of: 00 hours, 00 minutes, 17 seconds.
[INFO] [Core]: No content, starting dummy core.
[INFO] [Core]: Content ran for a total of: 00 hours, 00 minutes, 00 seconds.



@gouchi
Copy link
Contributor

gouchi commented Jun 2, 2024

@G-Ray @xade93 Can you confirm it is working using latest update.

I confirm it is working on Wayland. I compiled it with ./configure --disable-x11 --disable-qt --enable-wayland

ra-wayland-ppsspp

Thank you.

@gouchi
Copy link
Contributor

gouchi commented Sep 8, 2024

@unknownbrackets @hrydgard I think we can close this issue.

Thank you.

@hrydgard hrydgard closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Libretro Issue on Libretro but not all ports.
Projects
None yet
Development

No branches or pull requests

10 participants