Skip to content

Conversation

@robert-ancell
Copy link
Contributor

Cherry pick of #173602

Impacted users: All Linux users of Flutter
Impact Description: Due to calling gtk_window_redraw on a Flutter thread a lock up may occur. The Flutter app will then become unresponsive.
Workaround: No workaround
Risk: Low - fix is to run the GTK call on the GTK thread which is what the correct behaviour should be.
Test coverage: Rendering covered by existing tests, use of thread not explicitly tested, but #173660 opened to add this in future.
Validation Steps: Run test program in #173447 which generates many frames and maximizes the chance of a lock up.

gtk_widget_queue_draw is not thread-safe, call it from an idle callback.

Fixes flutter#173447
@flutter-dashboard
Copy link

This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter.

Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed.

@github-actions github-actions bot added engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically a: desktop Running on desktop labels Aug 13, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves a critical threading issue by ensuring that the GTK redraw call is executed on the correct GTK thread, preventing potential application freezes. The change correctly uses g_idle_add to schedule the operation. Additionally, the refactoring consolidates the redraw logic with the first-frame signal emission, which is a nice improvement for code clarity. The fix is well-targeted and correct. I have one minor suggestion to fix a typo in a comment.

// callback.
g_idle_add(first_frame_idle_cb, self);
}
// Perform the redraw in the GTK thead.
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There's a typo in this comment. It should be "thread" instead of "thead".1

// Perform the redraw in the GTK thread.

Style Guide References

Footnotes

  1. Code should be readable, and typos can hinder readability. (link)

@robert-ancell robert-ancell changed the title Fix GTK redraw call being called from non-GTK thread. (#173602) [beta] Cherry pick fix GTK redraw call being called from non-GTK thread Aug 13, 2025
@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 13, 2025
@camsim99
Copy link
Contributor

Thanks for the cherry picks @robert-ancell!

@auto-submit auto-submit bot merged commit 780ac30 into flutter:flutter-3.36-candidate.0 Aug 13, 2025
166 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop autosubmit Merge PR when tree becomes green via auto submit App engine flutter/engine related. See also e: labels. platform-linux Building on or for Linux specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants