Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@cyanglaz
Copy link
Contributor

@cyanglaz cyanglaz commented Mar 2, 2023

First patch for iOS Embedder api migration.
The iOS Embedder API implementation is going to be hidden behind this flag during the migration.
This PR introduced:

  1. A command line flag enable-embedder-api, which can also be used for Android when we want to migrate it to embedder API.
  2. An info.plist flag FLTEnableIOSEmbedderAPI, which is used on iOS.
    Both flag acts the same on iOS and either one of them being true should run iOS embedder with the embedder API.
    This flag defaults to false.

First step of flutter/flutter#112232

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@cyanglaz cyanglaz requested a review from jmagman March 2, 2023 19:05
@cyanglaz cyanglaz marked this pull request as ready for review March 2, 2023 19:06
@cyanglaz cyanglaz force-pushed the embedder_api_patch1_flag branch from e2f883d to 8942090 Compare March 2, 2023 19:07
Copy link
Member

@jmagman jmagman left a comment

Choose a reason for hiding this comment

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

Minor nits. Looks like the FlutterEngineTest are crashing though.

"requested sampling value, MSAA will be disabled.")
DEF_SWITCH(EnableIOSEmbedderAPI,
"enable-embedder-api",
"Enable the embedder api. Defaults to false. Ignored if the "
Copy link
Member

Choose a reason for hiding this comment

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

Alternatively you could say "iOS only" for now, up to you though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My first version was actually "iOS only" but wanted to keep it future proof for android. I will revert back to "iOS only", it's less confusing.

@cyanglaz cyanglaz force-pushed the embedder_api_patch1_flag branch from 2d99212 to b2f8505 Compare March 2, 2023 23:02

- (void)testCreate {
id project = OCMClassMock([FlutterDartProject class]);
FlutterDartProject* project = [[FlutterDartProject alloc] init];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jmagman The test failure was due to the mock project doesn't have the setting ivar mocked. For these tests, I either removed the project completely or used a real project object. There was no reason to mock the project at the first place.

@cyanglaz cyanglaz requested a review from jmagman March 3, 2023 18:59
draft

draft

fix

fix test

fix test

revuew

fix tests
Comment on lines 1400 to 1402
- (BOOL)enableEmbedderAPI {
return _enableEmbedderAPI;
}
Copy link
Member

Choose a reason for hiding this comment

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

This didn't get synthesized for you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They should. The getters were from the old implementation. I forgot to remove this and the below getters.
Will remove now.

#pragma mark - Embedder API properties

// Function pointers for interacting with the embedder.h API.
@property(nonatomic, assign) BOOL enableEmbedderAPI;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@property(nonatomic, assign) BOOL enableEmbedderAPI;
@property(nonatomic, assign, readonly) BOOL enableEmbedderAPI;

Copy link
Contributor

Choose a reason for hiding this comment

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

probably also wanna remove assign if do readonly

Copy link
Member

Choose a reason for hiding this comment

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

I think you still want to keep assign (as opposed to retain or copy) for the primitive? I don't think the readwrite/readonly impacts that.

Copy link
Contributor

Choose a reason for hiding this comment

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

iirc assign/retain/copy etc only affect how the setters are synthesized. readonly won't synthesize the setter at all in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked at it again. It is in the .mm file. So I will remove the readonly and keep the assign.

@hellohuanlin
Copy link
Contributor

Both flag acts the same on iOS and either one of them being true should run iOS embedder with the embedder API.

Can you clarify why do we need both flags and when to use which one?

@jmagman
Copy link
Member

jmagman commented Mar 3, 2023

Both flag acts the same on iOS and either one of them being true should run iOS embedder with the embedder API.

Can you clarify why do we need both flags and when to use which one?

The tool flag would be for a single flutter run invocation, and it gets passed on as a launch argument to the app, read by the engine. The Info.plist bool makes it persistent for the app across runs, so you can open it in Xcode and have it be passed into the engine without actually setting a launch argument in the scheme.
We do the same pattern for other experimental features.

@cyanglaz
Copy link
Contributor Author

cyanglaz commented Mar 3, 2023

Can you clarify why do we need both flags and when to use which one?

The info.plist is for running from XCode, the commandline flag is for running from terminal without the need to edit the info.plist.

/// Enable embedder api on the embedder.
///
/// This is ignored on the platforms that use the embedder_api by default.
bool enable_embedder_api = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe more self-descriptive naming like enable_embedder_api_for_ios (or enable_embedder_api_for_mobile if wanna re-use for android)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to keep it generic so it could be reused by android.
I also wanted to keep it the same name as the command line flag. And I would like the command line flag to be short for easier typing when testing ;p

@cyanglaz cyanglaz force-pushed the embedder_api_patch1_flag branch from b624b14 to 99a48ca Compare March 3, 2023 20:56
@cyanglaz cyanglaz added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 3, 2023
@auto-submit auto-submit bot merged commit 85d0e15 into flutter:main Mar 3, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants