samples icon indicating copy to clipboard operation
samples copied to clipboard

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

Open taiju59 opened this issue 6 months ago • 3 comments

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.

https://github.com/user-attachments/assets/9f3a406f-4380-4fb7-a633-222a19243fb6

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.

taiju59 avatar Jun 17 '25 09:06 taiju59

Same issue here, Waiting for comments!

ala-harri avatar Jul 01 '25 09:07 ala-harri

Same issue

kennenfromchina avatar Jul 30 '25 06:07 kennenfromchina

This issue mentioned here https://github.com/flutter/flutter/issues/172105

ala-harri avatar Jul 30 '25 08:07 ala-harri