[iOS] Fixes SplashScreenView crash when remove from view hierarchy#34496
[iOS] Fixes SplashScreenView crash when remove from view hierarchy#34496auto-submit[bot] merged 2 commits intoflutter:mainfrom
Conversation
|
cc @cyanglaz |
cyanglaz
left a comment
There was a problem hiding this comment.
LGTM % nits.
@gaaclarke Do you mind taking a secondary review?
| UIView* nilView = nil; | ||
| [flutterViewController setSplashScreenView:nilView]; |
There was a problem hiding this comment.
| UIView* nilView = nil; | |
| [flutterViewController setSplashScreenView:nilView]; | |
| [flutterViewController setSplashScreenView:nil]; |
There was a problem hiding this comment.
@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
There was a problem hiding this comment.
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.
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 tonilto remove the splash screen view.
There was a problem hiding this comment.
@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.
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.
There was a problem hiding this comment.
#34743 has merged, apologies for that taking so long. Can you rebase on your change and make this nil?
d4bf336 to
57a4ea3
Compare
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.