Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[iOS] Fixes SplashScreenView crash when remove from view hierarchy #34496

Merged
merged 2 commits into from
Jul 29, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,15 @@ - (void)callViewRenderedCallback {

- (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:^{
splashScreen.alpha = 0;
}
completion:^(BOOL finished) {
[splashScreen removeFromSuperview];
[splashScreen release];
if (onComplete) {
onComplete();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,15 @@ - (void)testViewDidLoadDoesntInvokeEngineAttachViewWhenEngineNeedsLaunch {
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 {
Expand Down