godot-proposals icon indicating copy to clipboard operation
godot-proposals copied to clipboard

Allow the render loop to continue when the window is minimized

Open pochoco24 opened this issue 1 year ago • 3 comments

Describe the project you are working on

A Twitch Stream Overlay for OBS.

Describe the problem or limitation you are having in your project

When minimizing the Godot window, the game capture in OBS freezes until I restore the window back.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

If Godot stops drawing when minimized to save energy, it would be great to toggle that feature so OBS captures could work.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

A boolean in Project Settings to toggle drawing when minimized.

If this enhancement will not be used often, can it be worked around with a few lines of script?

This feature can be useful for VR games or games that require to draw while minimized.

I've tried to compile a custom godot build to fix this problem, but I can't find what disabled minimized window rendering. (I'm not familiar with C++ neither.)

Is there a reason why this should be core and not an add-on in the asset library?

I'm unsure if plugins can change engine behavior like this.

pochoco24 avatar Jul 26 '24 20:07 pochoco24

  • Related to https://github.com/godotengine/godot-proposals/issues/5790.

Calinou avatar Jul 26 '24 21:07 Calinou

In order to solve an XR issue (see PR https://github.com/godotengine/godot/pull/94412), we added a feature (in Godot 4.3-rc1) that will allow you to make Godot keep rendering even if all Godot windows are minimized: DisplayServer.register_additional_output()

If an additional output is registered with DisplayServer, then Godot will keep rendering.

dsnopek avatar Jul 27 '24 17:07 dsnopek

I suppose what @dsnopek mentioned could be implemented as a project setting, which would register an additional output with a reserved object name.

Calinou avatar Jul 27 '24 17:07 Calinou

I tried to capture Godot with OBS while minimized with this commit, but it still freezes in OBS when the window is minimized.

All I have in the scene is an animated moving cube, a camera, and a script:

extends Node3D

var object = Object.new()

func _ready() -> void:
	DisplayServer.register_additional_output(object)

pochoco24 avatar Jul 31 '24 02:07 pochoco24

I tried to capture Godot with OBS while minimized with this commit, but it still freezes in OBS when the window is minimized.

Hm. Well, DisplayServer.register_additional_output() should definitely keep Godot's render loop running. I just re-tested this on Windows (since I most recently tested it on MacOS) with a VR application (OpenXR), and if I minimize the window when using Godot 4.3-beta3 the rendering in the headset stops (and never recovers even if I show the window again), whereas with Godot 4.3-rc1 rendering in the headset continues as expected.

So, I don't think the problem is that the render loop has stopped. I would suspect either a Windows issue (maybe it doesn't update the window when minimized even though Godot is rendering it?), an OBS issue (maybe it can't capture the window's content when it's minimized?) or Godot needs to do something else special in order to make Windows or OBS do the right thing.

In any case, the changes from PR https://github.com/godotengine/godot/pull/94412 seem to be working fine in my testing. But I think perhaps some additional changes may be necessary in order to support your use-case?

dsnopek avatar Jul 31 '24 17:07 dsnopek

an OBS issue (maybe it can't capture the window's content when it's minimized?)

@pochoco24 Are you using Game Capture or Window Capture in OBS? I believe Game Capture has options that control how effectively it can capture minimized windows.

Edit: I realized this was already proposed in https://github.com/godotengine/godot-proposals/issues/1931 a while ago, so consolidating there. Please continue the discussion in that proposal :slightly_smiling_face:

Calinou avatar Jul 31 '24 23:07 Calinou