Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Flutter app hangs after pressing system back and reopening (clean project on Android real device) #168265

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

Open
davidecantini opened this issue May 3, 2025 · 4 comments
Labels
in triage Presently being triaged by the triage team

Comments

@davidecantini
Copy link

Steps to reproduce

  1. Create a brand new Flutter project:
   flutter create open_close_issue
   cd open_close_issue
  1. Run the app on a real Android device (tested on Pixel 8, Android 15):
   flutter run
  1. Once the app is running, press the OS back button to exit it.

  2. Reopen the app by tapping the app icon on the device launcher, then press OS back button. Repeat this a couple of times (in the reported log, it happened in just one cycle, start-close-reopen-> hangs)

Additional info:
I tried to disable impeller (flutter run --no-enable-impeller) but the issue still occurs.

Expected results

The app should reopen normally each time.

Actual results

After a few reopen cycles, the app hangs on splash screen. Logs show visibility changes but no Dart errors. Eventually, the app becomes unresponsive (showing OS message asking to wait or close the unresponsive app).

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatelessWidget {
  const MainApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Hello World!'),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Launching lib/main.dart on Pixel 8 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
I/flutter (24002): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(60)] Using the Impeller rendering backend (Vulkan).
Connecting to VM Service at ws://127.0.0.1:59248/K4qOvYxQXc8=/ws
Connected to the VM Service.
D/InsetsController(24002): hide(ime(), fromIme=false)
I/ImeTracker(24002): com.example.open_close_issue:bf2abcd7: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
D/VRI[MainActivity](24002): visibilityChanged oldVisibility=true newVisibility=false
W/WindowOnBackDispatcher(24002): sendCancelIfRunning: isInProgress=false callback=android.view.ViewRootImpl$$ExternalSyntheticLambda13@5df9966
D/ViewRootImpl(24002): Skipping stats log for color mode
I/flutter (24002): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(60)] Using the Impeller rendering backend (Vulkan).
D/WindowLayoutComponentImpl(24002): Register WindowLayoutInfoListener on Context=com.example.open_close_issue.MainActivity@7402caa, of which baseContext=android.app.ContextImpl@7329411
D/ProfileInstaller(24002): Installing profile for com.example.open_close_issue
D/VRI[MainActivity](24002): visibilityChanged oldVisibility=true newVisibility=false
I/pen_close_issue(24002): Thread[2,tid=24005,WaitingInMainSignalCatcherLoop,Thread*=0xb40000731a662010,peer=0x14002a68,"Signal Catcher"]: reacting to signal 3
I/pen_close_issue(24002): 
I/pen_close_issue(24002): Wrote stack traces to tombstoned
D/VRI[MainActivity](24002): visibilityChanged oldVisibility=true newVisibility=false

