Discard embedded UIViews on hot restart. (#6772)

This commit is contained in:
Amir Hardon 2018-11-08 09:32:01 -08:00 committed by GitHub
parent 387ca2ef86
commit 18ca035cfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 2 deletions

View File

@ -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++) {

View File

@ -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);

View File

@ -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

View File

@ -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);
};

View File

@ -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_;
}