hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.24k stars 800 forks source link

Window rule to allow client to render when unfocused / on another workspace #2701

Open Cloudef opened 1 year ago

Cloudef commented 1 year ago

Useful with some games like dark souls which will disconnect you if the fps flutters too much. When running inside gamescope it can limit FPS when unfocused as well. (though not sure if this feature works in wayland?)

donovanglover commented 1 year ago

+1. Current behavior breaks hitsound audio in the osu-stable editor when switching workspaces.

tchofy commented 1 year ago

A workaround I've been doing to get some games to behave as expected is by having OBS capture their window (without recording), but I had to downgrade OBS to 29.0.2-6 due to https://github.com/hyprwm/Hyprland/issues/2679 and https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/58.

donovanglover commented 1 year ago

Workaround works great for me, thanks! Would love to see a window rule in Hyprland if possible.

maxi0604 commented 4 months ago

+1. This issue has shown up for me in Factorio multiplayer, where server lag occurs for other players if the FPS of the server is too low.

cprin21 commented 2 months ago

+1 This issue reduces the experience of using the hyprexpo plugin as it is very clear that the inactive workspaces are not rendered, causing them to show up as freeze frames of how they were when switched away. On a more practical level it makes gaming non-ideal due to instability caused by this issue, such as in World of Warcraft causing disconnects (using Gamescope exacerbates the frequency of disconnects). If not entirely 'fixed', would a client (window) rule or workspace rule be a good workaround, e.g. keeping workspace 5 rendering persistently, or game's client?

alcio1 commented 1 month ago

+1. I'm getting disconnected when switching workspaces while playing Elden Ring.

Myned commented 1 month ago

From my comment @ https://github.com/hyprwm/Hyprland/issues/3776#issuecomment-2249249448:

I can no longer reproduce my main issue with GW2 accumulating frames @ https://github.com/hyprwm/Hyprland/commit/4beac91cbd791657cc53d6e483eb41bf4df1ec0c, so this may be fixed. It's worth retesting affected games with aquamarine if mitigating those issues are the only reason for a [rule].

https://github.com/hyprwm/Hyprland/issues/3776 is likely a duplicate of this issue as well.

Morbiuzx commented 1 week ago

I get disconnected from every Souls game when I leave the game opened in an unfocused workspace, error says "Frame rate unsuitable for online play". I like games to stop rendering when switching workspaces because it lowers power consumption as the GPU is not being used when the game is unfocused, but a windowrule to control this behaviour would be nice in some cases.

Myned commented 1 week ago

Can confirm that Elden Ring still detects low framerate when switching workspaces after the migration (77cf651), but other games that had issues previously with halted rendering seem to handle it better, at least. A rule to fully render in the background (not just at e.g. 1 fps) would likely still be needed for games like ER that are overactive with their cheat prevention methods, or perhaps support for minimize requests but that's another issue entirely.

enzi commented 1 week ago

Yep, +1 to this. A window rule would be best but I can also live with a workspace rule. I tried patching it but had no success. My basic angle was to utilize m_bForceRendering and always render workspace 5 that I set in a config. Tried 2 different angles:

One in Renderer.cpp

@@ -347,6 +347,14 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, PHLWORK

    EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);

    for (auto& w : g_pCompositor->m_vWindows) {
        if (!pWorkspace->m_bForceRendering)
            continue;

        renderWindow(w, pMonitor, time, true, RENDER_PASS_ALL);
    }

    // loop over the tiled windows that are fading out
    for (auto& w : g_pCompositor->m_vWindows) {
        if (!shouldRenderWindow(w, pMonitor))

and one for Swipe.cpp

@@ -59,6 +59,7 @@ void CInputManager::endWorkspaceSwipe() {
    static auto PSWIPENEW     = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_create_new");
    static auto PSWIPEUSER    = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_use_r");
    static auto PWORKSPACEGAP = CConfigValue<Hyprlang::INT>("general:gaps_workspaces");
    static auto PFORCEDRENDERWORKSPACE = CConfigValue<Hyprlang::INT>("general:forced_render_workspace");
    const bool  VERTANIMS     = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert" ||
        m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle.starts_with("slidefadevert");

@@ -185,7 +186,15 @@ void CInputManager::endWorkspaceSwipe() {
        PWORKSPACEL->m_bForceRendering = false;
    if (PWORKSPACER)
        PWORKSPACER->m_bForceRendering = false;
    m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false;

    if (m_sActiveSwipe.pWorkspaceBegin->m_iID != *PFORCEDRENDERWORKSPACE)
    {
        m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false;
    }
    else
    {
        Debug::log(LOG, "Prevented stop rendering");
    }

    m_sActiveSwipe.pWorkspaceBegin  = nullptr;
    m_sActiveSwipe.initialDirection = 0;
ShayBox commented 1 week ago

Also having this issue on VRChat, audio cuts out and video players freeze, which is especially annoying because video players can't seek, so everyone watching has to restart from the beginning with me.

It would be nice if, however this is fixed, it could be applied to only certain workspaces or windows to reduce extra lag from forced rendering.

Perfectio07 commented 1 week ago

I too would love to see this enhancement, whether as a window or workspace rule

vaxerski commented 1 week ago

fine