-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Started bridging the scene delegate to the lifecycle delegate for shortcuts #170180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
||
@interface FlutterAppDelegate () | ||
|
||
@property(nonatomic, strong, nullable) FlutterPluginAppLifeCycleDelegate* lifeCycleDelegate; |
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.
keep the readwrite implementation property as-is, add readonly
to this.
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.
I removed the direct usage of the lifecycle delegate and instead started calling directly into the app delegate as we discussed in our meeting. That's a bit more scary but I think it technically is the safer thing to do.
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.
could you share a bit more details (for me and future readers) on app delegate vs life cycle delegate decision? Thx!
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.
Jenn pointed out that users could be subclassing FlutterAppDelegate and override application:performActionForShortcutItem:completionHandler:
and be performing their own logic, like say analytics for the usage of shortcuts.
Talking directly the the lifecycle delegate would break them, but fix the plugin problems. So, I decided to call the delegate directly.
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.
looks reasonable. can we add some unit tests?
We have integration tests. We can't add unit tests because it relies on the application delegate being a FlutterAppDelegate which we don't support in our unit test harness. |
Could you explain more?
|
Thanks, I forgot you could mock like that. Done. |
autosubmit label was removed for flutter/flutter/170180, because - The status or check suite Linux gradle_plugin_fat_apk_test has failed. Please fix the issues identified (or deflake) before re-applying this label. |
rerunning Linux gradle_plugin_fat_apk_test, issue filed |
@hellohuanlin friendly ping |
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.
I have some concerns around relaying scene delegate calls to app delegate, mainly the fact that we are changing Apple's behavior that may surprise us in the future. See more details here: #170037 (comment)
If there's no other way around, I'm fine with relaying the calls, but just wanna hear your thoughts on it first.
if ([appDelegate isKindOfClass:[FlutterAppDelegate class]]) { | ||
[appDelegate application:FlutterSharedApplication.application | ||
performActionForShortcutItem:shortcutItem | ||
completionHandler:completionHandler]; |
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 do it for one method, we should probably do it for all methods for minimal surprise.
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.
This method is special where apple has specifically called out that they will not call the old app delegate method. Things like "will resign active" are still called. The goal of this PR is to fix broken behavior.
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.
Things like "will resign active" are still called.
IIRC from my experiment a few days ago, "will resign active" are not called
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.
Same as "background/foreground" callbacks (there are some discussions around it a few days ago in the chat channel)
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.
Related: #170178
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.
I think we should be test driven. I don't think we have any failing tests related to resign active. We should double check, but I think that should be addressed in a different PR.
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.
also reported in #170037
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.
I think that should be addressed in a different PR.
Either way sounds good to me. I just wanna have a consistent behavior - if we relay 1 call, we should relay all similar calls.
I agree. This feels like the kind of thing that addresses the short-term pain of everyone having to move their code to the scene delegate (or add the relay to their own code) but will create headaches long-term. I would much rather see Flutter take the stance that code should be moved to align with platform expectations. Another approach would be to spin up a subclass that does the relaying. Teams that don't want that functionality would simply use the superclass instead. |
@AquaGeek what headaches are you thinking of? Can you explain further? |
@hellohuanlin What do you see the alternative being? Here's the options I see:
We chose to do 2 because 3 could end up breaking users without any runtime help. I'm not quite sure what the problem we are trying to avoid is. I think there is just a general sense that maybe something bad can happen, but I couldn't think of one. All of this happens under the hood and we can swap it around if we want. |
This resonate with my last paragraph in #170037 (comment)
Maybe it is the least worst option we have (unless we can think of a better option?) I'm not against this. I just wanna make sure we are aware of this departure of apple's practice, and get it well documented if we do so. |
This reverts commit 10b32cd.
I switched back to talking the the lifecycle delegate directly. While I think in general we should make our decisions based on concrete concerns and tests, not calling the FlutterAppDelegate isn't technically a breaking change even if it can break some customers. So, I'm fine doing the more reserved solution of talking to the delegate directly. Keeping the logic inline with Apple's will be more understandable at least for the odd scenarios where it may matter. |
What do you think about we firstly start with relaying the calls, and adding the warning in tooling against app delegate usage (apple's deprecation warning isn't sufficient as we discussed yesterday), and then remove the relay in the future? This allows a smoother transition for developers. |
I don't think it's necessary. The people this effects is low, there is no longer an automatic migration and and it's not a Breaking Change. I think that will just complicate the migration. Who knows what decision will be made in the future but migrating may never be an automatic thing considering the events of the last few days. I plan on filing an issue for the static warning like we discussed yesterday as part of resolving this PR, so that idea doesn't get lost. |
Sounds good. I think i'm comfortable with this. Before stamping this, @jmagman FYI this reverts to the original implementation that you had concerns: #170180 (comment) |
testing: There integration tests in the plugins repo.
fixes: #169928
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.