xfangfang / wiliwili

第三方B站客户端,目前可以运行在PC全平台、PSVita、PS4 、Xbox 和 Nintendo Switch上
https://xfangfang.github.io/wiliwili
GNU General Public License v3.0
3k stars 147 forks source link

PC 端点击视频后闪退 #289

Closed TakChen closed 4 months ago

TakChen commented 4 months ago

描述

Win 11 CPU 5800 GPU: AMD 7800xt 下载,打开后, 随便点一个视频, 直接闪退

版本: 1.3.0 以及 GithubAction #804 的 build

复现步骤

GIF: screenshots

其他信息

后面尝试使用 命令行+参数运行 .\wiliwili.exe -d -v -t -o 打出日志文件 日志中并没有发现什么有用的信息

wiliwili_config.json

wiliwili.log

xfangfang commented 4 months ago

看 log,可能是这一段代码间的某个位置出的问题: https://github.com/xfangfang/wiliwili/blob/2183dd1bf3ca2648961be47cc11499edce1d018f/wiliwili/source/view/mpv_core.cpp#L297-L406

如果方便的话可以在那个区域加点 log 调试一下。

804 的 build 有四个 windows 版,都存在同样的问题吗?尤其是 x86_64 的 d3d 和 gl 这两个。

TakChen commented 4 months ago

我这边用了 x64 的 D3D & GL 版都试过了, 一样的现象;

而且我发现配置播放设置的地方也闪退, 我都不知道是故意的还是本来就这么设计的 https://github.com/xfangfang/wiliwili/assets/10719409/609cc188-3bd4-4085-9e57-6a98dcb0d0a5 主要是播放设置的前三个, 后面的就没有闪退了

修改编码缓存闪退.log 修改硬件加速闪退.log

xfangfang commented 4 months ago

请问您上面截图用的是哪个版本的 wiliwili

TakChen commented 4 months ago

我这边重新梳理了一下,

下载了 Release version v1.3.0 的 wiliwili-Windows-x86_64.zip运行, 会有

  1. 视频点击播放会闪退的问题
  2. 设置中调整播放设置的前3个选项会有问题

然后我尝试用另一台电脑(ThinkPad 14 AMD 5800h)运行 同一个版本, 没有出现相同问题;

没办法,我只好在我有问题的机子上安装环境手动build;

# Windows: install dependencies (MSYS2 MinGW64)
# 拉取代码
git clone --recursive https://github.com/xfangfang/wiliwili.git
cd wiliwili
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-make \
  git mingw-w64-x86_64-mpv mingw-w64-x86_64-libwebp
cmake -B build -G "MinGW Makefiles" -DPLATFORM_DESKTOP=ON
mingw32-make -C build wiliwili -j$(nproc)
cd build

启动exe文件, 更改设置中的硬件编码选项

