-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[Reland3] Implements UISceneDelegate dynamically w/ FlutterLaunchEngine (#169276) #169365
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
[Reland3] Implements UISceneDelegate dynamically w/ FlutterLaunchEngine (#169276) #169365
Conversation
b89bd9e
to
8fcd82f
Compare
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.m
Show resolved
Hide resolved
|
||
func register(with registry: FlutterPluginRegistry) { | ||
GeneratedPluginRegistrant.register(with: registry) | ||
let registrar = registry.registrar(forPlugin: "battery") |
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.
@vashworth I think I may have misspoken. I was thinking we could get rid of this since we would be sending the FlutterViewController. I decided to send the FlutterPluginRegistry though since that makes more sense to send the abstraction that is more apropos. We could potentially allow people to get the binary messenger from the FlutterPluginRegistry if we wanted to get rid of it.
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 have to issue breaking changes, we might as well introduce a registry.registrar(forChannel:)
for sanity
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.
registry.registrar(forChannel:)
wouldn't quite be the right API since a registrar has a BinaryMessenger which you specify the channel name on.
Registry.binaryMessenger
would be the convenience we want but that completely circumvents the need for the registrar.
I think Registry.unaffiliatedRegistrar
would probably be what we want, something like that.
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.
Let me know if you are fine with shelving this decision for later since it's a convenience that will be added to the existing API. The PR in it's current state is just using what is already present.
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.
Ya I think we can leave it. Maybe add some comments to registrar(forPlugin:)
saying it's also ok for non-plugins? Or explain in the instruction website?
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.
Can we get the FlutterViewController and get the binary messenger from it?
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.
Can we get the FlutterViewController and get the binary messenger from it?
If someone has a FlutterViewController they can get the binary messenger and the FlutterViewController is a FlutterPluginRegistry. There's no concept the represents both of those things. Having them both doesn't make sense because accessing the binary messenger invalidates the need for a registrar.
Making register callback send in a FlutterViewController would make that possible, but I didn't want to do that because that leaves us tied to a concrete class which gives us less options in the future.
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.
Okay last ditch comment: I really dislike using forPlugin
, it's confusing since it's not a plugin. Plugin means something specific in Flutter, so I think it'd be confusing for users too.
From my understanding, forPlugin
is used to get the registrar to hook up a method channel with the plugin and/or publish the plugin. With this use case, we never intend to do those things.
What if we have another method called registrarForKey
, which basically does the same under the covers but has a slightly different intention?
Maybe something like this:
master...vashworth:flutter:registar_for_key
WDYT?
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.
That is overloading the concept of a plugin name and a key now, which are functionally the same. We know that but it is confusing to someone. "Can you have a key and a plugin name with the same values?"
It also makes people have to come up with a key which they didn't have to in the past. I think FlutterPluginRegistry.registrar
is better. It just gives you an unincorporated registrar, which matches the semantics we had previously.
We have to think hard if we want to continue to support that though.
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.
Overall looks good. left some comments
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.m
Show resolved
Hide resolved
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.h
Show resolved
Hide resolved
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterSceneDelegate.m
Show resolved
Hide resolved
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Show resolved
Hide resolved
|
||
func register(with registry: FlutterPluginRegistry) { | ||
GeneratedPluginRegistrant.register(with: registry) | ||
let registrar = registry.registrar(forPlugin: "battery") |
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 have to issue breaking changes, we might as well introduce a registry.registrar(forChannel:)
for sanity
packages/flutter_tools/lib/src/ios/migrations/uiscenedelegate_migration.dart
Show resolved
Hide resolved
@gaaclarke I think this still needs a warning somewhere in the engine that checks if they've adopted the UIScene lifecycle, like the UIKit warning that points to documentation on how to migrate. Is that possible? |
@vashworth I just added an issue for that above: #169678. It has the same problem as the static check that we want to link to the migration guide. |
engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterLaunchEngine.m
Show resolved
Hide resolved
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
## _Description of what this PR is changing or adding, and why:_ Adding breaking change notice for UISceneDelegate adoption. ## _Issues fixed by this PR (if any):_ flutter/flutter#167267 ## _PRs or commits this PR depends on (if any):_ flutter/flutter#169365 ## Presubmit checklist - [x] This PR is marked as draft with an explanation if not meant to land until a future stable release. - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Victoria Ashworth <15619084+vashworth@users.noreply.github.com> Co-authored-by: Shams Zakhour (ignore Sfshaza) <44418985+sfshaza2@users.noreply.github.com> Co-authored-by: Parker Lougheed <parlough@gmail.com>
… usage (#12095) ## _Description of what this PR is changing or adding, and why:_ Updating platform channel guidance to be inline with the breaking change: #12082 ## _Issues fixed by this PR (if any):_ ## _PRs or commits this PR depends on (if any):_ flutter/flutter#169365 #12082 ## Presubmit checklist - [x] This PR is marked as draft with an explanation if not meant to land until a future stable release. - [x] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [x] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [x] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer.
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
This PR break deep link in Flutter |
@rajveermalviya has filed that deep-links issue here: |
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
…LaunchEngine (#169276) (flutter/flutter#169365)
BREAKING CHANGE
Adopting Apple's UISceneDelegate protocol shifts the initialization order of apps. For the common cases we've made sure they will work without change. The one case that will require a change is any app that in
-[UIApplicateDelegate didFinishLaunchingWithOptions:]
assumes thatUIApplicationDelegate.window.rootViewController
is aFlutterViewController
instance. Users should follow the migration guide to update that usage.Changes since revert
It's been rebased onto the FlutterPluginRegistrant PR which was used for migration. The dynamic selection of the UISceneDelegate has been removed, instead there is a flutter tool migration to the Info.plist.
Description
fixes: #167267
design doc:
https://docs.google.com/document/d/1ZfcQOs-UKRa9jsFG84-MTFeibZTLKCvPQLxF2eskx44/edit?tab=t.0
relands #168396
relands #168914
relands #169276
Pre-launch Checklist
///
).