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

Commit a3194fa

Browse files
[CP-stable]Fix rendering corruption by Flutter and GDK sharing the same OpenGL context (#53183)
This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? flutter/flutter#148653 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/wiki/Hotfix-Documentation-Best-Practices) for examples Linux applications showing visual corruption on some frames ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Visual corruption seen on Linux Flutter apps, affects production apps. ### Workaround: Is there a workaround for this issue? No workaround. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? (rendering corruption not currently testable, may not be possible to test). ### Validation Steps: What are the steps to validate that this fix works? Run app in flutter/flutter#148653 and observe popup not rendering correctly or corruption during window resize.
1 parent a43ee36 commit a3194fa

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

shell/platform/linux/fl_renderer_gdk.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ struct _FlRendererGdk {
1010
// Window being rendered on.
1111
GdkWindow* window;
1212

13-
// Main OpenGL rendering context.
13+
// OpenGL rendering context used by GDK.
14+
GdkGLContext* gdk_context;
15+
16+
// Main OpenGL rendering context used by Flutter.
1417
GdkGLContext* main_context;
1518

16-
// Secondary OpenGL rendering context.
19+
// Secondary OpenGL rendering context used by Flutter.
1720
GdkGLContext* resource_context;
1821
};
1922

@@ -39,6 +42,7 @@ static void fl_renderer_gdk_clear_current(FlRenderer* renderer) {
3942
static void fl_renderer_gdk_dispose(GObject* object) {
4043
FlRendererGdk* self = FL_RENDERER_GDK(object);
4144

45+
g_clear_object(&self->gdk_context);
4246
g_clear_object(&self->main_context);
4347
g_clear_object(&self->resource_context);
4448

@@ -64,6 +68,14 @@ FlRendererGdk* fl_renderer_gdk_new(GdkWindow* window) {
6468
}
6569

6670
gboolean fl_renderer_gdk_create_contexts(FlRendererGdk* self, GError** error) {
71+
self->gdk_context = gdk_window_create_gl_context(self->window, error);
72+
if (self->gdk_context == nullptr) {
73+
return FALSE;
74+
}
75+
if (!gdk_gl_context_realize(self->gdk_context, error)) {
76+
return FALSE;
77+
}
78+
6779
self->main_context = gdk_window_create_gl_context(self->window, error);
6880
if (self->main_context == nullptr) {
6981
return FALSE;
@@ -85,5 +97,5 @@ gboolean fl_renderer_gdk_create_contexts(FlRendererGdk* self, GError** error) {
8597

8698
GdkGLContext* fl_renderer_gdk_get_context(FlRendererGdk* self) {
8799
g_return_val_if_fail(FL_IS_RENDERER_GDK(self), nullptr);
88-
return self->main_context;
100+
return self->gdk_context;
89101
}

0 commit comments

Comments
 (0)