At this point the app is hanging already.

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-IT) [391ms]
    • Flutter version 3.29.3 on channel stable at /Users/davide/tools/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (3 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [1,209ms]
    • Android SDK at /Users/davide/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • Java binary at: /opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home/bin/java
      This JDK is specified in your Flutter configuration.
      To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [943ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [11ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [10ms]
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)

[✓] VS Code (version 1.99.3) [9ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (5 available) [6.2s]
    • Pixel 8 (mobile)                • 38091FDJH00P17                       • android-arm64  • Android 15
      (API 35)
    • iPhone 16 Pro (mobile)          • 85972543-7EFA-41C7-9BEC-504327796554 • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.4.1
      24E263 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.4.1
      24E263 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome
      136.0.7103.48

[✓] Network resources [702ms]
    • All expected network resources are available.

• No issues found!
@danagbemava-nc danagbemava-nc added the in triage Presently being triaged by the triage team label May 5, 2025
@danagbemava-nc
Copy link
Member

screen-20250505-103702.mov

Hi @davidecantini, I just tested on my Pixel 7 and I can't seem to reproduce the issue. See the recording above. Is there any additional information you can provide?

Can you also check logcat to see if any errors are thrown?

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 5, 2025
@davidecantini
Copy link
Author

Hi @danagbemava-nc, thanks for testing it.

For all tests, I’m running the app from VS Code with the device connected via USB (using flutter run from the IDE). The issue reproduces after closing and reopening the app after pressing the OS back button, with the USB still connected. Sometimes it takes only one cycle close-reopen (as in the video below), sometimes a couple of times, but it eventually happens.

screen-20250507-001016.mp4

Here is the log when the video above was recorded:

Launching lib/main.dart on Pixel 8 in debug mode...
✓ Built build/app/outputs/flutter-apk/app-debug.apk
I/flutter (10686): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(60)] Using the Impeller rendering backend (Vulkan).
Connecting to VM Service at ws://127.0.0.1:49768/HnQ9XJttgUQ=/ws
Connected to the VM Service.
D/InsetsController(10686): hide(ime(), fromIme=false)
I/ImeTracker(10686): com.example.open_close_issue:8b5b293c: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
D/ProfileInstaller(10686): Installing profile for com.example.open_close_issue
D/InsetsController(10686): hide(ime(), fromIme=false)
I/ImeTracker(10686): com.example.open_close_issue:1d79e422: onCancelled at PHASE_CLIENT_ALREADY_HIDDEN
D/VRI[MainActivity](10686): visibilityChanged oldVisibility=true newVisibility=false
W/WindowOnBackDispatcher(10686): sendCancelIfRunning: isInProgress=false callback=android.view.ViewRootImpl$$ExternalSyntheticLambda13@bd594a7
D/ViewRootImpl(10686): Skipping stats log for color mode
I/flutter (10686): [IMPORTANT:flutter/shell/platform/android/android_context_vk_impeller.cc(60)] Using the Impeller rendering backend (Vulkan).
I/ContentCaptureHelper(10686): Setting logging level to OFF
D/WindowLayoutComponentImpl(10686): Register WindowLayoutInfoListener on Context=com.example.open_close_issue.MainActivity@7329411, of which baseContext=android.app.ContextImpl@e25f26f
I/pen_close_issue(10686): Thread[2,tid=10692,WaitingInMainSignalCatcherLoop,Thread*=0xb40000731a66e2c0,peer=0x14001718,"Signal Catcher"]: reacting to signal 3
I/pen_close_issue(10686):
I/pen_close_issue(10686): Wrote stack traces to tombstoned
D/VRI[MainActivity](10686): visibilityChanged oldVisibility=true newVisibility=false
Lost connection to device.

Exited.

I see this consistently in logcat right before the app becomes unresponsive:

I/pen_close_issue(10686): Thread[2,tid=10692,WaitingInMainSignalCatcherLoop,...]: reacting to signal 3  
I/pen_close_issue(10686): Wrote stack traces to tombstoned  
Lost connection to device.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 6, 2025
@danagbemava-nc
Copy link
Member

Hi @davidecantini, aside the Pixel 8, are you seeing this on any other devices? I retried to repro and repeated it about 20x but it did not freeze for me

@danagbemava-nc danagbemava-nc added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 7, 2025
@davidecantini
Copy link
Author

Hi @danagbemava-nc, yes, I can see the issue on both these devices I tested (from >flutter devices):

M2011K2G (mobile)  • 1***                     • android-arm64  • Android 14 (API 34)
Pixel 8 (mobile)      • 3***                     • android-arm64  • Android 15 (API 35)

One thing I noticed is that after the app becomes unresponsive and I acknowledge the “App Not Responding” alert, VS Code typically loses connection to the device (as shown in the logs above) and, once the debugger is detached, the app seems to behave normally - I can open and close it repeatedly without triggering the issue again.
This seems to suggest that the debugger connection (or something being held up or locked due to the debugger’s involvement) might be contributing to the problem.

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in triage Presently being triaged by the triage team
Projects
None yet
Development

No branches or pull requests

2 participants