alibaba / alibaba/flutter_boost

[featurePR] 修复 iOS FBFlutterContainerManager activeContainer:forUniqueId 方法崩溃

Open
#1,658 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
7.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

### 环境配置:
```
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.3.1 20E241 darwin-x64, locale
zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio (version 2020.3)
✗ Unable to find bundled Java version.
[✓] VS Code (version 1.67.2)
[✓] Connected device (3 available)
```

` **flutter_boost 版本 v3.0-null-safety-release.2**
`
### 问题描述:

- A、B页面为FBFlutterViewContainer
- A present B, A 可以 调用dismiss, B 也可以调用dismiss, ,两者调用dimiss都会关闭B
- 如果 A 作为父节点,B则是子节点,A 的presentingVC 则为null
- 当A调用dismissViewControllerAnimated, B页面返回, FBFlutterViewContainer 内部 dismissViewControllerAnimated:(BOOL)flag completion: 被调用, 页面销毁,
```
//当VC被dismiss时,就通知flutter层销毁page
[self detachFlutterEngineIfNeeded];
[self notifyWillDealloc];
```

- A页面被dismiss,并从 allContainers 中移除, A页面被激活后,就会导致FBFlutterContainerManager activeContainer:forUniqueId 方法崩溃

### 解决方案:
判断下 self.presentingViewController 是否为null,如果null 则不销毁页面,为null 则代表当前页面A 为父节点,不能被销毁
```
- (void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {

BOOL isDismissed = self.presentingViewController ? YES : NO;
[super dismissViewControllerAnimated:flag completion:^(){
if (completion) {
completion();
}
if (isDismissed) {
[self detachFlutterEngineIfNeeded];
[self notifyWillDealloc];
}
}];
}

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the FBFlutterContainerManager activeContainer:forUniqueId path and the overridden dismissViewControllerAnimated:completion: behavior described in the issue. Reproduce the A/B parent-child dismissal flow on iOS, then verify that the container remains valid when presentingViewController is nil and that the crash no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, ios, objective-c
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.