obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
58.82k stars 7.83k forks source link

Celeste captured at 10 FPS on Linux/Wayland/sway #2323

Closed YaLTeR closed 4 years ago

YaLTeR commented 4 years ago

Celeste is an X11 game. On Wayland (with the sway compositor) OBS always captures it at around 10 FPS regardless of the OBS FPS setting. On X11 with the exact same setup it's captured at 60 FPS as it should be.

Expected Behavior

Celeste is captured at 60 FPS or whatever other FPS I have selected in OBS.

Current Behavior

Celeste is captured at around 10-15 FPS regardless of the OBS FPS setting.

Steps to Reproduce

  1. Install sway.
  2. Launch Celeste.
  3. Have OBS capture it via Xcomposite.
  4. Observe the OBS window to see that Celeste updates at 10 FPS, or try capturing to check the output file.

Additional information

No other X11 games or applications I captured thus far had this issue (everything captured at the correct FPS).

I tried running Celeste in a child sway running via the X11 backend (so Celeste was running via Xwayland inside sway, which was an X11 window itself running via Xwayland in the parent sway) and capturing this child sway's X11 window via OBS to observe this odd behavior:

You can see a video recording demonstrating the above here: https://youtu.be/5B4z-YOwp04

This leads me to believe there's some issue with OBS not "seeing" that Celeste has pushed a new frame and thus falling back to some kind of a 10 FPS timer.

Log of me opening OBS, observing the 10 FPS Celeste updating in the OBS preview, and closing it:

