Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flickering in embedded game when paused #102006

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Hilderin
Copy link
Contributor

This PR should fix the flickering and artefacts when the embedded game is resized for a larger size when the game is paused. This is caused by the fact that Godot does not rerender when the game is paused, which is expected.

Although I was unable to reproduce the flickering on my computer, I did observe artifacts when the game was paused and the window was resized to a larger size.

To prevent these artifacts and hopefully the flickering, I have implemented a solution that saves the size of the embedded game when the pause is activated. This saved size is then set as a fixed size in the embedded process control to ensure the game window never becomes larger.

I also fixed another issue related to pause mode. When the game was paused, closing the floating window did not complete until the game was unpaused. This issue occurred because the close message sent to the window was not processed.

Additionally, I discovered another minor, unrelated issue. If the last selected tab was Game when the editor was launched, and the game was started with the floating window enabled, a blank main screen would appear in the editor. The content of the Game tab was transferred to the floating window, but the tab (main screen) was not changed for another editor.

@Hilderin Hilderin added this to the 4.4 milestone Jan 25, 2025
@AThousandShips AThousandShips requested a review from a team January 25, 2025 09:25
Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not able to reproduce the flickering, but changes look reasonable, and I have not encountered any issues while testing it.

@@ -787,14 +799,29 @@ void GameView::_window_close_request() {
embedded_process->reset();

// When the embedding is not complete, we need to kill the process.
if (embedded_process->is_embedding_in_progress()) {
// If the game is paused, the close request will not be processed by the game, so it's better to kill the process.
if (embedded_process->is_embedding_in_progress() || paused) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (embedded_process->is_embedding_in_progress() || paused) {
if (paused || embedded_process->is_embedding_in_progress()) {

Cheaper condition first

//Stretch... No need for the window size.
embedded_process->set_window_size(Size2i());
if (embed_size_mode == SIZE_MODE_FIXED || embed_size_mode == SIZE_MODE_KEEP_ASPECT) {
//The embedded process control will need the desired window size.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//The embedded process control will need the desired window size.
// The embedded process control will need the desired window size.

While we're here

EditorRun::WindowPlacement placement = EditorRun::get_window_placement();
embedded_process->set_window_size(placement.size);
} else {
//Stretch... No need for the window size.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Stretch... No need for the window size.
// Stretch... No need for the window size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Horrible Flickering when closing docks while embedded game is paused
3 participants