Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ - (void)dispatchPointerDataPacket:(std::unique_ptr<flutter::PointerDataPacket>)p
return _shell->GetTaskRunners().GetPlatformTaskRunner();
}

- (fml::RefPtr<fml::TaskRunner>)GPUTaskRunner {
FML_DCHECK(_shell);
return _shell->GetTaskRunners().GetGPUTaskRunner();
}

- (void)ensureSemanticsEnabled {
self.iosPlatformView->SetSemanticsEnabled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- (void)dispatchPointerDataPacket:(std::unique_ptr<flutter::PointerDataPacket>)packet;

- (fml::RefPtr<fml::TaskRunner>)platformTaskRunner;
- (fml::RefPtr<fml::TaskRunner>)GPUTaskRunner;

- (fml::WeakPtr<flutter::PlatformView>)platformView;

Expand Down
34 changes: 17 additions & 17 deletions shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -308,27 +308,27 @@ - (void)removeSplashScreenView:(dispatch_block_t _Nullable)onComplete {
}

- (void)installFirstFrameCallback {
auto weak_platform_view = [_engine.get() platformView];
if (!weak_platform_view) {
fml::WeakPtr<flutter::PlatformViewIOS> weakPlatformView = [_engine.get() platformView];
if (!weakPlatformView) {
return;
}
__unsafe_unretained auto weak_flutter_view_controller = self;
// This is on the platform thread.
weak_platform_view->SetNextFrameCallback([weak_platform_view, weak_flutter_view_controller,
task_runner = [_engine.get() platformTaskRunner]]() {
// This is on the GPU thread.
task_runner->PostTask([weak_platform_view, weak_flutter_view_controller]() {
// We check if the weak platform view is alive. If it is alive, then the view controller
// also has to be alive since the view controller owns the platform view via the shell
// association. Thus, we are not convinced that the unsafe unretained weak object is in
// fact alive.
if (weak_platform_view) {
if (weak_flutter_view_controller->_splashScreenView) {
[weak_flutter_view_controller removeSplashScreenView:^{
[weak_flutter_view_controller callViewRenderedCallback];

// Start on the platform thread.
weakPlatformView->SetNextFrameCallback([weakSelf = [self getWeakPtr],
platformTaskRunner = [_engine.get() platformTaskRunner],
gpuTaskRunner = [_engine.get() GPUTaskRunner]]() {
FML_DCHECK(gpuTaskRunner->RunsTasksOnCurrentThread());
// Get callback on GPU thread and jump back to platform thread.
platformTaskRunner->PostTask([weakSelf]() {
fml::scoped_nsobject<FlutterViewController> flutterViewController(
[(FlutterViewController*)weakSelf.get() retain]);
if (flutterViewController) {
if (flutterViewController.get()->_splashScreenView) {
[flutterViewController removeSplashScreenView:^{
[flutterViewController callViewRenderedCallback];
}];
} else {
[weak_flutter_view_controller callViewRenderedCallback];
[flutterViewController callViewRenderedCallback];
}
}
});
Expand Down