-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Fixes SplashScreenView crash when remove from view hierarchy #34496
Conversation
cc @cyanglaz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % nits.
@gaaclarke Do you mind taking a secondary review?
UIView* nilView = nil; | ||
[flutterViewController setSplashScreenView:nilView]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIView* nilView = nil; | |
[flutterViewController setSplashScreenView:nilView]; | |
[flutterViewController setSplashScreenView:nil]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyanglaz Emm, setSplashScreenView:nil
would build error because splashScreenView
declare nonnull
and we treat build warning as error. Actually we have the case that let user pass the nil
to remove the splash screen view, see
engine/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Lines 630 to 637 in 257b05f
- (void)setSplashScreenView:(UIView*)view { | |
if (!view) { | |
// Special case: user wants to remove the splash screen view. | |
if (_splashScreenView) { | |
[self removeSplashScreenView:nil]; | |
} | |
return; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this wrong that we make the view
paramter nonnull and still checking nullability in the implementation? Maybe we should update the method syntax to make the parameter nonnull.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like setSplashScreenView
should allow nil #6834, probably an oversight from adding NS_ASSUME_NONNULL_BEGIN
. Can you instead make the API nullable?
- @property(strong, nonatomic) UIView* splashScreenView;
+ @property(strong, nonatomic, nullable) UIView* splashScreenView;
and add a comment to the header like:
*
Set tonil
to remove the splash screen view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cyanglaz We support view
nullable to remove the view
from view hierarchy, but we use NS_ASSUME_NONNULL_BEGIN
to declare view
nonnull.
@jmagman We can make the API nullable, but it may lead to an API-breaking change for Swift users, if Swift users use the getter of splashScreenView
, the return type changed from UIView
to UIView?
.
But I agree that we should make it nullable, should we need to make a new PR as a breaking change to add nullable keyword?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we don't make this API nullable, it means this feature is not supported on swift, right?
So I think we should introduce the swift breaking change and make the API nullable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#34743 has merged, apologies for that taking so long. Can you rebase on your change and make this nil
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmagman Done. :)
d4bf336
to
57a4ea3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes flutter/flutter#37818 , flutter/flutter#105423. There are some cases that we remove the splashScreenView from superview before add it to view hierarchy.
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.