-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//Stretch... No need for the window size. | |
// Stretch... No need for the window size. |
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 theGame
tab was transferred to the floating window, but the tab (main screen) was not changed for another editor.