Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
[Linux][FlView] fix rendering on startup when shown after plugin regi…
Browse files Browse the repository at this point in the history
…stration (#38982)

* [FlView] fix rendering on startup when shown after plugin registration

* Add clarifying comment
  • Loading branch information
jpnurmi authored Jan 26, 2023
1 parent 8ca3b2b commit d17004d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions shell/platform/linux/fl_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,17 @@ static void handle_geometry_changed(FlView* self) {
self->engine, allocation.width * scale_factor,
allocation.height * scale_factor, scale_factor);

fl_renderer_wait_for_frame(self->renderer, allocation.width * scale_factor,
allocation.height * scale_factor);
// Make sure the view has been realized and its size has been allocated before
// waiting for a frame. `fl_view_realize()` and `fl_view_size_allocate()` may
// be called in either order depending on the order in which the window is
// shown and the view is added to a container in the app runner.
//
// Note: `gtk_widget_init()` initializes the size allocation to 1x1.
if (allocation.width > 1 && allocation.height > 1 &&
gtk_widget_get_realized(GTK_WIDGET(self))) {
fl_renderer_wait_for_frame(self->renderer, allocation.width * scale_factor,
allocation.height * scale_factor);
}
}

// Adds a widget to render in this view.
Expand Down Expand Up @@ -661,6 +670,8 @@ static void fl_view_realize(GtkWidget* widget) {
g_warning("Failed to start Flutter engine: %s", error->message);
return;
}

handle_geometry_changed(self);
}

// Implements GtkWidget::get-preferred-width
Expand Down

0 comments on commit d17004d

Please sign in to comment.