[iOS] Fixes SplashScreenView crash when remove from view hierarchy (flutter/engine#34496)
This commit is contained in:
@@ -197,7 +197,7 @@ FLUTTER_DARWIN_EXPORT
|
||||
|
||||
/**
|
||||
* Specifies the view to use as a splash screen. Flutter's rendering is asynchronous, so the first
|
||||
* frame rendered by the Flutter application might not immediately appear when theFlutter view is
|
||||
* frame rendered by the Flutter application might not immediately appear when the Flutter view is
|
||||
* initially placed in the view hierarchy. The splash screen view will be used as
|
||||
* a replacement until the first frame is rendered.
|
||||
*
|
||||
|
||||
@@ -507,7 +507,7 @@ static void SendFakeTouchEvent(FlutterEngine* engine,
|
||||
|
||||
- (void)removeSplashScreenView:(dispatch_block_t _Nullable)onComplete {
|
||||
NSAssert(_splashScreenView, @"The splash screen view must not be null");
|
||||
UIView* splashScreen = _splashScreenView.get();
|
||||
UIView* splashScreen = [_splashScreenView.get() retain];
|
||||
_splashScreenView.reset();
|
||||
[UIView animateWithDuration:0.2
|
||||
animations:^{
|
||||
@@ -515,6 +515,7 @@ static void SendFakeTouchEvent(FlutterEngine* engine,
|
||||
}
|
||||
completion:^(BOOL finished) {
|
||||
[splashScreen removeFromSuperview];
|
||||
[splashScreen release];
|
||||
if (onComplete) {
|
||||
onComplete();
|
||||
}
|
||||
|
||||
@@ -433,6 +433,15 @@ extern NSNotificationName const FlutterViewControllerWillDealloc;
|
||||
OCMVerify(never(), [mockEngine attachView]);
|
||||
}
|
||||
|
||||
- (void)testSplashScreenViewRemoveNotCrash {
|
||||
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"engine" project:nil];
|
||||
[engine runWithEntrypoint:nil];
|
||||
FlutterViewController* flutterViewController =
|
||||
[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil];
|
||||
[flutterViewController setSplashScreenView:[[UIView alloc] init]];
|
||||
[flutterViewController setSplashScreenView:nil];
|
||||
}
|
||||
|
||||
- (void)testInternalPluginsWeakPtrNotCrash {
|
||||
FlutterSendKeyEvent sendEvent;
|
||||
@autoreleasepool {
|
||||
|
||||
Reference in New Issue
Block a user