Skip to content

[add-to-app] Cannot re-open Flutter screen after multiple transitions between iOS native and Flutter #172105

@ala-harri

Description

@ala-harri

Steps to reproduce

  1. Integrate Flutter as a module into an existing iOS app using single flutter engine.

  2. Launch a Flutter screen from a native view controller (e.g., using FlutterEngine and FlutterViewController).

  3. Dismiss or pop the Flutter screen to return to native.

  4. Repeat the process several times (open Flutter, close, then open again).

  5. After a few transitions, attempting to open the Flutter screen again results in a freeze or no response.

Expected results

The Flutter screen should open reliably every time, regardless of how many transitions occur between native and Flutter.

Actual results

After several transitions, the Flutter screen fails to open. The app may freeze, or the Flutter engine does not render the screen.

Code sample

Code sample
// Example of presenting FlutterViewController from native
let flutterEngine = (UIApplication.shared.delegate as! AppDelegate).flutterEngine
let flutterViewController = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
self.present(flutterViewController, animated: true, completion: nil)

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel stable, 3.32.4, on macOS 15.5 24F74 darwin-arm64, locale
    en-PS) [718ms]
    • Flutter version 3.32.4 on channel stable at
      /Users/alaamarneh/development/flutter
    ! Warning: `flutter` on your path resolves to
      /Users/alaamarneh/Development/flutter/bin/flutter, which is not inside
      your current Flutter SDK checkout at
      /Users/alaamarneh/development/flutter. Consider adding
      /Users/alaamarneh/development/flutter/bin to the front of your path.
    ! Warning: `dart` on your path resolves to
      /Users/alaamarneh/Development/flutter/bin/dart, which is not inside your
      current Flutter SDK checkout at /Users/alaamarneh/development/flutter.
      Consider adding /Users/alaamarneh/development/flutter/bin to the front of
      your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 6fba2447e9 (4 weeks ago), 2025-06-12 19:03:56 -0700
    • Engine revision 8cd19e509d
    • Dart version 3.8.1
    • DevTools version 2.45.1
    • If those were intentional, you can disregard the above warnings; however
      it is recommended to use "git" directly to perform update checks and
      upgrades.

[!] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    [758ms]
    • Android SDK at /Users/alaamarneh/Library/Android/sdk
    ✗ cmdline-tools component is missing.
      Try installing or updating Android Studio.
      Alternatively, download the tools from
      https://developer.android.com/studio#command-line-tools-only and make sure
      to set the ANDROID_HOME environment variable.
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/to/macos-android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [1,540ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

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

[✓] Android Studio (version 2025.1.2) [8ms]
    • Android Studio at /Applications/Android Studio Preview.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.6+-13391695-b895.109)

[✓] Android Studio (version 2024.3) [7ms]
    • 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.6+-13355223-b631.42)

[✓] Connected device (2 available) [6.9s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.5 24F74 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 138.0.7204.101

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

! Doctor found issues in 2 categories.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: existing-appsIntegration with existing apps via the add-to-app flowc: regressionIt was better in the past than it is nowd: examplesSample code and demosengineflutter/engine related. See also e: labels.found in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions