Skip to content

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

@taiju59

Description

@taiju59

Steps to Reproduce

  1. Launch the fullscreen app.
  2. Tap "Launch Flutter ViewController" to open the Flutter screen.
  3. Tap "Exit this screen" to close the Flutter screen.
  4. Repeat steps 2 and 3.
  5. 💥Tap "Launch Flutter ViewController", but the Flutter screen does not appear.
screenlog.mp4

Environment

Flutter: 3.32.4
Xcode: 16.4
iOS Simulator: iPhone 16 (iOS 18.5)

Additional Information

  • The following message is logged when attempting to transition to the Flutter screen, even if the transition appears successful.
    [ERROR:flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm(183)] The supplied FlutterEngine <FlutterEngine: 0x104807470> is already used with FlutterViewController instance <FlutterViewController: 0x10e808600>. One instance of the FlutterEngine can only be attached to one FlutterViewController at a time. Set FlutterEngine.viewController to nil before attaching it to another FlutterViewController.
    
  • Also appeared in the plugin app and an app built following the official guide.
  • The number of transitions before the issue appears varies.
  • Not appeared in the multiple_flutters app.
  • I think setting flutterEngine.viewController = nil on Flutter screen dismissal would solve the problem, but I don't know if this is the right or recommended solution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions