mixxxdj / mixxx

Mixxx is Free DJ software that gives you everything you need to perform live mixes.
http://mixxx.org
Other
4.48k stars 1.27k forks source link

2.4 GUI lags on Windows when --disable-vumetergl is not specified #11686

Closed JoergAtGithub closed 1 year ago

JoergAtGithub commented 1 year ago

Bug Description

Reported an confirmed here: https://mixxx.zulipchat.com/#narrow/stream/109171-development/topic/2.2E4.20Lagging.20UI.20on.20Windows

Orignial reporter: @NotYourAverageAl

Version

2.4.0 Beta

OS

Windows11

daschuer commented 1 year ago

The feature has been added to Mixxx 2.3 here: https://github.com/mixxxdj/mixxx/pull/10893 to improve the performance on macOs

I remember various discussions around this and recommendation to use this flag. For my understanding the Linux issue with that is solved but windows remains.

Does this issue already apply to Mixxx 2.3 on Windows? If yes this is a 2.3 bug?

Shall we consider to change the default on windows?

JoergAtGithub commented 1 year ago

I would prefer a common solution for all platforms. But first we need to understand what happens here.

NotYourAverageAl commented 1 year ago

Okay, I installed 2.3.5 and I can replicate the gui lag. Waveforms are all okay, except "RGB","HSV", "Filtered"; Mixxx reports 60fps framerate but its defo choppy.

m0dB commented 1 year ago

@NotYourAverageAl when you say: "but its defo choppy", do you mean that a) the actual frame-rate seems to be less than 60, or do you mean that b) the waveforms scroll smoothly, but the rest of the UI interaction (sliders, knobs) is laggy?

I am trying to think how the GL VU-meters can trigger this. If everything is running smoothly with the other GL widgets (waveforms, spinnies), clearly the GL widget itself is not the problem. So there must be something specific of the vumeters that causes this.

Some things that come to mind. I don't have Windows myself, so I can't try these things myself.

1) There is logic in the VU-meters to only redraw when there has been a change in value. The waveforms and the spinnies redraw every time. Maybe something is wrong with this logic, or maybe not redrawing everything frame is somehow worse. I think it's worth trying if removing that logic makes a difference. I can create a PR to test this.

2) The VU-meters are the last GL widgets that are swapped. Maybe once we are trying to swap them, we have already missed the vsync, and the swap blocks. It would be interesting to see what happens if we do not swap the spinnies (comment out emit swapSpinnies(); in waveformwidgetfactory.cpp).

2b) We could also try triggering the swap a bit earlier to see if that makes a difference. In vsyncthread.cpp, instead of

if (remainingForSwap > 100) {
  usleep(remainingForSwap);
}

do something like

if (remainingForSwap > 1100) {
  usleep(remainingForSwap - 1000);
}

3) Maybe there is something particular about the VU-meters that doesn't play nice with the GL widget on Windows. Like the fact that they are small or how they are placed in the widget tree. We could try adding only a single VU-meter and see if the issue still occurs.

It's good to know that --disable-vumeterGL solves the issue, and as a last resort we can hardcode this option on Windows, but I agree that it would be much nicer to avoid that!

NotYourAverageAl commented 1 year ago

@m0dB It's the second scenario; the waveforms scroll smoothly, but the rest of the UI interaction (sliders, knobs) are laggy

m0dB commented 1 year ago

Thanks @NotYourAverageAl . I would say that rules out 2. I will investigate a bit more and probably ask you to test a build with some changes later this weekend. Btw, or you compiling mixxx yourself or simply running builds from github?

NotYourAverageAl commented 1 year ago

I've been running builds from github. I just tried a build with

if (remainingForSwap > 1100) {
  usleep(remainingForSwap - 1000);
}

but saw no improvement. I'm still a newbie, just need to make sure I built the actual commit I made 🤦🏾‍♂️

m0dB commented 1 year ago

@JoergAtGithub I just remembered this old PR of yours:

https://github.com/m0dB/mixxx/pull/4/commits/9e61ef64faa4a08b4e3e6e84382a162208626651

Is this the same issue and solved with this same hack? If that's the case, the problem is probably not with the GL VuMeter per se, but that for some reason event handling gets interrupted and using the legacy VuMeter does periodic update calls just like your hack. I didn't want to take that PR at the time, because I didn't understand how this could work, but it certainly is interesting.

On a side note, I have been doing some profiling on macOS and surprisingly enough, the swaps of the VuMeter take longer that the waveforms and the spinnies...

m0dB commented 1 year ago

Could you please try the builds from this PR: https://github.com/mixxxdj/mixxx/pull/11698

(I am particularly interested if this solves the laggy UI on windows, but also if it doesn't cause any performance degradation on Linux. On macOS it seems to improve performance a bit)

Thanks!

m0dB commented 1 year ago

Another PR: https://github.com/mixxxdj/mixxx/pull/11722 , which disables the GL based VuMeter by default and enables an improved legacy VuMeter.