Skip to content

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

Merged
merged 7 commits into from
Jun 17, 2025

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Jun 6, 2025

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.

@github-actions github-actions bot added platform-ios iOS applications specifically engine flutter/engine repository. See also e: labels. team-ios Owned by iOS platform team labels Jun 6, 2025

@interface FlutterAppDelegate ()

@property(nonatomic, strong, nullable) FlutterPluginAppLifeCycleDelegate* lifeCycleDelegate;
Copy link
Member

@jmagman jmagman Jun 6, 2025

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.

Copy link
Member Author

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.

Copy link
Contributor

@hellohuanlin hellohuanlin Jun 6, 2025

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!

Copy link
Member Author

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.

@gaaclarke
Copy link
Member Author

quick actions tested locally (since the test won't run as part of presubmit), it works:

Screenshot 2025-06-06 at 3 16 22 PM

@gaaclarke gaaclarke marked this pull request as ready for review June 6, 2025 22:17
@gaaclarke gaaclarke requested a review from a team as a code owner June 6, 2025 22:17
@gaaclarke gaaclarke requested review from jmagman and vashworth June 6, 2025 22:17
Copy link
Contributor

@hellohuanlin hellohuanlin left a 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?

@gaaclarke
Copy link
Member Author

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.

@hellohuanlin
Copy link
Contributor

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? OCMock should be able to mock the app delegate (I may misunderstand the problem tho).

id mockApplication = OCMClassMock([UIApplication class]);
OCMStub([mockApplication shared]).andReturn(mockApplication);
id mockAppDelegate = OCMClassMock([FlutterAppDelegate class]);
OCMStub([mockApplication delegate]).andReturn(mockApplication)

@gaaclarke
Copy link
Member Author

Could you explain more? OCMock should be able to mock the app delegate (I may misunderstand the problem tho).

Thanks, I forgot you could mock like that. Done.

@gaaclarke gaaclarke requested a review from hellohuanlin June 9, 2025 20:35
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jun 9, 2025
Copy link
Contributor

auto-submit bot commented Jun 9, 2025

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.

@gaaclarke
Copy link
Member Author

rerunning Linux gradle_plugin_fat_apk_test, issue filed

@gaaclarke
Copy link
Member Author

@hellohuanlin friendly ping

Copy link
Contributor

@hellohuanlin hellohuanlin left a 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];
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Contributor

@hellohuanlin hellohuanlin Jun 10, 2025

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related: #170178

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also reported in #170037

Copy link
Contributor

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.

@AquaGeek
Copy link

AquaGeek commented Jun 10, 2025

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.

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.

@gaaclarke
Copy link
Member Author

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.

@hellohuanlin
Copy link
Contributor

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.

@gaaclarke
Copy link
Member Author

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.

@hellohuanlin
Copy link
Contributor

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)

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@gaaclarke gaaclarke added this pull request to the merge queue Jun 17, 2025
Merged via the queue into flutter:master with commit b1af493 Jun 17, 2025
180 of 181 checks passed
@gaaclarke gaaclarke deleted the shortcut-bridge branch June 17, 2025 23:25
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 18, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 19, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jun 19, 2025
Roll Flutter from 8303a96a0a99 to 85a9b4f38906 (93 revisions)

flutter/flutter@8303a96...85a9b4f