$ ./wiliwili.exe
14:41:51.286[INFO] wiliwili v1.3.0
14:41:51.287[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili\build
14:41:51.287[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
14:41:51.287[INFO] cookie: DedeUserID:0
14:41:51.287[INFO] refreshToken:
14:41:51.287[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,1551x801","limited_fps":0,"player_hwdec":false,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
14:41:51.288[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:41:51.288[INFO] Load window state: 1649x860,1551x801
14:41:51.288[INFO] Set app theme: Dark
14:41:51.288[INFO] Set app locale: zh-Hans
14:41:51.294[INFO] Using platform GLFW
14:41:51.401[INFO] glfw: GL Vendor: ATI Technologies Inc.
14:41:51.401[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
14:41:51.401[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
14:41:51.401[INFO] glfw: GLFW Version: 3.4.0
14:41:51.430[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
14:41:51.631[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
14:41:51.631[INFO] Using internal font: ./resources/font/switch_font.ttf
14:41:51.639[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
14:41:51.642[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
14:41:51.642[INFO] Load emoji font: ./resources/font/emoji.ttf
14:41:51.643[INFO] Load keymap icon: ./resources/font/keymap_xbox.ttf
14:41:51.643[INFO] createWindow done
14:41:51.803[INFO] max_thread_num: 4
14:41:55.032[INFO] App is up to date
14:41:56.268[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:41:56.271[INFO] MPV hardware decode: auto-safe
14:41:56.275[INFO] MPV Version: mpv 0.37.0
14:41:56.275[INFO] FFMPEG Version: 6.1.1
14:41:56.277[INFO] uninitialize Video
14:41:56.277[INFO] trying free mpv context
14:41:56.277[INFO] trying terminate mpv
14:41:56.279[INFO] MPV hardware decode: auto-safe
14:41:56.281[INFO] MPV Version: mpv 0.37.0
14:41:56.281[INFO] FFMPEG Version: 6.1.1
14:41:56.282[INFO] Set shader []:
14:41:56.283[INFO] disableDimming: false
14:41:59.038[INFO] Window position changed to 427x779
14:42:01.200[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:42:01.200[INFO] uninitialize Video
14:42:01.200[INFO] trying free mpv context
14:42:01.200[INFO] trying terminate mpv
14:42:01.205[INFO] MPV Version: mpv 0.37.0
14:42:01.205[INFO] FFMPEG Version: 6.1.1
14:42:01.206[INFO] Set shader []:
14:42:01.206[INFO] disableDimming: false
14:42:01.983[ERROR] report event error: 0
14:42:04.750[INFO] Save window state: 0,1649x860,427x779
14:42:04.750[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:42:04.751[INFO] disableDimming: false
14:42:04.751[INFO] disableDimming: false
14:42:04.751[INFO] disableDimming: false
14:42:04.751[INFO] Exiting...
14:42:05.035[INFO] uninitialize Video
14:42:05.036[INFO] trying free mpv context
14:42:05.036[INFO] trying terminate mpv

没有复现上述问题

然后我执行 Release 中下载的exe, 更改设置中的硬件编码选项

$ ./wiliwili-v.1.3.0-github-release.exe
14:43:34.144[INFO] wiliwili v1.3.0
14:43:34.146[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili\build
14:43:34.146[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
14:43:34.146[INFO] cookie: DedeUserID:0
14:43:34.146[INFO] refreshToken:
14:43:34.146[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,427x779","limited_fps":0,"player_hwdec":false,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
14:43:34.146[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:43:34.146[INFO] Load window state: 1649x860,427x779
14:43:34.147[INFO] Set app theme: Dark
14:43:34.147[INFO] Set app locale: zh-Hans
14:43:34.155[INFO] Using platform GLFW
14:43:34.259[INFO] glfw: GL Vendor: ATI Technologies Inc.
14:43:34.259[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
14:43:34.259[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
14:43:34.259[INFO] glfw: GLFW Version: 3.4.0
14:43:34.286[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
14:43:34.461[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
14:43:34.461[INFO] Using internal font: @res/font/switch_font.ttf
14:43:34.466[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
14:43:34.469[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
14:43:34.469[INFO] Load keymap icon: @res/font/keymap_xbox.ttf
14:43:34.469[INFO] createWindow done
14:43:34.620[INFO] max_thread_num: 4
14:43:37.817[INFO] App is up to date
14:43:44.893[ERROR] report event error: 0
14:43:46.385[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:43:46.400[INFO] Load libmpv-2.dll, size: 27563472
14:43:46.403[INFO] MPV hardware decode: auto-safe

崩了, 发现日志中有个 Load libmpv-2.dll, size: 27563472,

我去查了一下, 发现libmpv-2.dll大小对不上啊;

$ ls ${MINGW_PREFIX}/bin/libmpv-2.dll -l
-rwxr-xr-x 1 Tak Chen Tak Chen 2896541 Nov 24 23:02 /mingw64/bin/libmpv-2.dll
$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.37.0-1

然后我去 GitHub action build #746 看了下 Workflow file

发现 build 里面用的是 0.36 的 版本 https://github.com/xfangfang/wiliwili/actions/runs/7496862718/workflow#L147

于是我本地下载安装之后

curl -LO https://github.com/xfangfang/wiliwili/releases/download/v0.1.0/${MINGW_PACKAGE_PREFIX}-mpv-0.36.0-3-any.pkg.tar.zst
pacman -U --noconfirm *.pkg.tar.zst
$ ls ${MINGW_PREFIX}/bin/libmpv-2.dll -l
-rwxr-xr-x 1 Tak Chen Tak Chen 27563472 Jan 11 15:06 /mingw64/bin/libmpv-2.dll
$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.36.0-3

libmpv-2.dll 的大小对上了;

于是执行 我本地build的 exe, 就闪退了

$ ./wiliwili.exe
14:52:51.635[INFO] wiliwili v1.3.0
14:52:51.637[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili\build
14:52:51.637[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
14:52:51.637[INFO] cookie: DedeUserID:0
14:52:51.637[INFO] refreshToken:
14:52:51.637[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,427x779","limited_fps":0,"player_hwdec":true,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
14:52:51.637[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
14:52:51.637[INFO] Load window state: 1649x860,427x779
14:52:51.638[INFO] Set app theme: Dark
14:52:51.638[INFO] Set app locale: zh-Hans
14:52:51.644[INFO] Using platform GLFW
14:52:51.814[INFO] glfw: GL Vendor: ATI Technologies Inc.
14:52:51.814[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
14:52:51.815[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
14:52:51.815[INFO] glfw: GLFW Version: 3.4.0
14:52:51.844[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
14:52:52.014[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
14:52:52.014[INFO] Using internal font: ./resources/font/switch_font.ttf
14:52:52.021[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
14:52:52.026[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
14:52:52.026[INFO] Load emoji font: ./resources/font/emoji.ttf
14:52:52.027[INFO] Load keymap icon: ./resources/font/keymap_xbox.ttf
14:52:52.027[INFO] createWindow done
14:52:52.181[INFO] max_thread_num: 4
14:52:55.365[INFO] App is up to date
14:52:55.994[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json

后面我重新安装回 mingw-w64-x86_64-mpv-0.37 的版本 , 更改设置, 视频播放 都正常了

总结

libmpv-2.dll 0.36 的版本在某些 window机器上会出现崩溃问题

xfangfang commented 4 months ago

非常感谢详细反馈! libmpv-2.dll 用的是 @dragonflylee 编译的精简版 mpv,原版mpv太大了不适合放在应用内,可能要麻烦他来看看具体的原因了。

在这个评论里 https://github.com/xfangfang/wiliwili/issues/289#issuecomment-1962412990 有我指出来的问题发生的位置,如果您有时间,可以逐行添加log,看看具体在哪个位置发生的崩溃,这应该对排查问题帮助很大。

xfangfang commented 4 months ago

另外一个可以尝试的事是在 https://sourceforge.net/projects/mpv-player-windows/files/libmpv/ 下载官方编译的mpv,找0.36.0发布时间附近的,比如:mpv-dev-x86_64-20230806-git-6729285.7z,本地编译运行时直接将下载的 dll 放在软件同目录即可。(注意检查 log 看是否加载了正确的 dll)

这个操作的目的主要是看看这个问题是不是 0.36.0本身导致的,如果官方的 0.36.0 本身就在你电脑上有问题,那应该更新一下版本就可以了。

TakChen commented 4 months ago

好像不太好找,我这边的做法是:

我看到是 0.36.0-3的版本,

curl -LO https://github.com/xfangfang/wiliwili/releases/download/v0.1.0/${MINGW_PACKAGE_PREFIX}-mpv-0.36.0-3-any.pkg.tar.zst

所以我去https://packages.msys2.org/package/mingw-w64-x86_64-mpv?repo=mingw64

这里下载了

https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpv-0.36.0-3-any.pkg.tar.zst

0.36.0-3 的版本安装, 运行, 没有问题;

$ wget https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-mpv-0.36.0-3-any.pkg.tar.zst
$ pacman -U mingw-w64-x86_64-mpv-0.36.0-3-any.pkg.tar.zst
$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.36.0-3
$ ./wiliwili.exe
16:18:09.883[INFO] wiliwili v1.3.0
16:18:09.885[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili\build
16:18:09.885[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
16:18:09.885[INFO] cookie: DedeUserID:0
16:18:09.885[INFO] refreshToken:
16:18:09.885[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,427x779","limited_fps":0,"player_hwdec":true,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
16:18:09.885[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
16:18:09.885[INFO] Load window state: 1649x860,427x779
16:18:09.886[INFO] Set app theme: Dark
16:18:09.886[INFO] Set app locale: zh-Hans
16:18:09.894[INFO] Using platform GLFW
16:18:10.075[INFO] glfw: GL Vendor: ATI Technologies Inc.
16:18:10.075[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
16:18:10.075[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
16:18:10.075[INFO] glfw: GLFW Version: 3.4.0
16:18:10.103[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
16:18:10.277[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
16:18:10.277[INFO] Using internal font: @res/font/switch_font.ttf
16:18:10.282[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
16:18:10.285[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
16:18:10.285[INFO] Load keymap icon: @res/font/keymap_xbox.ttf
16:18:10.285[INFO] createWindow done
16:18:10.452[INFO] max_thread_num: 4
16:18:13.595[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
16:18:13.620[INFO] Load libmpv-2.dll, size: 2896541
16:18:13.627[INFO] MPV Version: mpv 0.37.0
16:18:13.627[INFO] FFMPEG Version: 6.1.1
16:18:13.628[INFO] uninitialize Video
16:18:13.628[INFO] trying free mpv context
16:18:13.628[INFO] trying terminate mpv
16:18:13.633[INFO] MPV Version: mpv 0.37.0
16:18:13.633[INFO] FFMPEG Version: 6.1.1
16:18:13.633[INFO] Set shader []:
16:18:13.634[INFO] disableDimming: false
16:18:13.637[INFO] App is up to date
16:18:16.938[INFO] Save window state: 0,1649x860,427x779
16:18:16.938[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
16:18:16.938[INFO] disableDimming: false
16:18:16.938[INFO] disableDimming: false
16:18:16.938[INFO] Exiting...
16:18:17.012[INFO] uninitialize Video
16:18:17.012[INFO] trying free mpv context
16:18:17.013[INFO] trying terminate mpv
16:18:17.039[INFO] mainLoop done
xfangfang commented 4 months ago

16:18:13.627[INFO] MPV Version: mpv 0.37.0 16:18:13.627[INFO] FFMPEG Version: 6.1.1

看log 应该加载的还是 0.37,mpv_bundle_dll 这个编译选项的主要目的是打包时候使用的,本地测试跑代码其实不需要把mpv打包进wiliwili.exe里。

TakChen commented 4 months ago

不好意思, 因为我刚刚想尝试给自己打个独立包给自己用, 结果报libsharpyuv-0.dll & libwebp-7.dll 找不到; 然后我就以为其他的DLL 也没打包进去, 就直接拿去测了.


我重新测试了一下

## mpv-0.36, 不打包
pacman -U --noconfirm mingw-w64-x86_64-mpv-0.36.0-3-any.pkg.tar.zst
$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.36.0-3
cmake -B build-0.36 -G "MinGW Makefiles" -DPLATFORM_DESKTOP=ON
mingw32-make -C build-0.36 wiliwili -j$(nproc)

然后运行

$ ./build-0.36/wiliwili.exe

然后什么都没发生, 日志都没有,窗口都没有

然后我尝试让他打日志

$ ./wiliwili.exe -d -v -t -o

也是什么都没发生, 日志都没有,窗口都没有.

没办法, 我只能先重装回去 0.37的 mpv

$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.36.0-3
$ pacman -S --noconfirm mingw-w64-x86_64-mpv
resolving dependencies...
looking for conflicting packages...

Packages (1) mingw-w64-x86_64-mpv-0.37.0-1

Total Installed Size:  6.06 MiB
Net Upgrade Size:      0.17 MiB

:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring                                                                                                                                                                                  [##################################################################################################################################] 100%
(1/1) checking package integrity                                                                                                                                                                                [##################################################################################################################################] 100%
(1/1) loading package files                                                                                                                                                                                     [##################################################################################################################################] 100%
(1/1) checking for file conflicts                                                                                                                                                                               [##################################################################################################################################] 100%
(1/1) checking available disk space                                                                                                                                                                             [##################################################################################################################################] 100%
:: Processing package changes...
(1/1) upgrading mingw-w64-x86_64-mpv 
$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.37.0-1
$ ./build-0.36/wiliwili.exe
20:35:34.528[INFO] wiliwili v1.3.0
20:35:34.529[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili
20:35:34.530[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
20:35:34.530[INFO] cookie: DedeUserID:0
20:35:34.530[INFO] refreshToken:
20:35:34.530[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,614x1002","limited_fps":0,"player_hwdec":true,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
20:35:34.530[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:35:34.530[INFO] Load window state: 1649x860,614x1002
20:35:34.530[INFO] Set app theme: Dark
20:35:34.530[INFO] Set app locale: zh-Hans
20:35:34.538[INFO] Using platform GLFW
20:35:34.646[INFO] glfw: GL Vendor: ATI Technologies Inc.
20:35:34.646[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
20:35:34.646[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
20:35:34.646[INFO] glfw: GLFW Version: 3.4.0
20:35:34.675[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
20:35:34.849[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
20:35:34.849[INFO] Using internal font: ./resources/font/switch_font.ttf
20:35:34.856[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
20:35:34.860[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
20:35:34.860[INFO] Load emoji font: ./resources/font/emoji.ttf
20:35:34.860[INFO] Load keymap icon: ./resources/font/keymap_xbox.ttf
20:35:34.861[INFO] createWindow done
20:35:35.054[INFO] max_thread_num: 4
20:35:38.203[INFO] App is up to date
20:35:38.282[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:35:38.289[INFO] MPV Version: mpv 0.37.0
20:35:38.289[INFO] FFMPEG Version: 6.1.1
20:35:38.291[INFO] uninitialize Video
20:35:38.291[INFO] trying free mpv context
20:35:38.291[INFO] trying terminate mpv
20:35:38.296[INFO] MPV Version: mpv 0.37.0
20:35:38.296[INFO] FFMPEG Version: 6.1.1
20:35:38.296[INFO] Set shader []:
20:35:38.297[INFO] disableDimming: false
20:35:39.403[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:35:39.404[INFO] uninitialize Video
20:35:39.404[INFO] trying free mpv context
20:35:39.404[INFO] trying terminate mpv
20:35:39.407[INFO] MPV hardware decode: auto-safe
20:35:39.410[INFO] MPV Version: mpv 0.37.0
20:35:39.410[INFO] FFMPEG Version: 6.1.1
20:35:39.410[INFO] Set shader []:
20:35:39.411[INFO] disableDimming: false
20:35:41.400[INFO] Save window state: 0,1649x860,614x1002
20:35:41.401[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:35:41.401[INFO] disableDimming: false
20:35:41.401[INFO] disableDimming: false
20:35:41.401[INFO] disableDimming: false
20:35:41.401[INFO] Exiting...
20:35:41.695[INFO] uninitialize Video
20:35:41.695[INFO] trying free mpv context
20:35:41.695[INFO] trying terminate mpv

就没问题;


然后我就尝试用 0.37 的 mpv 打包

$ pacman -Qo /mingw64/bin/libmpv-2.dll
/mingw64/bin/libmpv-2.dll is owned by mingw-w64-x86_64-mpv 0.37.0-1
cp ${MINGW_PREFIX}/bin/libmpv-2.dll resources/
## mpv-0.37, ninja, 打包资源
cmake -B build-0.37-bundle-ninja -G "Ninja" -DUSE_LIBROMFS=ON -DMPV_BUNDLE_DLL=ON \
            -DCMAKE_BUILD_TYPE=Release \
            -DPLATFORM_DESKTOP=ON \
            -DWIN32_TERMINAL=OFF \
            -DCURL_DISABLE_PROGRESS_METER=ON \
            -DUSE_LIBIDN2=OFF \
            -DUSE_WIN32_IDN=ON \
            -DCURL_USE_LIBSSH2=OFF \
            -DCURL_USE_LIBPSL=OFF \
            -DZLIB_USE_STATIC_LIBS=ON
cmake --build-0.37-bundle-ninja

打包完成后, 如果在 MSYS2 MinGW64 下跑, 就正常

$ ./build-0.37-bundle-ninja/wiliwili.exe
20:52:40.162[INFO] wiliwili v1.3.0
20:52:40.163[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili
20:52:40.164[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
20:52:40.164[INFO] cookie: DedeUserID:0
20:52:40.164[INFO] refreshToken:
20:52:40.164[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,614x1002","limited_fps":0,"player_hwdec":true,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
20:52:40.164[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:52:40.164[INFO] Load window state: 1649x860,614x1002
20:52:40.165[INFO] Set app theme: Dark
20:52:40.165[INFO] Set app locale: zh-Hans
20:52:40.174[INFO] Using platform GLFW
20:52:40.330[INFO] glfw: GL Vendor: ATI Technologies Inc.
20:52:40.330[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
20:52:40.330[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
20:52:40.330[INFO] glfw: GLFW Version: 3.4.0
20:52:40.393[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
20:52:40.578[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
20:52:40.578[INFO] Using internal font: @res/font/switch_font.ttf
20:52:40.583[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
20:52:40.586[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
20:52:40.586[INFO] Load keymap icon: @res/font/keymap_xbox.ttf
20:52:40.586[INFO] createWindow done
20:52:40.772[INFO] max_thread_num: 4
20:52:45.102[INFO] App is up to date
20:52:45.920[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:52:45.943[INFO] Load libmpv-2.dll, size: 2896541
20:52:45.950[INFO] MPV Version: mpv 0.37.0
20:52:45.950[INFO] FFMPEG Version: 6.1.1
20:52:45.961[INFO] uninitialize Video
20:52:45.961[INFO] trying free mpv context
20:52:45.961[INFO] trying terminate mpv
20:52:45.967[INFO] MPV Version: mpv 0.37.0
20:52:45.967[INFO] FFMPEG Version: 6.1.1
20:52:45.967[INFO] Set shader []:
20:52:45.969[INFO] disableDimming: false
20:52:46.893[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:52:46.893[INFO] uninitialize Video
20:52:46.893[INFO] trying free mpv context
20:52:46.893[INFO] trying terminate mpv
20:52:46.895[INFO] MPV hardware decode: auto-safe
20:52:46.898[INFO] MPV Version: mpv 0.37.0
20:52:46.898[INFO] FFMPEG Version: 6.1.1
20:52:46.899[INFO] Set shader []:
20:52:46.899[INFO] disableDimming: false
20:52:50.912[ERROR] report event error: 0
20:52:51.772[INFO] Save window state: 0,1649x860,614x1002
20:52:51.772[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
20:52:51.772[INFO] disableDimming: false
20:52:51.772[INFO] disableDimming: false
20:52:51.772[INFO] disableDimming: false
20:52:51.772[INFO] Exiting...
20:52:51.935[INFO] uninitialize Video
20:52:51.935[INFO] trying free mpv context
20:52:51.936[INFO] trying terminate mpv
20:52:51.969[INFO] mainLoop done

但是如果在 PS下跑, 就什么都没有, 和 上面的mpv-0.36, 不打包的 行为一模一样, 什么都没有发生.

然后

我直接在explorer.exe 下 双击执行, 会提示缺少报libsharpyuv-0.dll & libwebp-7.dll, 我手动复制依赖到同级目录下, 双击执行, 可以打开了, 但是 在播放和更改配置时又闪退了;

然后

我又在 PS下跑,

PS E:\code\msys64\home\Tak Chen\wiliwili\build-0.37-bundle-ninja> .\wiliwili.exe -d -v -t -o

这回 能打开了, 但是 在播放和更改配置时又闪退了;

21:04:12.003[INFO] wiliwili v1.3.0
21:04:12.005[INFO] Current working directory: E:\code\msys64\home\Tak Chen\wiliwili\build-0.37-bundle-ninja
21:04:12.005[INFO] client: 23817545.1708786208/f4a77ec6-a258-bb96-4655-e24c394ff6a1
21:04:12.005[INFO] cookie: DedeUserID:0
21:04:12.005[INFO] refreshToken: 
21:04:12.005[INFO] setting: {"app_ui_scale":"1080p","fullscreen":false,"hide_bottom_bar":false,"hide_fps":false,"home_window_state":"0,1649x860,614x1002","limited_fps":0,"player_hwdec":true,"player_inmemory_cache":0,"player_low_quality":false,"tls_verify":true,"video_codec":7}
21:04:12.005[INFO] Load config from: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
21:04:12.005[INFO] Load window state: 1649x860,614x1002
21:04:12.006[INFO] Set app theme: Dark
21:04:12.006[INFO] Set app locale: zh-Hans
21:04:12.015[INFO] Using platform GLFW
21:04:12.140[INFO] glfw: GL Vendor: ATI Technologies Inc.
21:04:12.140[INFO] glfw: GL Renderer: AMD Radeon RX 7900 XT
21:04:12.140[INFO] glfw: GL Version: 4.6.0 Compatibility Profile Context 24.1.1.240110
21:04:12.140[INFO] glfw: GLFW Version: 3.4.0
21:04:12.170[WARNING] Cannot find custom gamepad db, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/gamecontrollerdb.txt)
21:04:12.340[WARNING] Cannot find custom font, (Searched at: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/font.ttf)
21:04:12.341[INFO] Using internal font: @res/font/switch_font.ttf
21:04:12.346[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
21:04:12.349[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
21:04:12.349[INFO] Load keymap icon: @res/font/keymap_xbox.ttf
21:04:12.349[INFO] createWindow done
21:04:12.506[INFO] max_thread_num: 4
21:04:14.759[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
21:04:14.761[INFO] Load libmpv-2.dll, size: 2896541

这回, libmpv-2.dll 的版本的确是官方的 0.37了, 但还是有问题;

$ ls -l resources/libmpv-2.dll
-rwxr-xr-x 1 Tak Chen Tak Chen 2896541 Feb 25 20:40 resources/libmpv-2.dll


怎么打个包就出问题了.....

为什么打包我还会漏依赖了....

然后, 我就尝试 不打包 mpv 依赖了

cmake -B build-0.37-bundle-ninja-NOMPV -G "Ninja" -DUSE_LIBROMFS=ON \
            -DCMAKE_BUILD_TYPE=Release \
            -DPLATFORM_DESKTOP=ON \
            -DWIN32_TERMINAL=OFF \
            -DCURL_DISABLE_PROGRESS_METER=ON \
            -DUSE_LIBIDN2=OFF \
            -DUSE_WIN32_IDN=ON \
            -DCURL_USE_LIBSSH2=OFF \
            -DCURL_USE_LIBPSL=OFF \
            -DZLIB_USE_STATIC_LIBS=ON
cmake --build build-0.37-bundle-ninja-NOMPV

然后将生成的 exe 拖到一个独立文件夹, 补全了其他dll 依赖后, 启动, 正常了

tc@T-HOME:/mnt/d/apps/wiliwili$ ls *.dll
SDL2.dll                libgcc_s_seh-1.dll       libopencore-amrwb-0.dll      libuchardet.dll
avcodec-60.dll          libgdk_pixbuf-2.0-0.dll  libopenjp2-7.dll             libunibreak-5.dll
avdevice-60.dll         libgio-2.0-0.dll         libopus-0.dll                libunistring-5.dll
avfilter-9.dll          libglib-2.0-0.dll        libp11-kit-0.dll             libva.dll
avformat-60.dll         libgme.dll               libpango-1.0-0.dll           libva_win32.dll
avutil-58.dll           libgmodule-2.0-0.dll     libpangocairo-1.0-0.dll      libvapoursynth-script-0.dll
dovi.dll                libgmp-10.dll            libpangoft2-1.0-0.dll        libvidstab.dll
libSvtAv1Enc.dll        libgnutls-30.dll         libpangowin32-1.0-0.dll      libvorbis-0.dll
libaom.dll              libgobject-2.0-0.dll     libpcre2-8-0.dll             libvorbisenc-2.dll
libarchive-13.dll       libgomp-1.dll            libpixman-1-0.dll            libvpl.dll
libass-9.dll            libgraphite2.dll         libplacebo-338.dll           libvpx-1.dll
libb2-1.dll             libgsm.dll               libpng16-16.dll              libwebp-7.dll
libbluray-2.dll         libharfbuzz-0.dll        libpython3.11.dll            libwebpmux-3.dll
libbrotlicommon.dll     libhogweed-6.dll         librsvg-2-2.dll              libwinpthread-1.dll
libbrotlidec.dll        libiconv-2.dll           librtmp-1.dll                libx264-164.dll
libbrotlienc.dll        libidn2-0.dll            librubberband-2.dll          libx265.dll
libbz2-1.dll            libintl-8.dll            libsamplerate-0.dll          libxml2-2.dll
libcaca-0.dll           libjpeg-8.dll            libshaderc_shared.dll        libzimg-2.dll
libcairo-2.dll          liblcms2-2.dll           libsharpyuv-0.dll            libzstd.dll
libcairo-gobject-2.dll  liblz4.dll               libsoxr.dll                  lua51.dll
libcrypto-3-x64.dll     liblzma-5.dll            libspeex-1.dll               postproc-57.dll
libdatrie-1.dll         libmodplug-1.dll         libspirv-cross-c-shared.dll  rav1e.dll
libdav1d-7.dll          libmp3lame-0.dll         libsrt.dll                   swresample-4.dll
libexpat-1.dll          libmpv-2.dll             libssh.dll                   swscale-7.dll
libffi-8.dll            libmujs.dll              libstdc++-6.dll              vulkan-1.dll
libfftw3-3.dll          libnettle-8.dll          libtasn1-6.dll               xvidcore.dll
libfontconfig-1.dll     libogg-0.dll             libthai-0.dll                zlib1.dll
libfreetype-6.dll       libopenal-1.dll          libtheoradec-1.dll
libfribidi-0.dll        libopencore-amrnb-0.dll  libtheoraenc-1.dll
tc@T-HOME:/mnt/d/apps/wiliwili$ ls *.exe
wiliwili.exe


因为我本身对 C++ 不熟, 都是 trial and error 试出来的

头大, debug 用的环境还没调好

xfangfang commented 4 months ago

感谢,非常感谢如此详细的说明。

mpv依赖很多,其实你可以直接去下载官方打包好的dll,只有引入一个 mpv就可以了: https://sourceforge.net/projects/mpv-player-windows/files/libmpv/

前面换0.36没有log的问题,我感觉或许是编译参数设置了或者设置过 -DWIN32_TERMINAL=OFF 导致的,这应该是个小问题。

我理解的意思是,现在只要打包成一个独立的app,那么就会遇到问题,不打包就没问题。

对于打包和不打包的行为区别是,不打包的时候 wiliwili 启动时通过系统来加载 mpv dll;打包到应用内部时,wiliwili 通过 MemoryModule 这个第三方库加载内存中的 dll。

我还是建议在下面这段代码里加点log,看看程序究竟是挂在了哪行。

https://github.com/xfangfang/wiliwili/blob/2183dd1bf3ca2648961be47cc11499edce1d018f/wiliwili/source/view/mpv_core.cpp#L297-L406

dragonflylee commented 4 months ago

这里编译了一版附带 0.37.0 mpv 剪裁版的 wiliwili https://nightly.link/dragonflylee/wiliwili/actions/runs/8039447014

如果还是崩溃,可以替换为官方完整版的 dll

v0.36.0-6729285

v0.37.0-6898d57

TakChen commented 4 months ago

我这边用 dragonflylee 的 包试了一下, 全部都不行;

3个版本的 表现都为: 窗口能打开, 但是一点击视频或者调整播放设置的前3个选项会闪退;

怎么现在好像成了打包的问题了?

我们先针对其中一个现象来调吧, 即: 调整播放设置的硬件加速会闪退;

然后,

我就在代码里面加了一些打日志

// mpv_core.cpp
MPVCore::MPVCore() {
#if defined(MPV_BUNDLE_DLL)
    auto &dllData = romfs::get("libmpv-2.dll");
    dll           = MemoryLoadLibrary(dllData.data(), dllData.size());
    brls::Logger::info("Load libmpv-2.dll, size: {}", dllData.size());

    brls::Logger::info("#### MPVCore::MPVCore    mpvSetOptionString    ");
    mpvSetOptionString     = (mpvSetOptionStringFunc)MemoryGetProcAddress(dll, "mpv_set_option_string");
    brls::Logger::info("#### MPVCore::MPVCore    mpvObserveProperty    ");
    mpvObserveProperty     = (mpvObservePropertyFunc)MemoryGetProcAddress(dll, "mpv_observe_property");
    mpvCreate              = (mpvCreateFunc)MemoryGetProcAddress(dll, "mpv_create");
    brls::Logger::info("#### MPVCore::MPVCore    mpvInitialize    ");
    mpvInitialize          = (mpvInitializeFunc)MemoryGetProcAddress(dll, "mpv_initialize");
    mpvTerminateDestroy    = (mpvTerminateDestroyFunc)MemoryGetProcAddress(dll, "mpv_terminate_destroy");
    mpvSetWakeupCallback   = (mpvSetWakeupCallbackFunc)MemoryGetProcAddress(dll, "mpv_set_wakeup_callback");
    mpvCommandString       = (mpvCommandStringFunc)MemoryGetProcAddress(dll, "mpv_command_string");
    mpvErrorString         = (mpvErrorStringFunc)MemoryGetProcAddress(dll, "mpv_error_string");
    mpvWaitEvent           = (mpvWaitEventFunc)MemoryGetProcAddress(dll, "mpv_wait_event");
    mpvGetProperty         = (mpvGetPropertyFunc)MemoryGetProcAddress(dll, "mpv_get_property");
    mpvCommandAsync        = (mpvCommandAsyncFunc)MemoryGetProcAddress(dll, "mpv_command_async");
    mpvGetPropertyString   = (mpvGetPropertyStringFunc)MemoryGetProcAddress(dll, "mpv_get_property_string");
    mpvFreeNodeContents    = (mpvFreeNodeContentsFunc)MemoryGetProcAddress(dll, "mpv_free_node_contents");
    brls::Logger::info("#### MPVCore::MPVCore    mpvSetOption    ");

然后打包测试

cmake -B build-0.37-bundle-ninja -G "Ninja" -DUSE_LIBROMFS=ON -DMPV_BUNDLE_DLL=ON \
            -DCMAKE_BUILD_TYPE=Release \
            -DPLATFORM_DESKTOP=ON \
            -DWIN32_TERMINAL=ON \
            -DCURL_DISABLE_PROGRESS_METER=ON \
            -DUSE_LIBIDN2=OFF \
            -DUSE_WIN32_IDN=ON \
            -DCURL_USE_LIBSSH2=OFF \
            -DCURL_USE_LIBPSL=OFF \
            -DZLIB_USE_STATIC_LIBS=ON
cmake --build build-0.37-bundle-ninja

运行后, 更改设置, 崩溃; 日志停留在

.....
21:36:22.745[INFO] Using internal font: @res/font/switch_font.ttf
21:36:22.751[INFO] Using zh-Hans font: C:\WINDOWS\Fonts\msyh.ttc
21:36:22.755[INFO] Using korean font: C:\WINDOWS\Fonts\malgun.ttf
21:36:22.755[INFO] Load keymap icon: @res/font/keymap_xbox.ttf
21:36:22.755[INFO] createWindow done
21:36:23.130[INFO] max_thread_num: 4
21:36:25.251[INFO] Write config to: C:\Users\Tak Chen\AppData\Local\xfangfang\wiliwili/wiliwili_config.json
21:36:25.254[INFO] Load libmpv-2.dll, size: 2896541
21:36:25.254[INFO] #### MPVCore::MPVCore    mpvSetOptionString

额...接下来怎么搞...完全没头绪

dragonflylee commented 4 months ago

@TakChen 自己编译的时候请把 MPV_BUNDLE_DLL 设置为 OFF, 否则会妨碍您的调式

另外,替换官方dll请使用 opengl的包 https://nightly.link/dragonflylee/wiliwili/actions/runs/8039447014/wiliwili-Windows-d74193e-gl-x86_64.zip ,官方dll并不支持dx直接渲染

xfangfang commented 4 months ago

@TakChen 我前面说两次啦,继续添加log,看究竟是哪一行卡住的,log就往 MPVCore::init 这个函数里加就好啦~

TakChen commented 4 months ago

解决了......

我刚刚突发奇想, 去 window 事件管理器那边看看, 发现了以下日志

错误应用程序名称: wiliwili.exe,版本: 1.3.0.111,时间戳: 0x65db7315
错误模块名称: nvcuda64.dll,版本: 31.0.15.3118,时间戳: 0x63f92c60
异常代码: 0xc0000409
错误偏移量: 0x000000000053c834
错误进程 ID: 0x0xF90
错误应用程序启动时间: 0x0x1DA68C6802373D5
错误应用程序路径: C:\Users\Tak Chen\Downloads\wiliwili-Windows-d74193e-gl-x86_64 (2)\wiliwili.exe
错误模块路径: C:\WINDOWS\system32\DriverStore\FileRepository\nv_dispi.inf_amd64_abf7e4e84f20581c\nvcuda64.dll
报告 ID: e3056a1f-0a1e-4e77-8462-c92493e173e0
错误程序包全名: 
错误程序包相对应用程序 ID: 

我突然一惊, 不对啊, 我不是用的A卡吗? 怎么还会有CUDA 调用; 然后我怀疑我的NV 驱动没删除干净; 网上找了个 Display Driver Uninstaller(DDU).exe 执行, 发现 我电脑上的确装了两个 驱动, 因为我之前用的是 N卡, 换卡的时候没卸载驱动, 因为换了之后平时用着都没事 卸载掉后 现在 正常了

小结

如果发生崩溃情况, 去windows 的事件查看器 看看, 或许有意外收获🤣🤣

xfangfang commented 4 months ago

哈哈 好意外啊,解决了就是好的结局~