08:28:32.593: CPU Name: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz
08:28:32.593: CPU Speed: 2763.976MHz
08:28:32.594: Physical Cores: 4, Logical Cores: 8
08:28:32.594: Physical Memory: 15929MB Total, 7747MB Free
08:28:32.594: Kernel Version: Linux 4.18.16-zen1-1-zen
08:28:32.594: Distribution: "Arch Linux" Unknown
08:28:32.594: Window System: X11.0, Vendor: The X.Org Foundation, Version: 1.20.6
08:28:32.595: Portable mode: false
08:28:32.659: OBS 24.0.5-2 (linux)
08:28:32.659: ---------------------------------
08:28:32.660: ---------------------------------
08:28:32.660: audio settings reset:
08:28:32.660:   samples per sec: 44100
08:28:32.660:   speakers:        2
08:28:32.665: ---------------------------------
08:28:32.665: Initializing OpenGL...
08:28:32.761: Loading up OpenGL on adapter X.Org Radeon RX 580 Series (POLARIS10, DRM 3.26.0, 4.18.16-zen1-1-zen, LLVM 9.0.1)
08:28:32.761: OpenGL loaded successfully, version 4.5 (Core Profile) Mesa 19.3.2, shading language 4.50
08:28:32.773: ---------------------------------
08:28:32.773: video settings reset:
08:28:32.773:   base resolution:   2560x1440
08:28:32.773:   output resolution: 1280x720
08:28:32.773:   downscale filter:  Lanczos
08:28:32.773:   fps:               60/1
08:28:32.773:   format:            NV12
08:28:32.773:   YUV mode:          601/Partial
08:28:32.773: NV12 texture support not available
08:28:32.776: Audio monitoring device:
08:28:32.776:   name: Default
08:28:32.776:   id: default
08:28:32.776: ---------------------------------
08:28:32.777: Failed to load 'en-US' text for module: 'decklink-ouput-ui.so'
08:28:32.876: No blackmagic support
08:28:32.885: NVENC supported
08:28:32.885: FFMPEG VAAPI supported
08:28:32.893: VLC found, VLC video source enabled
08:28:32.893: ---------------------------------
08:28:32.893:   Loaded Modules:
08:28:32.893:     libwlrobs.so
08:28:32.893:     vlc-video.so
08:28:32.893:     text-freetype2.so
08:28:32.893:     rtmp-services.so
08:28:32.893:     obs-x264.so
08:28:32.893:     obs-transitions.so
08:28:32.893:     obs-outputs.so
08:28:32.893:     obs-libfdk.so
08:28:32.893:     obs-filters.so
08:28:32.893:     obs-ffmpeg.so
08:28:32.893:     linux-v4l2.so
08:28:32.893:     linux-pulseaudio.so
08:28:32.893:     linux-jack.so
08:28:32.893:     linux-decklink.so
08:28:32.893:     linux-capture.so
08:28:32.893:     linux-alsa.so
08:28:32.894:     libobs-linuxbrowser.so
08:28:32.894:     image-source.so
08:28:32.894:     frontend-tools.so
08:28:32.894:     decklink-ouput-ui.so
08:28:32.894: ---------------------------------
08:28:32.894: ==== Startup complete ===============================================
08:28:32.896: All scene data cleared
08:28:32.896: ------------------------------------------------
08:28:32.899: pulse-input: Server name: 'pulseaudio 13.0'
08:28:32.899: pulse-input: Audio format: s16le, 48000 Hz, 2 channels
08:28:32.899: pulse-input: Started recording from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor'
08:28:32.900: pulse-input: Server name: 'pulseaudio 13.0'
08:28:32.900: pulse-input: Audio format: s16le, 32000 Hz, 2 channels
08:28:32.900: pulse-input: Started recording from 'alsa_input.usb-046d_C922_Pro_Stream_Webcam_8445BA7F-02.analog-stereo'
08:28:32.999: v4l2-input: Start capture from /dev/video0
08:28:33.000: v4l2-input: Input: 0
08:28:33.000: v4l2-input: Resolution: 1280x720
08:28:33.000: v4l2-input: Pixelformat: 21VY
08:28:33.000: v4l2-input: Linesize: 1280 Bytes
08:28:33.001: v4l2-input: Framerate: 60,00 fps
08:28:33.002: v4l2-input: Start capture from /dev/video2
08:28:33.002: v4l2-input: Input: 0
08:28:33.022: v4l2-input: Resolution: 1280x720
08:28:33.022: v4l2-input: Pixelformat: 21VY
08:28:33.022: v4l2-input: Linesize: 1280 Bytes
08:28:33.022: v4l2-input: Framerate: 30,00 fps
08:28:33.401: xcompcap: [window-capture: 'Celeste window'] update settings:
08:28:33.401:   title: Celeste
08:28:33.401:   class: Celeste.bin.x86_64
08:28:33.401:   Bit depth: 24
08:28:33.401:   Found proper GLXFBConfig (in 152): yes
08:28:33.401: 
08:28:33.403: Switched to scene 'Celeste'
08:28:33.403: ------------------------------------------------
08:28:33.403: Loaded scenes:
08:28:33.403: - scene 'Scene':
08:28:33.403:     - source: 'Webcam' (v4l2_input)
08:28:33.403:     - source: 'Old webcam' (v4l2_input)
08:28:33.403:     - source: 'Wayland output' (wlrobs)
08:28:33.403: - scene 'HL1':
08:28:33.403:     - source: 'Half-Life' (xcomposite_input)
08:28:33.403: - scene 'Left monitor':
08:28:33.403: - scene 'Talos':
08:28:33.403:     - source: 'The Talos Principle' (xcomposite_input)
08:28:33.403:     - source: 'Splits' (xcomposite_input)
08:28:33.403: - scene 'Portal':
08:28:33.403:     - source: 'Portal OpenGL' (xcomposite_input)
08:28:33.403: - scene 'osu':
08:28:33.403:     - source: 'osu!' (xcomposite_input)
08:28:33.403:         - filter: 'Render Delay' (gpu_delay)
08:28:33.404:     - source: 'Webcam' (v4l2_input)
08:28:33.404:     - source: 'Old webcam' (v4l2_input)
08:28:33.404:     - source: 'Chat BG' (color_source)
08:28:33.404:     - source: 'Chat' (linuxbrowser-source)
08:28:33.404:     - source: 'Discord' (xcomposite_input)
08:28:33.404:         - filter: 'Color Correction' (color_filter)
08:28:33.404:     - source: 'Text (FreeType 2)' (text_ft2_source)
08:28:33.404:     - source: 'Brackets' (xcomposite_input)
08:28:33.404: - scene 'Quaver scene':
08:28:33.404:     - source: 'Quaver' (xcomposite_input)
08:28:33.404:         - filter: 'Render Delay' (gpu_delay)
08:28:33.404:     - source: 'Text (FreeType 2)' (text_ft2_source)
08:28:33.404:     - source: 'Main menu' (image_source)
08:28:33.404:     - source: 'Select 1' (image_source)
08:28:33.404:     - source: 'Select 2' (image_source)
08:28:33.404:     - source: 'Gameplay' (image_source)
08:28:33.404:         - filter: 'Color Correction' (color_filter)
08:28:33.404:     - source: 'Results' (image_source)
08:28:33.404:     - source: 'Results 2' (image_source)
08:28:33.404:         - filter: 'Color Correction' (color_filter)
08:28:33.404:     - source: 'Old webcam' (v4l2_input)
08:28:33.404:     - source: 'Webcam' (v4l2_input)
08:28:33.404: - scene 'Celeste':
08:28:33.404:     - source: 'Celeste window' (xcomposite_input)
08:28:33.404: ------------------------------------------------
08:28:33.468: adding 46 milliseconds of audio buffering, total audio buffering is now 46 milliseconds (source: Mic/Aux)
08:28:33.468: 
08:28:43.564: ==== Shutting down ==================================================
08:28:43.569: Switched to scene '(null)'
08:28:43.584: v4l2-input: Stopped capture after 312 frames
08:28:43.606: v4l2-input: Stopped capture after 155 frames
08:28:44.012: pulse-input: Stopped recording from 'alsa_output.pci-0000_00_1b.0.analog-stereo.monitor'
08:28:44.012: pulse-input: Got 2298 packets with 532515 frames
08:28:44.012: pulse-input: Stopped recording from 'alsa_input.usb-046d_C922_Pro_Stream_Webcam_8445BA7F-02.analog-stereo'
08:28:44.012: pulse-input: Got 1118 packets with 355392 frames
08:28:44.013: All scene data cleared
08:28:44.013: ------------------------------------------------
08:28:44.040: Freeing OBS context data
08:28:44.052: [Scripting] Total detached callbacks: 0
08:28:44.057: == Profiler Results =============================
08:28:44.057: run_program_init: 935,219 ms
08:28:44.057:  ┣OBSApp::AppInit: 1,32 ms
08:28:44.057:  ┃ ┗OBSApp::InitLocale: 0,605 ms
08:28:44.057:  ┗OBSApp::OBSInit: 907,866 ms
08:28:44.057:    ┣obs_startup: 16,592 ms
08:28:44.057:    ┗OBSBasic::OBSInit: 826,6 ms
08:28:44.057:      ┣OBSBasic::InitBasicConfig: 0,073 ms
08:28:44.057:      ┣OBSBasic::ResetAudio: 0,081 ms
08:28:44.057:      ┣OBSBasic::ResetVideo: 115,905 ms
08:28:44.057:      ┣OBSBasic::InitOBSCallbacks: 0,003 ms
08:28:44.057:      ┣OBSBasic::InitHotkeys: 0,022 ms
08:28:44.057:      ┣obs_load_all_modules: 117,715 ms
08:28:44.057:      ┃ ┣obs_init_module(decklink-ouput-ui.so): 0,512 ms
08:28:44.057:      ┃ ┣obs_init_module(frontend-tools.so): 73,186 ms
08:28:44.057:      ┃ ┣obs_init_module(image-source.so): 0,002 ms
08:28:44.057:      ┃ ┣obs_init_module(libobs-linuxbrowser.so): 0,002 ms
08:28:44.057:      ┃ ┣obs_init_module(linux-alsa.so): 0,001 ms
08:28:44.057:      ┃ ┣obs_init_module(linux-capture.so): 0,42 ms
08:28:44.057:      ┃ ┣obs_init_module(linux-decklink.so): 0,105 ms
08:28:44.057:      ┃ ┣obs_init_module(linux-jack.so): 0,001 ms
08:28:44.057:      ┃ ┣obs_init_module(linux-pulseaudio.so): 0,001 ms
08:28:44.057:      ┃ ┣obs_init_module(linux-v4l2.so): 0,001 ms
08:28:44.057:      ┃ ┣obs_init_module(obs-ffmpeg.so): 0,438 ms
08:28:44.057:      ┃ ┃ ┗nvenc_check: 0,375 ms
08:28:44.057:      ┃ ┣obs_init_module(obs-filters.so): 0,008 ms
08:28:44.057:      ┃ ┣obs_init_module(obs-libfdk.so): 0,001 ms
08:28:44.057:      ┃ ┣obs_init_module(obs-outputs.so): 0,002 ms
08:28:44.057:      ┃ ┣obs_init_module(obs-transitions.so): 0,004 ms
08:28:44.057:      ┃ ┣obs_init_module(obs-x264.so): 0,001 ms
08:28:44.057:      ┃ ┣obs_init_module(rtmp-services.so): 0,353 ms
08:28:44.057:      ┃ ┣obs_init_module(text-freetype2.so): 0,004 ms
08:28:44.058:      ┃ ┣obs_init_module(vlc-video.so): 1,877 ms
08:28:44.058:      ┃ ┗obs_init_module(libwlrobs.so): 0,003 ms
08:28:44.058:      ┣OBSBasic::ResetOutputs: 0,36 ms
08:28:44.058:      ┣OBSBasic::CreateHotkeys: 0,022 ms
08:28:44.058:      ┣OBSBasic::InitService: 0,819 ms
08:28:44.058:      ┣OBSBasic::InitPrimitives: 0,069 ms
08:28:44.058:      ┗OBSBasic::Load: 510,891 ms
08:28:44.058: obs_hotkey_thread(25 ms): min=0,06 ms, median=0,222 ms, max=0,641 ms, 99th percentile=0,571 ms, 100% below 25 ms
08:28:44.058: audio_thread(Audio): min=0 ms, median=0,107 ms, max=0,27 ms, 99th percentile=0,176 ms
08:28:44.058: obs_graphics_thread(16,6667 ms): min=0,107 ms, median=1,15 ms, max=497,35 ms, 99th percentile=1,84 ms, 99,8454% below 16,667 ms
08:28:44.058:  ┣tick_sources: min=0 ms, median=0,43 ms, max=493,973 ms, 99th percentile=0,789 ms
08:28:44.058:  ┣output_frame: min=0,101 ms, median=0,238 ms, max=3,368 ms, 99th percentile=0,372 ms
08:28:44.058:  ┃ ┗gs_context(video->graphics): min=0,101 ms, median=0,237 ms, max=3,367 ms, 99th percentile=0,371 ms
08:28:44.058:  ┃   ┣render_video: min=0,017 ms, median=0,091 ms, max=0,396 ms, 99th percentile=0,16 ms
08:28:44.058:  ┃   ┃ ┗render_main_texture: min=0,014 ms, median=0,086 ms, max=0,393 ms, 99th percentile=0,149 ms
08:28:44.058:  ┃   ┗gs_flush: min=0,042 ms, median=0,115 ms, max=2,955 ms, 99th percentile=0,208 ms
08:28:44.058:  ┗render_displays: min=0,003 ms, median=0,464 ms, max=1,657 ms, 99th percentile=0,904 ms
08:28:44.058: =================================================
08:28:44.058: == Profiler Time Between Calls ==================
08:28:44.058: obs_hotkey_thread(25 ms): min=25,126 ms, median=25,296 ms, max=25,721 ms, 96% within ±2% of 25 ms (0% lower, 4% higher)
08:28:44.058: obs_graphics_thread(16,6667 ms): min=2,648 ms, median=16,667 ms, max=497,354 ms, 99,6904% within ±2% of 16,667 ms (0,154799% lower, 0,154799% higher)
08:28:44.058: =================================================
08:28:44.064: Number of memory leaks: 1
Fenrirthviti commented 4 years ago

We do not currently support Wayland, so it is unlikely this is something we will be looking in to.

YaLTeR commented 4 years ago

Just to clarify, both OBS and Celeste are running in X11 through Xwayland (an X11 server) in this case, so technically this is an OBS-on-X11 issue.

kkartaltepe commented 4 years ago

There are many implementations of X, and we only support xserver.

If xwayland is truly compatible then the issue is again not an OBS problem but an implementation performance issue and you should bring it up with xwayland maintainers.

emersion commented 4 years ago

As a side note, xwayland is part of xorg-xserver. It's in the same repo, shares the same code and xorg-xserver maintainers also maintain xwayland.

Fenrirthviti commented 4 years ago

On X11 with the exact same setup it's captured at 60 FPS as it should be.

In your report, you stated that running on x11 directly this issue was not present. Therefor, it stands to reason this is not really an issue with OBS, but with xwayland or sway.

It definitely sounds like something that should be reported to them, especially if results are inconsistent. If they can provide details that explain the issue and provide direction on how we would resolve it, we can consider changes. However, at this time, Wayland (and by extension any abstraction or compatibility layers) are not supported.

jp9000 commented 4 years ago

This is something where I'm just generally not sure if we can do anything about for now. We have a capture method for wayland currently in PR state, although I haven't had time to review or even look in to it yet. Perhaps that may work better in the long run.

YaLTeR commented 4 years ago

I asked sway developers and they said it might be an xwayland issue. I'll report it there and see if they can figure it out.

YaLTeR commented 4 years ago

I have reported the issue to xwayland: https://gitlab.freedesktop.org/xorg/xserver/issues/967