microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
9.94k stars 299 forks source link

When the computer has more than two graphics cards, the program that calls the GPU cannot be run in WSLg #486

Open LiarOnce opened 2 years ago

LiarOnce commented 2 years ago

Environment

Windows build number: Windows 11 Build 22000.194
Your Distribution version: Ubuntu 20.04
Your WSLg version: 1.0.28

GPUs:

GPU 0: Intel(R) UHD Graphics 630 (30.0.100.9922)

GPU 1: NVIDIA GeForce RTX 2070 (510.06)

Both of the above graphics cards have installed drivers that support vGPU

Steps to reproduce

  1. Install Firefox and `mesa-utils from the Ubuntu repository under WSL2g.
  2. Start Firefox or glxgears
  3. Firefox and glxgears exits with an I/O error.

Run Firefox:

Gdk-Message: 13:48:26.958: firefox: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.

Run glxgears:

XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 1580 requests (1580 known processed) with 0 events remaining.

pulseaudio.log versions.txt weston.log

Expected behavior

Try to run firefox

Actual behavior

Programs that use GPU, including Firefox, cannot run.

hideyukn88 commented 2 years ago

@LiarOnce, thanks for reporting the issue. Can you run glxinfo -B and let me know the output ? Also what version of mesa do you have? if you have version 21.2.0 or newer, then you can select which GPU to be used by environment variable, otherwise, the default should be used. But just in case, can you set environment variable? For further details, please refer this PR, https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10710. Thanks!

LiarOnce commented 2 years ago

@hideyukn88 glxinfo -B output:

name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (NVIDIA GeForce RTX 2070) (0xffffffff)
    Version: 21.0.3
    Accelerated: yes
    Video memory: 16141MB
    Unified memory: no
    Preferred profile: core (0x1)
    Max core profile version: 3.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (NVIDIA GeForce RTX 2070)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 21.0.3
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 21.0.3
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 21.0.3
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

I tried to update Mesa to 21.2.3 and set MESA_D3D12_DEFAULT_ADAPTER_NAME, but it also returned the same error (WSL has been restarted):

liaronce@DESKTOP-FTND6VV:/mnt/c/Users/qq106$ export MESA_D3D12_DEFAULT_ADAPTER_NAME="INTEL"
liaronce@DESKTOP-FTND6VV:/mnt/c/Users/qq106$ glxinfo -B
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Microsoft Corporation (0xffffffff)
    Device: D3D12 (Intel(R) UHD Graphics 630) (0xffffffff)
    Version: 21.2.3
    Accelerated: yes
    Video memory: 8238MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 3.3
    Max compat profile version: 3.1
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL vendor string: Microsoft Corporation
OpenGL renderer string: D3D12 (Intel(R) UHD Graphics 630)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 21.2.3 - kisak-mesa PPA
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 3.1 Mesa 21.2.3 - kisak-mesa PPA
OpenGL shading language version string: 1.40
OpenGL context flags: (none)

OpenGL ES profile version string: OpenGL ES 3.0 Mesa 21.2.3 - kisak-mesa PPA
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

liaronce@DESKTOP-FTND6VV:/mnt/c/Users/qq106$ firefox
Gdk-Message: 09:08:54.664: firefox: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
hideyukn88 commented 2 years ago

@LiarOnce, do you see any dumps at /mnt/wslg/dumps? if so, please share them with us. If there is no dumps, please enable debugconsole for WSL and share the output with us. For debugconsole, please refer below. Thanks!

https://docs.microsoft.com/en-us/windows/wsl/wsl-config#wsl-2-setting-preview-options

LiarOnce commented 2 years ago

@hideyukn88 debugConsole output when running firefox:

[   24.153105] potentially unexpected fatal signal 7.
[   24.155627] CPU: 6 PID: 223 Comm: weston Not tainted 5.10.60.1-microsoft-standard-WSL2 #1
[   24.159376] RIP: 0033:0x7fc7685a6ed8
[   24.161172] Code: 3b 47 08 73 3d 48 8b 47 28 48 89 fb 48 85 c0 74 59 4c 8d 64 24 04 b9 04 00 00 00 4c 89 e2 ff d0 48 83 f8 04 75 1c 48 8b 73 10 <41> 8b 04 24 0f c8 89 c0 48 83 c6 04 48 89 73 10 eb 0f 66 0f 1f 44
[   24.170936] RSP: 002b:00007fff75717f90 EFLAGS: 00010206
[   24.173547] RAX: 0000000000000000 RBX: 000055e5bfd4b140 RCX: 0000000000040000
[   24.177627] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 000055e5bfd4b140
[   24.181452] RBP: 00007fff75718020 R08: 0000000000000000 R09: 0000000000000016
[   24.186621] R10: 000055e5bff74730 R11: 0000000000000004 R12: 00007fc768042000
[   24.190644] R13: 0000000000000000 R14: 000055e5bfd4b140 R15: 000055e5bfd4b140
[   24.194251] FS:  00007fc76a3c8900 GS:  0000000000000000

Full logs: debugconsole.log

hideyukn88 commented 2 years ago

@LiarOnce, thanks, so it does seems weston crashed, then there should be dumps saved at /mnt/wslg/dumps, please share with us, thanks!

LiarOnce commented 2 years ago

@hideyukn88 core.weston.zip This is dump

hideyukn88 commented 2 years ago

@LiarOnce, the dump shows weston got SIGBUS during initialization of fontconfig, and terminated. Just for clarification purpose, can you run xclock or xcalc without any problem? Thanks!

LiarOnce commented 2 years ago

@hideyukn88 Unable to run, returned a similar error:

liaronce@DESKTOP-FTND6VV:/mnt/c/Users/qq106$ xcalc
Warning: Cannot convert string "8x13" to type FontStruct
Warning: Missing charsets in String to FontSet conversion
Warning: Cannot convert string "-adobe-symbol-*-*-*-*-*-120-*-*-*-*-*-*" to type FontStruct
X connection to :0 broken (explicit kill or server shutdown).

liaronce@DESKTOP-FTND6VV:/mnt/c/Users/qq106$ xclock
Warning: Missing charsets in String to FontSet conversion
X connection to :0 broken (explicit kill or server shutdown).
hideyukn88 commented 2 years ago

@LiarOnce, thanks for info. For recording purpose, I put the callstack of your crash below. It's occurred while loading font file from Windows, c:\Windows\Fonts\MTEXTRA.TTF, and this is Microsoft-supplied font, so should be good, and under my environment, that font file can be loaded just fine. I will see if I can fine more from your dumps, thanks!

Core was generated by `/usr/bin/weston --backend=rdp-backend.so --xwayland --shell=rdprail-shell.so --'.
Program terminated with signal SIGBUS, Bus error.
#0  FT_Stream_ReadULong (stream=stream@entry=0x56452d967d90, error=error@entry=0x7ffc545ab510)
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/base/ftstream.c:649
649             result = FT_NEXT_ULONG( p );
[Current thread is 1 (Thread 0x7ffb25f68900 (LWP 8))]
(gdb) bt
#0  0x00007ffb24146ed8 in FT_Stream_ReadULong
    (stream=stream@entry=0x56452d967d90, error=error@entry=0x7ffc545ab510)
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/base/ftstream.c:649
#1  0x00007ffb24189520 in sfnt_open_font (face=0x56452dae6d80, stream=0x56452d967d90)
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/sfnt/sfobjs.c:766
#2  0x00007ffb24189520 in sfnt_init_face
    (stream=<optimized out>, face=0x56452dae6d80, face_instance_index=0, num_params=<optimized out>, params=<optimized out>) at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/sfnt/sfobjs.c:914