2025-06-19 engine-flutter-autoroll@skia.org Roll Skia from af242598f14d to 794936b23812 (2 revisions) (flutter/flutter#170875)
2025-06-19 gourabkumarsi@google.com Drop support for 21/22 Lollipop (flutter/flutter#170748)
2025-06-19 engine-flutter-autoroll@skia.org Roll Dart SDK from 6020126c10e8 to bce9abe03175 (1 revision) (flutter/flutter#170872)
2025-06-19 engine-flutter-autoroll@skia.org Roll Skia from df97f7f407db to af242598f14d (4 revisions) (flutter/flutter#170867)
2025-06-19 engine-flutter-autoroll@skia.org Roll Skia from 1d8f7ebd23cc to df97f7f407db (5 revisions) (flutter/flutter#170864)
2025-06-19 engine-flutter-autoroll@skia.org Roll Dart SDK from 4ab716b09e9d to 6020126c10e8 (1 revision) (flutter/flutter#170862)
2025-06-19 engine-flutter-autoroll@skia.org Roll Skia from 291d41414fa7 to 1d8f7ebd23cc (2 revisions) (flutter/flutter#170857)
2025-06-19 engine-flutter-autoroll@skia.org Roll Dart SDK from b32559bca3cc to 4ab716b09e9d (9 revisions) (flutter/flutter#170855)
2025-06-19 jessy.yameogo@gmail.com remove --start-paused flag by default and set useDwdsWebSocketConnect… (flutter/flutter#170612)
2025-06-18 matanlurey@users.noreply.github.com Engine builders no longer require `is_fusion` (flutter/flutter#170849)
2025-06-18 engine-flutter-autoroll@skia.org Roll Skia from 5f110d5f48a3 to 291d41414fa7 (2 revisions) (flutter/flutter#170836)
2025-06-18 robert.ancell@canonical.com Use a shared vertex buffer for rendering layers. (flutter/flutter#170717)
2025-06-18 30870216+gaaclarke@users.noreply.github.com fixes deeplinking in uiscenedelegate migrated projects (flutter/flutter#170452)
2025-06-18 jonahwilliams@google.com [Impeller] fix array uniforms on GLES backend. (flutter/flutter#170710)
2025-06-18 chinmaygarde@google.com [Impeller] Update README to add section about custom embedders. (flutter/flutter#170077)
2025-06-18 jason-simmons@users.noreply.github.com Escape the forbidden strings in the regex used to check test command output (flutter/flutter#170702)
2025-06-18 30870216+gaaclarke@users.noreply.github.com License cpp jun16 (flutter/flutter#170716)
2025-06-18 chinmaygarde@google.com Work around newer compilers requiring the satisfaction of three-way comparison of EncodableValue. (flutter/flutter#170822)
2025-06-18 45459898+RamonFarizel@users.noreply.github.com Update didUnmountRenderObject text description (flutter/flutter#169628)
2025-06-18 engine-flutter-autoroll@skia.org Roll Skia from 297dbc32a6c7 to 5f110d5f48a3 (2 revisions) (flutter/flutter#170821)
2025-06-18 matanlurey@users.noreply.github.com Add an initial "Using feature flags" doc for the team. (flutter/flutter#170767)
2025-06-18 34465683+rkishan516@users.noreply.github.com Feat: Add mouse cursor for CupertinoDialogAction (flutter/flutter#169051)
2025-06-18 matanlurey@users.noreply.github.com Update `Engine-artifacts.md` to reflect flutter/cocoon/4785 (flutter/flutter#170751)
2025-06-18 alex.medinsh@gmail.com `CupertinoPicker` new onChanged behaviour (flutter/flutter#170202)
2025-06-18 pateltirth454@gmail.com Rename `entryPointBaseUrl` to `entrypointBaseUrl` (flutter/flutter#170166)
2025-06-18 engine-flutter-autoroll@skia.org Roll Skia from 1cb13a21b547 to 297dbc32a6c7 (4 revisions) (flutter/flutter#170809)
2025-06-18 engine-flutter-autoroll@skia.org Roll Packages from 25d4fa4 to 715a0a5 (2 revisions) (flutter/flutter#170808)
2025-06-18 engine-flutter-autoroll@skia.org Roll Skia from 0a106c038cd0 to 1cb13a21b547 (1 revision) (flutter/flutter#170801)
2025-06-18 derekx@google.com Add `--profile-microtasks` switch (flutter/flutter#170690)
2025-06-18 engine-flutter-autoroll@skia.org Roll Skia from ff7fffa5dac5 to 0a106c038cd0 (3 revisions) (flutter/flutter#170795)
2025-06-18 87239766+thakaredipali@users.noreply.github.com Add example for CupertinoExpansionTile transition modes (flutter/flutter#170335)
2025-06-18 stanleycocoa@gmail.com feat: Add radius to DividerThemeData. (flutter/flutter#169739)
2025-06-18 engine-flutter-autoroll@skia.org Roll Skia from 75af9450b121 to ff7fffa5dac5 (3 revisions) (flutter/flutter#170772)
2025-06-17 98614782+auto-submit[bot]@users.noreply.github.com Reverts "add run_gradle_lock_files_check.dart for new PR's that modify gradle files (#169245)" (flutter/flutter#170770)
2025-06-17 30870216+gaaclarke@users.noreply.github.com Started bridging the scene delegate to the lifecycle delegate for shortcuts (flutter/flutter#170180)
2025-06-17 jonahwilliams@google.com [ui] npot display_list allocation. (flutter/flutter#170447)
2025-06-17 kevmoo@users.noreply.github.com Prefer .of over .from (flutter/flutter#170750)
2025-06-17 47866232+chunhtai@users.noreply.github.com Fix RawGestureDetector semantics (flutter/flutter#170549)
2025-06-17 runar@socialscreen.no Use correct type for filterIdentifier (flutter/flutter#170343)
2025-06-17 matanlurey@users.noreply.github.com Remove and inline `license_header.txt` (flutter/flutter#170475)
2025-06-17 muhatashim@google.com add run_gradle_lock_files_check.dart for new PR's that modify gradle files (flutter/flutter#169245)
2025-06-17 engine-flutter-autoroll@skia.org Roll Dart SDK from 4fad61257b29 to b32559bca3cc (3 revisions) (flutter/flutter#170746)
2025-06-17 kevinjchisholm@google.com [release] Sync stable changelog to master (flutter/flutter#170691)
2025-06-17 engine-flutter-autoroll@skia.org Roll Packages from 03a6abb to 25d4fa4 (5 revisions) (flutter/flutter#170743)
2025-06-17 bkonyi@google.com [ Widget Preview ] Remove support for synthetic package:flutter_gen (flutter/flutter#170602)
2025-06-17 engine-flutter-autoroll@skia.org Roll Skia from 8879db3b3319 to 75af9450b121 (4 revisions) (flutter/flutter#170739)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
engine flutter/engine repository. See also e: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Quick Actions Not Triggered When App is in Background
4 participants