Skip to content

Flutter for linux doesn't dispose app #136582

@AngryMane

Description

@AngryMane

Is there an existing issue for this?

Steps to reproduce

#  1. create template flutter application
$ flutter create test_app

# 2. build linux applicatoin
$ flutter build linux

# 3. run linux application with gdb
$ gdb -ex=run build/linux/x64/release/bundle/test_app

# 4. ctrl + c and set break point to `my_application_dispose`
(gdb) b my_application_dispose
(gdb) c

# 5. close app by tapping the cross mark button.  

Expected results

flutter app calls my_application_dispose and gdb catches SIGINT signal at my_application_dispose.

Actual results

flutter app doesn't call my_application_dispose.
But flutter official document expects to call this because it says Make sure to clean it up in my_application_dispose .

I thinks this is resolved by following fix. See the if call g_object_unref movie for the behavior when modified.

$ git diff 
diff --git a/linux/main.cc b/linux/main.cc
index e7c5c54..7b4070d 100644
--- a/linux/main.cc
+++ b/linux/main.cc
@@ -2,5 +2,7 @@
 
 int main(int argc, char** argv) {
   g_autoptr(MyApplication) app = my_application_new();
-  return g_application_run(G_APPLICATION(app), argc, argv);
+  auto ret = g_application_run(G_APPLICATION(app), argc, argv);
+  g_object_unref(app);
+  return ret;
 }

Code sample

It is reproduced in the template app generated by the flutter create command.

Screenshots or Video

Video demonstration for how to reproduce
record.mp4
if call g_object_unref
fixed.mp4

Logs

None

Flutter Doctor output

Doctor output
$ flutter doctor 
Doctor summary (to see all details, run flutter doctor -v):
Could not parse java version from: 

If there is a version please look for an existing bug https://github.com/flutter/flutter/issues/ and if one does not exist file a new issue.
[!] Flutter (Channel stable, 3.13.7, on Ubuntu 22.04.3 LTS 6.2.0-32-generic, locale ja_JP.UTF-8)
    ! Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is not inside your current Flutter SDK checkout at /home/yosuke/development/flutter. Consider adding /home/yosuke/development/flutter/bin to the front of your
      path.
[!] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
    ✗ Could not determine java version
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.74.2)
[✓] Connected device (1 available)
[✓] Network resources

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopfound in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-linuxBuilding on or for Linux specificallyr: fixedIssue is closed as already fixed in a newer versionteam-linuxOwned by the Linux platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions