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

Fix the application not disposing by breaking circular references on quit #47684

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

robert-ancell
Copy link
Contributor

GtkApplication windows contain a reference back to the application. This means the MyApplication object in the Flutter application never disposes. We workaround this by removing these references before we quit. This occurs for all GTK applications that quit using this method, see https://gitlab.gnome.org/GNOME/gtk/-/issues/6190. This may be fixed upstream at some point but the proposed workaround should solve the problem for all versions and not conflict with any upstream solution.

Fixes flutter/flutter#136582

@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 or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use 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.

@gspencergoog
Copy link
Contributor

Is there any way to test this? Seems like it would be a good thing to prevent a regression here.

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.

lgtm! As @gspencergoog notes, if there's a reasonable test that could be written, please add it.

Based on the issue filed, it sounds like perhaps a solution can eventually be upstreamed to GTK?

@robert-ancell
Copy link
Contributor Author

To test we'd have to launch and close a full Flutter application - it wasn't clear to me how we'd do that.

I hope an upstream fix does end up in GTK, but we wouldn't be able to rely on it being there for quite some time. I talked to a GTK maintainer and they didn't see it as a major issue and they expected apps to use the shutdown signal.

@cbracken
Copy link
Member

cbracken commented Nov 7, 2023

To test we'd have to launch and close a full Flutter application - it wasn't clear to me how we'd do that.

At some point I should get back to adding support for fixture tests for the Linux embedder. Until then, I don't think we have support for testing this.

@chinmaygarde
Copy link
Member

adding support for fixture tests for the Linux embedder

Can we file a bug for this and a test exemption request on Discord to continue?

@cbracken
Copy link
Member

cbracken commented Nov 9, 2023

We're waiting on a test to be written; there have been side discussions on a mechanism for testing this and @gspencergoog has landed code that should enable a test for this, so in all likelihood won't need to file for a test exemption.

@chinmaygarde
Copy link
Member

Any updates on a test so we can move this along?

@robert-ancell robert-ancell force-pushed the linux-application-dispose branch from 85efb21 to b5cf5a4 Compare November 23, 2023 21:47
@robert-ancell
Copy link
Contributor Author

Has a test now. @gspencergoog could you have a check if it works with the testing framework changes you made? In particular I call gtk_init() without any issues, I see you use fl_ensure_gtk_init in testing/fl_test_gtk_logs.h. I'm not sure if that should be refactored into a separate module or I should be using that.

@gspencergoog
Copy link
Contributor

fl_ensure_gtk_init is mainly used to make sure that the log message handler is set. If gtk_init is OK to call multiple times, then you don't have to use fl_ensure_gtk_init, but you'll need to if you have tests that look for critical log messages. That function exists because calling g_log_set_writer_func more than once is not a good idea (it asserts). Perhaps the name could have been better (e.g. fl_ensure_log_set_writer_func). I guess I called it that because calling a function with "init" in the name more than once seems like a bad idea.

@robert-ancell robert-ancell merged commit 9ebfc84 into flutter:main Nov 29, 2023
26 checks passed
@robert-ancell robert-ancell deleted the linux-application-dispose branch November 29, 2023 01:01
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Nov 29, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Nov 29, 2023
…139190)

flutter/engine@570fec4...4beaa11

2023-11-29 jonahwilliams@google.com [Impeller] fix descriptor pool recycler test flake. (flutter/engine#48479)
2023-11-29 robert.ancell@canonical.com Fix the application not disposing by breaking circular references on quit (flutter/engine#47684)
2023-11-28 dnfield@google.com Fix CanonicalizeURL for file schema (flutter/engine#48466)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC matanl@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
caseycrogers pushed a commit to caseycrogers/flutter that referenced this pull request Dec 29, 2023
…lutter#139190)

flutter/engine@570fec4...4beaa11

2023-11-29 jonahwilliams@google.com [Impeller] fix descriptor pool recycler test flake. (flutter/engine#48479)
2023-11-29 robert.ancell@canonical.com Fix the application not disposing by breaking circular references on quit (flutter/engine#47684)
2023-11-28 dnfield@google.com Fix CanonicalizeURL for file schema (flutter/engine#48466)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-engine-flutter-autoroll
Please CC matanl@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flutter for linux doesn't dispose app
4 participants