#3  0x00007ffb2415d1d3 in tt_face_init
    (stream=0x56452d967d90, ttface=0x56452dae6d80, face_index=0, num_params=0, params=0x0)
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/truetype/ttobjs.c:626
#4  0x00007ffb24148822 in open_face
    (driver=driver@entry=0x56452db72bd0, astream=astream@entry=0x7ffc545ab7d8, external_stream=external_stream@entry=0 '\000', face_index=face_index@entry=0, num_params=0, params=0x0, aface=0x7ffc545ab7e0)
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/base/ftobjs.c:1359
#5  0x00007ffb2414ab14 in ft_open_face_internal
    (library=0x56452daf1af0, args=args@entry=0x7ffc545ab9d0, face_index=face_index@entry=0, aface=aface@entry=0x7ffc545aba68, test_mac_fonts=test_mac_fonts@entry=1 '\001')
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/base/ftobjs.c:2431
#6  0x00007ffb2414b180 in FT_New_Face
    (library=<optimized out>, pathname=pathname@entry=0x56452d9640f0 "/mnt/c/Windows/Fonts/MTEXTRA.TTF", face_index=face_index@entry=0, aface=aface@entry=0x7ffc545aba68)
    at /usr/src/debug/freetype-2.9.1-4.cm1.x86_64/src/base/ftobjs.c:1422
#7  0x00007ffb241f8326 in IA__FcFreeTypeQueryAll
    (file=0x56452d9640f0 "/mnt/c/Windows/Fonts/MTEXTRA.TTF", id=id@entry=4294967295, blanks=blanks@entry=0x0, count=count@entry=0x0, set=set@entry=0x56452d9611b0) at fcfreetype.c:2181
#8  0x00007ffb241f2b44 in FcFileScanFontConfig (config=0x56452d8bee00, file=<optimized out>, set=0x56452d9611b0)
    at fcdir.c:78
#9  0x00007ffb241f2b44 in FcFileScanConfig
    (set=0x56452d9611b0, dirs=0x56452d93ac40, file=<optimized out>, config=0x56452d8bee00) at fcdir.c:156
#10 0x00007ffb241f2f9e in FcDirScanConfig
    (set=set@entry=0x56452d9611b0, dirs=dirs@entry=0x56452d93ac40, dir=dir@entry=0x56452d91acd0 "/mnt/c/Windows/Fonts", config=config@entry=0x56452d8bee00, force=1) at fcdir.c:253
#11 0x00007ffb241f31bc in FcDirScanConfig
    (config=0x56452d8bee00, force=1, dir=0x56452d91acd0 "/mnt/c/Windows/Fonts", dirs=0x56452d93ac40, set=0x56452d9611b0) at fcdir.c:321
#12 0x00007ffb241f31bc in FcDirCacheScan
    (dir=dir@entry=0x56452d92ad50 "/mnt/c/Windows/Fonts", config=config@entry=0x56452d8bee00) at fcdir.c:321
#13 0x00007ffb241f3442 in IA__FcDirCacheRead
    (dir=dir@entry=0x56452d92ad50 "/mnt/c/Windows/Fonts", force=force@entry=0, config=config@entry=0x56452d8bee00)
    at fcdir.c:422
#14 0x00007ffb241edfe1 in FcConfigAddDirList
    (config=config@entry=0x56452d8bee00, set=set@entry=FcSetSystem, dirSet=0x56452d914fd0) at fccfg.c:459
#15 0x00007ffb241ee0b0 in IA__FcConfigBuildFonts (config=config@entry=0x56452d8bee00) at fccfg.c:492
#16 0x00007ffb241f935b in FcInitLoadOwnConfigAndFonts (config=0x56452d8bee00, config@entry=0x0) at fcinit.c:172
#17 0x00007ffb241f9388 in IA__FcInitLoadConfigAndFonts () at fcinit.c:183
#18 0x00007ffb241eb097 in FcConfigEnsure () at fccfg.c:45
#19 0x00007ffb241ed2e6 in IA__FcConfigGetCurrent () at fccfg.c:1675
#20 0x00007ffb241ed2e6 in IA__FcConfigSubstituteWithPat
    (config=0x0, p=0x56452d8bff30, p_pat=0x0, kind=FcMatchPattern) at fccfg.c:1675
#21 0x00007ffb242484cd in pango_cairo_fc_font_map_fontset_key_substitute () at /lib/libpangocairo-1.0.so.0
#22 0x00007ffb24107598 in pango_fc_font_map_load_fontset () at /lib/libpangoft2-1.0.so.0
#23 0x00007ffb24267160 in itemize_state_process_run () at /lib/libpango-1.0.so.0
#24 0x00007ffb242680c8 in pango_itemize_with_base_dir () at /lib/libpango-1.0.so.0
#25 0x00007ffb2427052b in pango_layout_check_lines () at /lib/libpango-1.0.so.0
#26 0x00007ffb24272300 in pango_layout_get_extents_internal () at /lib/libpango-1.0.so.0
#27 0x00007ffb242727d7 in pango_layout_get_pixel_extents () at /lib/libpango-1.0.so.0
#28 0x00007ffb243fe498 in theme_render_frame
    (t=0x56452d8a78a0, cr=cr@entry=0x56452d616430, width=1356, height=<optimized out>, title=<optimized out>, title_rect=title_rect@entry=0x56452d8ce69c, buttons=0x56452d8ce6b0, flags=0) at ../shared/cairo-util.c:549
#29 0x00007ffb243ff855 in frame_repaint (frame=0x56452d8ce660, cr=cr@entry=0x56452d616430)
    at ../shared/frame.c:1012
#30 0x00007ffb243f7ef9 in weston_wm_window_draw_decoration (window=0x56452d8c1b60)
    at ../xwayland/window-manager.c:1508
#31 0x00007ffb243f7ef9 in weston_wm_window_do_repaint (data=0x56452d8c1b60) at ../xwayland/window-manager.c:1596
#32 0x00007ffb26776b14 in wl_event_loop_dispatch_idle () at /lib/libwayland-server.so.0
#33 0x00007ffb26776c3a in wl_event_loop_dispatch () at /lib/libwayland-server.so.0
#34 0x00007ffb267750e5 in wl_display_run () at /lib/libwayland-server.so.0
#35 0x00007ffb269afcc0 in wet_main (argc=<optimized out>, argv=<optimized out>) at ../compositor/main.c:3438
#36 0x00007ffb267ff133 in __libc_start_main () at /lib/libc.so.6
#37 0x000056452c45b08e in _start ()
LiarOnce commented 2 years ago

@hideyukn88 I tried to uninstall the NVIDIA driver, leaving only the Intel graphics card running, and now running Firefox returns a different error:

liaronce@DESKTOP-FTND6VV:/mnt/c/Users/qq106$ firefox
Gdk-Message: 21:09:33.921: firefox: Fatal IO error 2 (No such file or directory) on X server :0.

Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.

core.weston.zip