devkitPro / pacman-packages

https://devkitpro.org
135 stars 106 forks source link

MPV displays blue screen during playback #303

Closed xfangfang closed 1 year ago

xfangfang commented 1 year ago

Previous feedback

~There is a commit message that reads `devkitPPC uses custom malloc lock/unlock`, but it has also been committed to the `devkitPro` branch, resulting in the use of malloc in libnx not being thread safe.~ ~Related commits that caused the problem to occur:~ https://github.com/devkitPro/newlib/commit/7be6e90210924339291f6cc631dda7beeaf81f8d https://github.com/devkitPro/newlib/commit/61f3a5d667de9ffe045263a24b8c6af6f8eb21e9 ~This has led to the MPV related issues mentioned in this:https://github.com/devkitPro/pacman-packages/issues/302~ I thought that the malloc lock was not set correctly in libnx, but later I realized it was my fault.

Details

  1. MPV will use multiple threads to call vsnprintf. Now it keeps throw errors (data abort) in vsnprintf. This function should be thread safe, I suspect there may be a problem with it .
  2. switch-mpv relies on SDL to play audio, and updates to switch-sdl2 cause audio noise when switching videos. This issue disappeared after downgrading switch-sdl2 to 2.0.14-1. It seems that a better solution is to reimplement audio playback from within MPV instead of relying on SDL. I will implement this when I have time.
xfangfang commented 1 year ago

I'm sorry to bother you again, but I think the issue with MPV should be related to the changes in newlib. The location of each crash may not be the same, but ultimately it is vsnprintf that reports an error. If I use the previous image(devkitpro/devkita64:20221113) to compile, there is no such issue.

Crash report: 2168-0002

crash always at main thread

# this is my code to call mpv to draw on the screen
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x24a7a0
0x000000000024a7a0: MPVCore::openglDraw(brls::Rect, float) at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7a2254
0x00000000007a2254: mpv_render_context_render at :?

# mpv internal calls
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7c08e4
0x00000000007c08e4: render at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7b0194
0x00000000007b0194: gl_video_render_frame at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7aed24
0x00000000007aed24: pass_draw_to_screen at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7ae78c
0x00000000007ae78c: pass_render_frame_dumb at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7a896c
0x00000000007a896c: copy_image at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x7ba9a0
0x00000000007ba9a0: gl_sc_addf at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x80fe48
0x000000000080fe48: bstr_xappend_vasprintf at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x14f3610
0x00000000014f3610: vsnprintf at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x14f3560
0x00000000014f3560: _vsnprintf_r at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x14ec9c0
0x00000000014ec9c0: _svfprintf_r at :?
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x1515c40
0x0000000001515c40: _dtoa_r at :?

# PC
$ aarch64-none-elf-addr2line -e wiliwili.elf -f -p -C -a 0x1517068
0x0000000001517068: _Balloc at :?
WinterMute commented 1 year ago

fixed with devkitA64 r22.1