Building emscripten with GLES is broken
Platform
libretro / Retroarch
Compiler and build tool versions
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.53 (ce5114bdd2175c7297583d3c25a53ca95d22f4ce)
Operating system version
Debian GNU/Linux bookworm 12.0 x86_64
Build commands used
Using the patches mentioned here for sub modules, and this commit, disabling GLES, then linking with RetroArch using gles2 causes PPSSPP to run almost flawlessly.
As far as I can tell the emulation itself runs perfectly, playable* as long as you don't need video. Much better than it was a few months ago when I originally tried getting it to run.
And here's the fun part, of course compiling without GLES and targeting gles2 wont work, that was just to get it to run at all.
Currently, if you build with GLES enabled (specifically if you pass the USING_GLES2 definition) the page will freeze upon load. I traced the freeze here where it seems to be waiting on another thread. This only happens when GLES is enabled, with it disabled the emulation runs as well as the browser can handle it, which is suspiring.
To build this:
-
git clone https://github.com/EmulatorJS/ppsspp.git -
git clone https://github.com/EmulatorJS/RetroArch.git -
git clone https://github.com/EmulatorJS/EmulatorJS.git -
cd ppsspp/libretro/ - Apply patches mentioned in #17779
-
emmake make clean && emmake make platform=emscripten -j$(nproc) -
cp ppsspp_libretro_emscripten.bc ../../RetroArch/dist-scripts/ -
cd ../../RetroArch/dist-scripts/ -
emmake ./dist-cores.sh emscripten clean - Open your file explorer and navigate to
EmulatorJS/data/cores/and open the .data file with 7zip, open the.jsfile (not.worker.js( in a text editor and search forasyncifyStubs. Remove any definitions of this. This errors because of a bug with emscripten where its defined but does not do anything. Removing this definition will fix the issue. - Download this zip to the
EmulatorJS/data/coresfolder - Launch your favorite web server pointing at the
EmulatorJSfolder. Be sure to set the headers mentioned here - Edit the core function to always return
psp. - Open a web browser and go to http://localhost:8080/index.html?debug=1&threads=1. It should warn you if threads is not properly enabled.
- Upload your rom to the page. It will automatically launch the game assuming you did step 13.
Through writing this (40-50 minutes) I've had ppsspp running in the browser with gles disabled (no video) and have had no crashes nor performance decreases (playing the title menu music). The only issue with the emscripten build target is gles.
A demo with gles disabled can be found here.
What happens
gles disabled log (working emulation, black screen): gles--disabled.log
gles enabled log (freezes page): gles-enabled.log
PPSSPP version affected
v1.17.1-11-gb41753896
Last working version
No response
Checklist
- [X] Test in the latest git build in case it's already fixed.
- [X] Make sure to run
git submodule update --init --recursivebefore building. - [X] Search for other reports of the same issue.
- [X] Try deleting the build directory and running the build again.
- [ ] Check GitHub Actions, which builds every merge and PR.
- [X] Include logs and help us reproduce.
Emscripten isn't a platform that the project (or at least I) care about, you're on your own. I'll leave the issue open, though.