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

未关闭
#2,654 3 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
dart, flutter, ios
领域
mobile-dev

调研方向

从 add_to_app/fullscreen 应用开始,使用列出的 Flutter、Xcode 和 iOS 版本重复复现这些转换。将其生命周期与 add_to_app/plugin 和 add_to_app/multiple_flutters 应用进行比较,重点关注日志中记录的 FlutterViewController 附加错误。完成标准是 Flutter 屏幕可以重复打开和关闭,且不会出现该错误或无法显示的问题。

由索引模型根据 Issue 内容生成。

描述

bug

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.
主要语言
Dart
星标
19.3k
派生
7.8k
平均合并
1 天 18 小时
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

flutter/samples 的其他 Issue

查看 flutter/samples 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。