xfangfang / wiliwili

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

Reset LC_NUMERIC on initializing #236

Closed mochaaP closed 8 months ago

mochaaP commented 8 months ago

libmpv requires LC_NUMERIC to be "C": https://github.com/mpv-player/mpv/blob/ad02db8ceefc8cd8a52ea0cbeff0a18e80882c6f/libmpv/client.h#L147-L149

But currently it depends on a XIM bugfix on X11 (https://github.com/xfangfang/glfw/blob/36ff2b3588aa2b745a59bc4f2a7b522cc21a220a/src/x11_init.c#L1262-L1267), and it doesn't reset in Wayland, causing a crash.

mochaaP commented 8 months ago

An easy fix is to deploy this to MPVCore::init(), but I'm uncertain about the affect on thread safety, since setlocale is MT-Unsafe const:locale env

xfangfang commented 8 months ago

Maybe it's safe to be called at: ProgramConfig::init() ?

like:

void ProgramConfig::init() {
    brls::Logger::info("wiliwili {}", APPVersion::instance().git_tag);

+   // Needed for MPV
+   setlocale(LC_NUMERIC, "C");

    // Set min_threads and max_threads of http thread pool
    ...
xfangfang commented 8 months ago

Done by: https://github.com/xfangfang/wiliwili/commit/87756ae9442f6ec8f2fd9661d0176a80feb24e80

Eitetsu0 commented 7 months ago

Done by: 87756ae

wayland下仍然存在问题,未设置LC_NUMERIC的情况下,加载视频播放页面崩溃。控制台输出:

Non-C locale detected. This is not supported.
Call 'setlocale(LC_NUMERIC, "C");' in your code.
00:54:28.464[ERROR] Fatal error: Error Create mpv Handle
terminate called after throwing an instance of 'std::logic_error'
  what():  Error Create mpv Handle
[1]    1580249 IOT instruction (core dumped)  wiliwili
xfangfang commented 7 months ago

@Eitetsu0 那你可以测试看看加在哪里可以,按文档的意思只要在初始化之前设置了就可以,我也不是很清楚为什么还会报错。