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
12 changes: 12 additions & 0 deletions shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,18 @@
return canvas;
}

void FlutterPlatformViewsController::Reset() {
UIView* flutter_view = flutter_view_.get();
for (UIView* sub_view in [flutter_view subviews]) {
[sub_view removeFromSuperview];
}
views_.clear();
overlays_.clear();
composition_order_.clear();
active_composition_order_.clear();
composition_frames_.clear();
}

bool FlutterPlatformViewsController::Present() {
bool did_submit = true;
for (size_t i = 0; i < composition_frames_.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class FlutterPlatformViewsController {
const flow::EmbeddedViewParams& params,
IOSSurface& surface);

// Discards all platform views instances and auxiliary resources.
void Reset();

bool Present();

void OnMethodCall(FlutterMethodCall* call, FlutterResult& result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ @implementation FlutterViewController {
fml::scoped_nsobject<FlutterView> _flutterView;
fml::scoped_nsobject<UIView> _splashScreenView;
fml::ScopedBlock<void (^)(void)> _flutterViewRenderedCallback;
std::unique_ptr<shell::FlutterPlatformViewsController> _platformViewsController;
UIInterfaceOrientationMask _orientationPreferences;
UIStatusBarStyle _statusBarStyle;
blink::ViewportMetrics _viewportMetrics;
Expand Down Expand Up @@ -891,7 +890,7 @@ - (void)onPreferredStatusBarStyleUpdated:(NSNotification*)notification {
#pragma mark - Platform views

- (shell::FlutterPlatformViewsController*)platformViewsController {
return _platformViewsController.get();
return [_engine.get() platformViewsController];
}

#pragma mark - FlutterBinaryMessenger
Expand Down
3 changes: 3 additions & 0 deletions shell/platform/darwin/ios/platform_view_ios.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ class PlatformViewIOS final : public PlatformView {
// |shell::PlatformView|
std::unique_ptr<VsyncWaiter> CreateVSyncWaiter() override;

// |shell::PlatformView|
void OnPreEngineRestart() const override;

FML_DISALLOW_COPY_AND_ASSIGN(PlatformViewIOS);
};

Expand Down
8 changes: 8 additions & 0 deletions shell/platform/darwin/ios/platform_view_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "flutter/fml/synchronization/waitable_event.h"
#include "flutter/fml/trace_event.h"
#include "flutter/shell/common/io_manager.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h"
#include "flutter/shell/platform/darwin/ios/ios_external_texture_gl.h"

Expand Down Expand Up @@ -118,6 +119,13 @@
return std::make_unique<VsyncWaiterIOS>(task_runners_);
}

void PlatformViewIOS::OnPreEngineRestart() const {
if (!owner_controller_) {
return;
}
[owner_controller_.get() platformViewsController] -> Reset();
}

fml::scoped_nsprotocol<FlutterTextInputPlugin*> PlatformViewIOS::GetTextInputPlugin() const {
return text_input_plugin_;
}
Expand Down