未验证 提交 18ca035c 编写于 作者: A Amir Hardon 提交者: GitHub

Discard embedded UIViews on hot restart. (#6772)

上级 387ca2ef
......@@ -167,6 +167,18 @@ SkCanvas* FlutterPlatformViewsController::CompositeEmbeddedView(
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_order_.size(); i++) {
......
......@@ -59,6 +59,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);
......
......@@ -31,7 +31,6 @@
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;
......@@ -899,7 +898,7 @@ constexpr CGFloat kStandardStatusBarHeight = 20.0;
#pragma mark - Platform views
- (shell::FlutterPlatformViewsController*)platformViewsController {
return _platformViewsController.get();
return [_engine.get() platformViewsController];
}
#pragma mark - FlutterBinaryMessenger
......
......@@ -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);
};
......
......@@ -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"
......@@ -118,6 +119,13 @@ std::unique_ptr<VsyncWaiter> PlatformViewIOS::CreateVSyncWaiter() {
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_;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册