libretro / nxengine-libretro

Port of NxEngine to the libretro API. NXEngine is a Cave Story game engine clone
85 stars 89 forks source link

Music doesn't play, game crashes at various points #97

Open Jackson89524 opened 2 years ago

Jackson89524 commented 2 years ago

I found these issues when coming back to the game, did further testing on a fresh install of Retroarch and NXEngine + CaveStory. Music doesn't play in any instance from the title screen to mimiga village, sound effects work fine (once got glitched sounds upon picking up the health item) Game crashes upon certain conditions: After about 16 seconds in mimiga village after the cutscene, on the not-fresh install, game crashed after the end of the cutscene before the balcony misery boss fight and also twice in the waterways which I'm not sure why Note: the crashes completely shut down Retroarch, and running Doukutsu.exe directly seems to not have these issues.

Uukrull commented 2 years ago

This also happens to me with the win64 version of Retroarch, but if I compile the nxengine_libretro.dll myself it works without problems so something must be wrong with the buildbot.

Jackson89524 commented 2 years ago

Can I ask how? I'm also on win64, tried looking up for a way to do it but didn't find much. Edit: found this page, and was able to follow through to the end, just had to build from "Makefile", but I still had the no music issue with the dll I got. Could you share the dll you built? I'd like to use it until there's a solution

Uukrull commented 2 years ago

nxengine_libretro.zip

You can also use the core dll from version 1.10.3 if you don't care about the last commit https://github.com/libretro/nxengine-libretro/commit/bc692a392473a45f63cdccbb353c3445b530d671

Uukrull commented 2 years ago

btw, I'm using the mingw that comes installed for Kodi:

MINGW64_NT-10.0-19044 3.2.0-340.x86_64 2021-07-02 08:36 UTC x86_64 Msys

I don't know if that makes a difference.

Jackson89524 commented 2 years ago

I didn't know there was a way to find previous versions of cores, but your core seems to work. Thanks for helping me with this!

bslenul commented 2 years ago

Might be a Windows only issue? Musics play fine and no crash on my Android phone and my Linux Mint VM.

It's also fine on Windows if I build the core with DEBUG=1 or with -O1 or lower, not sure if this is helpful for the devs but I got this:

#0  drum_gen (num_samples=3087, m_channel=10) at nxengine/sound/org.cpp:682
        pos2 = 0
        iratio = <optimized out>
        chan = 0x7ffede13e4a0 <note_channel+800>
        audioval = <optimized out>
        volume_ratio = 0.49803921568627452
        wave = 232
        pos1 = 0
        i = 0
        volume_left_ratio = 1
        volume_right_ratio = 0
        chan = <optimized out>
        pos1 = <optimized out>
        pos2 = <optimized out>
        iratio = <optimized out>
        audioval = <optimized out>
        i = <optimized out>
        volume_ratio = <optimized out>
        volume_left_ratio = <optimized out>
        volume_right_ratio = <optimized out>
        wave = <optimized out>
#1  NextBeat (m=10) at nxengine/sound/org.cpp:861
        chan = 0x7ffede13e4a0 <note_channel+800>
        track = 0x7ffede10375c <song+400284>
        note = <optimized out>
        len = 3087
        chan = <optimized out>
        track = <optimized out>
        note = <optimized out>
        len = <optimized out>
#2  generate_music () at nxengine/sound/org.cpp:743
        m = 10
        beats_left = 2
        out_position = 6174
#3  0x00007ffeddfe8be5 in org_run () at nxengine/sound/org.cpp:705
No locals.
#4  0x00007ffeddfe6043 in run_tick () at nxengine/main.cpp:274
No locals.
#5  gameloop () at nxengine/main.cpp:170
No locals.
#6  run_main () at nxengine/main.cpp:245
No locals.
#7  0x00007ffeddfe597d in retro_run () at nxengine/libretro/libretro.cpp:325
        frame_cnt = 1198
        samples = {0, 0, 0, 0, 17376, 29951, 513, 0, 2768, 29958, 513, 0 <repeats 13 times>, 17184, 27003, 32759, 0, 16, 0, 0, 0, -2656, 29631, 40, 0, 17458, 26714, 32759, 0, 2768, 29958, 513, 0, -5728, 26865, 32759, 0, 0, 0, 0, 0, -2240, 29631, 40, 0, 15200, 26993, 32759, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 83, 0 <repeats 11 times>, -1, -1, 0, 0, -1, 0, 0, 0, 0, 16128, 0, 0, -1, -1, 0, 0, -1, 0, 0, 0, -1, -1, 0, 0, -1, 0, 0, 0, 0, 0, 3, 0, -2496, 29631, 40, 0, -20524, 26714, 32759, 0, 13184, 26995, 32759, 0, 83, 0, 513, 0, -1744, 29631, 40, 0, 0, 0, 0, 0, -2240, 29631, 40, 0, 15200, 26993, 32759, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 83, 0 <repeats 15 times>, 18896, 26993, 32759, 0, 17872, 26994, 32759, 0, 13184, 26995, 32759, 0, 29792, 0, 84, 0, 15781, 26970, 32759, 0, 25603, 26776, 32759, 0 <repeats 13 times>...}
        frames = <optimized out>
