Skip to content

setInitialRoute is broken for iOS add-to-app #59895

Closed
@mehmetf

Description

@mehmetf

b/159359456

https://flutter.dev/docs/development/add-to-app/ios/add-flutter-screen?tab=entrypoint-library-swift-tab#route recommends

FlutterEngine *flutterEngine =
    [[FlutterEngine alloc] initWithName:@"my flutter engine"];
[[flutterEngine navigationChannel] invokeMethod:@"setInitialRoute"
                                      arguments:@"/onboarding"];
[flutterEngine run];

This does not work. The initial route comes out as default ("/"). If I initialize view controller with project (instead of engine) and use [flutterViewController setInitialRoute], it works.

Activity

added
engineflutter/engine repository. See also e: labels.
on Jun 23, 2020
Hixie

Hixie commented on Jun 23, 2020

@Hixie
Contributor

@chinmaygarde says this is more or less working as intended and that there is a workaround so I will reduce it to P3; he will update this bug shortly.

added
P1High-priority issues at the top of the work list
and removed on Jun 23, 2020
removed
P1High-priority issues at the top of the work list
on Jul 6, 2020
self-assigned this
on Jul 6, 2020
added this to the 1.21 - July 2020 milestone on Jul 6, 2020
chinmaygarde

chinmaygarde commented on Jul 7, 2020

@chinmaygarde
Member

@mehmetf : So, I am not sure how the initial recommendation on the page you linked was made. It is definitely inaccurate. Channel setup has always occurred when the underlying shell in the engine is setup. In the FlutterEngine API, the shell isn't setup till the runWithEntrypoint:libraryURI: method is called. So, I am pretty sure [flutterEngine navigationChannel] result is nil. Looking back at the history, it seems to have always worked this way with the FlutterViewController being special cased to setup the shell (and it channels) upfront to specifically work around the issue of the navigation channel being unavailable. The fix is to do the same in FlutterEngine (i.e, create the shell with Settings object in the FlutterDartProject).

The behavior described in the docs is a fair ask but it is a bit mystifying how that recommendation was made when the implementation has never worked that way. In any case, I see you bumped up the priority of this to P1. Is this now a blocker? My reading of the internal issue indicated that there was a workaround. I'll have reprioritize some other stuff if this is at indicated priority.

mehmetf

mehmetf commented on Jul 7, 2020

@mehmetf
ContributorAuthor

It is definitely inaccurate.

FWIW, I was very surprised at that recommendation as well.

Are you referring to initialize view controller with project instead of engine workaround? If so, that does not work for the user since they are an add-to-app user who wants to control how/when engine is initialized.

However, it is not a launch blocker for them for now so lowering priority to P2. We should, at the very least, fix documentation asap tho.

35 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressiona: existing-appsIntegration with existing apps via the add-to-app flowc: regressionIt was better in the past than it is nowengineflutter/engine repository. See also e: labels.platform-iosiOS applications specificallywaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @chinmaygarde@xster@Hixie@mehmetf@lds8988

    Issue actions

      setInitialRoute is broken for iOS add-to-app · Issue #59895 · flutter/flutter