Skip to content

Fix GTK redraw call being called from non-GTK thread. #173602

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

Merged
merged 2 commits into from
Aug 12, 2025

Conversation

robert-ancell
Copy link
Contributor

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

Fixes #173447

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

Fixes flutter#173447
@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

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.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@robert-ancell robert-ancell requested a review from mattkae August 12, 2025 04:07
@github-actions github-actions bot added engine flutter/engine repository. See also e: labels. platform-linux Building on or for Linux specifically a: desktop Running on desktop labels Aug 12, 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 correctly addresses a thread-safety issue by moving the gtk_widget_queue_draw call into an idle callback, ensuring it runs on the main GTK thread. The logic for handling the first frame has also been consolidated into the new redraw_cb function. This not only fixes the bug but also improves the code's structure and thread safety regarding the have_first_frame flag. The changes are well-implemented and effectively resolve the issue.

@robert-ancell
Copy link
Contributor Author

The fix was found by enabling tsan in the Flutter engine build. It also showed some potential issues coming from the Linux task runner, which I will investigate in the future.

Copy link
Contributor

@mattkae mattkae left a comment

Choose a reason for hiding this comment

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

Just a thought, but feel free to merge!

@mattkae
Copy link
Contributor

mattkae commented Aug 12, 2025

Also - I tested and it works well for me!

CC: @loic-sharma

@stuartmorgan-g
Copy link
Contributor

test-exempt: unblocks enabling tooling that catches it

@robert-ancell robert-ancell added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 12, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Aug 12, 2025
Merged via the queue into flutter:master with commit 53676f0 Aug 12, 2025
181 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Aug 12, 2025
@robert-ancell robert-ancell deleted the linux-threading-fixes branch August 12, 2025 23:33
@camsim99 camsim99 added the cp: beta cherry pick this pull request to beta release candidate branch label Aug 12, 2025
@flutteractionsbot
Copy link

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

@camsim99
Copy link
Contributor

@robert-ancell @loic-sharma We'll need to manually CP this to https://github.com/flutter/flutter/tree/flutter-3.35-candidate.0. Can one of you help out here? Thanks!

robert-ancell added a commit to robert-ancell/flutter that referenced this pull request Aug 12, 2025
gtk_widget_queue_draw is not thread-safe, call it from an idle callback.

Fixes flutter#173447
@robert-ancell
Copy link
Contributor Author

@camsim99 - cherry pick in #173667

robert-ancell added a commit to robert-ancell/flutter that referenced this pull request Aug 13, 2025
gtk_widget_queue_draw is not thread-safe, call it from an idle callback.

Fixes flutter#173447
@robert-ancell
Copy link
Contributor Author

And cherry pick for 3.36 branch as requested by @loic-sharma in #173669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: desktop Running on desktop cp: beta cherry pick this pull request to beta release candidate branch engine flutter/engine repository. 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.

Linux desktop app just stops updating its window after a while
6 participants