GreenComfyTea / OBS-Stats-on-Stream

A script for OBS that shows lagged/skipped/dropped frames and other data on your stream and/or in chat.
https://obsproject.com/forum/resources/obs-stats-on-stream.1319/
MIT License
19 stars 3 forks source link

Large rendering lag seemingly caused by script #10

Open kesumin opened 1 year ago

kesumin commented 1 year ago

I've been noticing huge rendering lag with an average of 13.5% frames missed compared to an average of 0.6% while disabled (through the plugin).

I'm currently using OBS 23.0.3 (x64) with OBS Stats on Stream 1.3. Bot is disabled. Here is my configuration:

OBS 28.0.3 (64-bit, windows)

21:37:28.097: CPU Name: Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz
21:37:28.097: CPU Speed: 3000MHz
21:37:28.097: Physical Cores: 8, Logical Cores: 8
21:37:28.097: Physical Memory: 16313MB Total, 8917MB Free
21:37:28.097: Windows Version: 10.0 Build 22621 (release: 2009; revision: 1105; 64-bit)
21:37:28.097: Running as administrator: false

21:37:28.415: Available Video Adapters: 
21:37:28.418:   Adapter 0: NVIDIA GeForce RTX 3050
21:37:28.418:     Dedicated VRAM: 4152360960
21:37:28.418:     Shared VRAM:    4257886208
21:37:28.418:     PCI ID:         10de:2507
21:37:28.418:     Driver Version: 31.0.15.2802
21:37:28.418:     output 0:
21:37:28.418:       name=1
21:37:28.418:       pos={0, 0}
21:37:28.418:       size={1920, 1080}
21:37:28.418:       attached=true
21:37:28.418:       refresh=240
21:37:28.418:       space=RGB_FULL_G22_NONE_P709
21:37:28.418:       sdr_white_nits=80
21:37:28.418:       nit_range=[min=0.098400, max=400.000000, max_full_frame=343.748291]
21:37:28.418:     output 1:
21:37:28.418:       name=2
21:37:28.418:       pos={1920, 0}
21:37:28.418:       size={1920, 1080}
21:37:28.418:       attached=true
21:37:28.418:       refresh=60
21:37:28.418:       space=RGB_FULL_G22_NONE_P709
21:37:28.418:       sdr_white_nits=80
21:37:28.418:       nit_range=[min=0.500000, max=270.000000, max_full_frame=270.000000]
21:37:28.418:     output 2:
21:37:28.418:       name=3
21:37:28.418:       pos={-1920, 0}
21:37:28.418:       size={1920, 1080}
21:37:28.418:       attached=true
21:37:28.418:       refresh=144
21:37:28.418:       space=RGB_FULL_G22_NONE_P709
21:37:28.418:       sdr_white_nits=80
21:37:28.418:       nit_range=[min=0.500000, max=270.000000, max_full_frame=270.000000]
21:37:28.420: Loading up D3D11 on adapter NVIDIA GeForce RTX 3050 (0)
21:37:28.489: D3D11 loaded successfully, feature level used: b000
21:37:28.489: DXGI increase maximum frame latency success
21:37:28.490: D3D11 GPU priority setup failed (not admin?)
21:37:29.723: ---------------------------------
21:37:29.723: video settings reset:
21:37:29.723:   base resolution:   1920x1080
21:37:29.723:   output resolution: 1920x1080
21:37:29.723:   downscale filter:  Bicubic
21:37:29.723:   fps:               60/1
21:37:29.723:   format:            NV12
21:37:29.723:   YUV mode:          Rec. 709/Partial
21:37:29.723: NV12 texture support enabled
21:37:29.723: P010 texture support not available
21:37:29.724: Audio monitoring device:
21:37:29.724:   name: VoiceMeeter Aux Input (VB-Audio VoiceMeeter AUX VAIO)
21:37:29.724:   id: {0.0.0.00000000}.{5140dc25-37df-48ab-845c-94130de3f631}
21:37:29.725: ---------------------------------

21:37:31.412: [Lua: OBS-Stats-on-Stream.lua] script loaded
21:37:31.412: [obs-scripting]: Loaded lua script: OBS-Stats-on-Stream.lua
21:37:31.413: [Lua: OBS-Stats-on-Stream.lua] Config loaded: C:\Users\User\AppData\Roaming\obs-studio\basic\profiles\1080pvarfps\basic.ini
21:37:31.413: [Lua: OBS-Stats-on-Stream.lua] No source found
21:37:31.413: [Lua: OBS-Stats-on-Stream.lua] Script is reloaded
21:37:31.415: [obs-scripting]: Loaded lua script: ljsocket.lua

This issue is also present while OBS is run in administrator mode.

Is there any solution for this and/or is there anyone else also experiencing this issue?

GreenComfyTea commented 1 year ago

Hmm. Missed frames are usually caused by GPU overload, but the script doesn't use GPU at all. It simply accesses the values thru OBS API. The only obvious reason that I see is if your Update Delay is too small.

But there is also a bug which causes the update to happen twice in a time frame instead of twice. It was not happening before, but started after specific OBS. Possibly due to changes to scripting system? Possibly the same kinda bug may happen to you?

Anyway, my knowledge of lua has increased over the past year so I was thinking of rewriting the script from scratch. For now I can only suggest you to try older OBS version.

GreenComfyTea commented 1 year ago

Try new version from Release Page and let me know if the issue persists.

Actually, I can see 21:37:31.415: [obs-scripting]: Loaded lua script: ljsocket.lua line in your logs and i dont think its right. Have you added this file to OBS Scripts? You only should have added OBS-Script-on-Stream.lua. ljsocket.lua in older version should be just located in the same folder as main file.

Example Screenshot ![image](https://user-images.githubusercontent.com/30152047/216356496-e6631e76-05b4-47f3-8ccb-44883be01dec.png)
kesumin commented 1 year ago

Sorry about the ridiculously long wait and thank you for the quick update!

I did have ljsocket.lua in my scripts but has now been removed. The error still seems to persist. I've also attempted creating a new scene to test the issue but frames missed to render lag is still at about 1.9%. It's still significantly better than my production scene. Issue may be amplified by something in the scene? I used to ues assets and tools running from a network device but have since moved everything local. Since OBS itself is also local, I don't believe it to be any issue related to hardware. GPU usage is 1-<1% average in the test scene.

Screenshot
![image](https://user-images.githubusercontent.com/65280024/220314941-f7c17022-0df8-41a0-b7ad-54afdeba355b.png)
GreenComfyTea commented 1 year ago

Waiting doesn't cost me anything, so no problem! :3

In fact, OBS can sometimes mess up scene/source configuration. Here's what you can try: 1) Update OBS to v29 just in case; 2) Launch OBS in admin mode again (because it says D3D11 GPU priority setup failed (not admin?)); 3) Set Settings -> Advanced -> Process Priority to High; 4) Create new profile and new scene collection and just create one Text (GDI+) Source for the script to use, to see if its any scenes/sources that are causing it; 5) Change the encoder to software x264 to see if it has any effect (I assume you are using hardware NVENC encoder, in which case you can also try NVENC via FFmpeg provided by StreamFX plugin, which is simply a better implementation of the encoder).