#8  0x00007ff76856000b in ?? ()
No symbol table info available.
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Info reg:

rax            0x0                 0
rbx            0xc10               3088
rcx            0xc10               3088
rdx            0x201096b528e       2203476251278
rsi            0x201096b528e       2203476251278
rdi            0x181e              6174
rbp            0x1820              0x1820
rsp            0x2873bff330        0x2873bff330
r8             0x1820              6176
r9             0x0                 0
r10            0x101040106ff0006   72343471473491974
r11            0xffff7b06          4294933254
r12            0x7ffede13e4a0      140732624266400
r13            0x181f              6175
r14            0x7c                124
r15            0x7ffede0a1bc0      140732623625152
rip            0x7ffeddfe7f7e      0x7ffeddfe7f7e <generate_music()+974>
eflags         0x10213             [ CF AF IF RF ]
cs             0x33                51
ss             0x2b                43
ds             0x2b                43
es             0x2b                43
fs             0x53                83
gs             0x2b                43
LibretroAdmin commented 2 years ago

I can confirm this to be the case. I get no more music on Windows, which definitely did work before. Perhaps an MXE toolchain issue? Compiling it locally also doesn't fix it except if I change optimization levels to -O1, which sucks as we'd be leaving a lot of nice optimizations on the table.

My GCC version on msys2/mingw-w64

$ gcc -v Using built-in specs. COLLECT_GCC=C:\msys64\mingw64\bin\gcc.exe COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/lto-wrapper.exe Target: x86_64-w64-mingw32 Configured with: ../gcc-12.1.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/include --libexecdir=/mingw64/lib --enable-bootstrap --enable-checking=release --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++,jit --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --disable-libstdcxx-pch --enable-lto --enable-libgomp --disable-multilib --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev3, Built by MSYS2 project' --with-bugurl=https://github.com/msys2/MINGW-packages/issues --with-gnu-as --with-gnu-ld --disable-libstdcxx-debug --with-boot-ldflags=-static-libstdc++ --with-stage1-ldflags=-static-libstdc++ Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.1.0 (Rev3, Built by MSYS2 project)

@Uukrull Can you tell us what your GCC version is?

Uukrull commented 2 years ago

@LibretroAdmin

$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-msys/10.2.0/lto-wrapper.exe Target: x8664-pc-msys Configured with: /c//S/gcc/src/gcc-10.2.0/configure --build=x86_64-pc-msys --prefix=/usr --libexecdir=/usr/lib --enable-bootstrap --enable-shared --enable-shared-libgcc --enable-static --enable-version-specific-runtime-libs --with-arch=x86-64 --with-tune=generic --disable-multilib --enable-__cxa_atexit --with-dwarf2 --enable-languages=c,c++,fortran,lto --enable-graphite --enable-threads=posix --enable-libatomic --enable-libgomp --disable-libitm --enable-libquadmath --enable-libquadmath-support --disable-libssp --disable-win32-registry --disable-symvers --with-gnu-ld --with-gnu-as --disable-isl-version-check --enable-checking=release --without-libiconv-prefix --without-libintl-prefix --with-system-zlib --enable-linker-build-id --with-default-libstdcxx-abi=gcc4-compatible --enable-libstdcxx-filesystem-ts Thread model: posix Supported LTO compression algorithms: zlib gcc version 10.2.0 (GCC)

LibretroAdmin commented 2 years ago

I came up with this diff patch which fixes the music on Windows. Can you guys verify if it takes care of the crashes experienced on your end as well?

If it does, then I will push this to master - https://gist.github.com/LibretroAdmin/7a638319d039bd25e3c33d25d344f9db

bslenul commented 2 years ago

Looks good, music is now playing properly and it doesn't crash anymore! 👍

LibretroAdmin commented 2 years ago

Pushed this commit - https://github.com/libretro/nxengine-libretro/commit/e271c6262d73f07e5d92d285503f1c049801c51a

@Jackson89524 Let me know if this can be closed after testing.

Jackson89524 commented 2 years ago

Just tested it, seems fine, no crash in Mimiga village and music plays, feel free to close!