alibaba / alibaba/flutter_boost

[Bug]: iOS 17.7.2(iphone12)跳转 创建FBFlutterViewContainer时候卡死

Open
#2,203 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

### 请描述遇到的问题,以及您所期望的正确的结果
(同一个设备,多次调试,存在显示正常和显示失败卡死的情况),其他一些设备是可以正常使用。
使用官方提供的demo,delegate代码如下:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];
[self.window makeKeyAndVisible];

FlutterBoostSetupOptions* options = [FlutterBoostSetupOptions createDefault];
options.dartEntryPointArgs = @[ @"I'm from IOS!", @"--for-test" ];

MyFlutterBoostDelegate* delegate=[[MyFlutterBoostDelegate alloc ] init];
[[FlutterBoost instance] setup:application delegate:delegate callback:^(FlutterEngine *engine) {
NSObject* registrar = [engine registrarForPlugin:@"plugin-name"];
FLNativeViewFactory* factory = [[FLNativeViewFactory alloc] initWithMessenger:registrar.messenger];
[[engine registrarForPlugin:@""] registerViewFactory:factory withId:@""];
} options:options];

UIViewControllerDemo *vc = [[UIViewControllerDemo alloc] initWithNibName:@"UIViewControllerDemo" bundle:[NSBundle mainBundle]];
vc.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"hybrid" image:nil tag:0];

FBFlutterViewContainer *fvc = [[FBFlutterViewContainer alloc] init] ;

[fvc setName:@"tab_friend" uniqueId:nil params:@{} opaque:YES];
fvc.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"flutter_tab" image:nil tag:1];

UITabBarController *tabVC = [[UITabBarController alloc] init];
tabVC.viewControllers = @[vc,fvc];

UINavigationController *rvc = [[UINavigationController alloc] initWithRootViewController:tabVC];

delegate.navigationController=rvc;

self.window.rootViewController = rvc;

UIButton *nativeButton = [UIButton buttonWithType:UIButtonTypeCustom];
nativeButton.frame = CGRectMake(self.window.frame.size.width * 0.5 - 50, 200, 100, 40);
nativeButton.backgroundColor = [UIColor redColor];
[nativeButton setTitle:@"push native" forState:UIControlStateNormal];
[nativeButton addTarget:self action:@selector(pushNative) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:nativeButton];

UIButton *pushEmbeded = [UIButton buttonWithType:UIButtonTypeCustom];
pushEmbeded.frame = CGRectMake(self.window.frame.size.width * 0.5 - 70, 150, 140, 40);
pushEmbeded.backgroundColor = [UIColor redColor];
[pushEmbeded setTitle:@"push embedded" forState:UIControlStateNormal];
[pushEmbeded addTarget:self action:@selector(pushEmbeded) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:pushEmbeded];

return YES;
}

当打印如下,即正常显示:

Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
flutter: The Dart VM service is listening on http://127.0.0.1:64296/10u-9h5XPkE=/
flutter: FlutterBoost_dart#page_visibility, #addGlobalObserver, Instance of 'AppGlobalPageVisibilityObserver'
flutter: FlutterBoost_dart#boost_flutter_binding: handleAppLifecycleStateChanged AppLifecycleState.resumed
flutter: dartEntrypointArgs: [I'm from IOS!, --for-test]
flutter: FlutterBoost_dart#_restoreStackForHotRestart, null, null
flutter: FlutterBoost_dart#_saveStackForHotRestart, [1748248963846_/], {1748248963846_/: Instance of 'FlutterContainer'}

当打印如下,加载失败,界面卡死:
Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?
flutter: The Dart VM service is listening on http://127.0.0.1:64296/10u-9h5XPkE=/
flutter: FlutterBoost_dart#page_visibility, #addGlobalObserver, Instance of 'AppGlobalPageVisibilityObserver'
flutter: FlutterBoost_dart#boost_flutter_binding: handleAppLifecycleStateChanged AppLifecycleState.resumed
flutter: dartEntrypointArgs: [I'm from IOS!, --for-test]

跳转代码:

self.flutterContainer = [[FBFlutterViewContainer alloc] init];
[self.flutterContainer setName:@"dbs_BatteryInfo" uniqueId:nil params:@{@"electricValue":electricValue,@"LanguageStr":LanguageStr} opaque:YES];
self.view.backgroundColor = [UIColor blackColor];
self.flutterContainer.view.backgroundColor = [UIColor blackColor];
self.flutterContainer.view.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
[self.view addSubview:self.flutterContainer.view];
[self addChildViewController:self.flutterContainer];

### 请说明如何操作会遇到上述问题

_No response_

### 在下面填入关键复现代码

```
```

### 复现的平台

Both

### Flutter SDK版本

Dart 3.6.1

### FlutterBoost版本

4.3.0

### 是否延迟初始化FlutterBoost

No

### 解决方案

在delegate初始化 :FBFlutterViewContainer *fvc = [[FBFlutterViewContainer alloc] init]; 神奇解决

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the official demo on iOS 17.7.2 with an iPhone 12, comparing the working and hanging initialization paths shown in the issue. Start by tracing FBFlutterViewContainer creation, delegate setup, and navigation to dbs_BatteryInfo. Done means the container consistently loads and navigation no longer hangs without relying on the reported initialization workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, ios
Domain
mobile-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.