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

[Linux][FlView] fix rendering on startup when shown after plugin registration #38982

Merged
merged 2 commits into from
Jan 26, 2023

Conversation

jpnurmi
Copy link
Member

@jpnurmi jpnurmi commented Jan 18, 2023

This PR contains the engine-side changes required for changing the Linux app template to show the window after registering plugins (flutter/flutter#118269).

Currently, FlView assumes that it gets realized before its size gets allocated. If we change the order in the app template, the view gets added to a layout first and then realized. Make sure to call handle_geometry_changed() from both and check the pre-conditions for fl_renderer_wait_for_frame() to ensure that the first frame is rendered regardless of the order of size-allocate and realize.

This makes it possible to change my_application.cc as follows:

diff --git a/linux/my_application.cc b/linux/my_application.cc
index d9eae08..59af183 100644
--- a/linux/my_application.cc
+++ b/linux/my_application.cc
@@ -48,7 +48,6 @@ static void my_application_activate(GApplication* application) {
   }
 
   gtk_window_set_default_size(window, 1280, 720);
-  gtk_widget_show(GTK_WIDGET(window));
 
   g_autoptr(FlDartProject) project = fl_dart_project_new();
   fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
@@ -59,6 +58,7 @@ static void my_application_activate(GApplication* application) {
 
   fl_register_plugins(FL_PLUGIN_REGISTRY(view));
 
+  gtk_widget_show(GTK_WIDGET(window));
   gtk_widget_grab_focus(GTK_WIDGET(view));
 }
 
Before After
image image

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

Thanks @jpnurmi !

@cbracken cbracken added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Jan 19, 2023
@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 26, 2023
@auto-submit auto-submit bot merged commit d17004d into flutter:main Jan 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 26, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 26, 2023
…119287)

* 8ca3b2b72 Roll Fuchsia Mac SDK from KLzrg8eFD9m5J9xa-... to MyL3JcOBni9CTx9wz... (flutter/engine#39171)

* d17004dd9 [Linux][FlView] fix rendering on startup when shown after plugin registration (flutter/engine#38982)
@jpnurmi jpnurmi deleted the realize-vs-size-allocate branch January 27, 2023 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App needs tests platform-linux
Projects
None yet
4 participants