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

Conversation

@iskakaushik
Copy link
Contributor

No description provided.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@iskakaushik iskakaushik force-pushed the embedder_external_texture_metal branch 3 times, most recently from 4fe5381 to 7d232ef Compare February 10, 2021 16:58
Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

I think some more clarity about the ownership of the texture handles in the documentation for embedder.h would be great. Other than that, a few nits about error handling and such.

Can we write a test for this on the Mac embedder_unittests harness?

/// Supported textures are YUVA and RGBA, in case of YUVA we expect 2 texture
/// handles to be provided by the embedder, Y first and UV next. In case of
/// RGBA only one should be passed.
/// These are individually aliases for id<MTLTexture> which will be released
Copy link
Member

Choose a reason for hiding this comment

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

Can you clarify the lifecycle of these handles? Is it transfer-in or transfer-none (in which case the engine will retain them)? I'd prefer the latter as its easier to reason about in case of errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, these are transfer-none, I improved the documentation.

@iskakaushik iskakaushik force-pushed the embedder_external_texture_metal branch from 7d232ef to a855fa4 Compare February 11, 2021 21:42
@iskakaushik
Copy link
Contributor Author

@chinmaygarde i've also added a test

@iskakaushik
Copy link
Contributor Author

@chinmaygarde friendly ping on this :-)

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Sorry about the slow reviews, this is a lot of context to page in and the stability guarantees around the embedder API need careful review. I think other than the minor handle leak and the const-ness of the textures struct field, this patch is good to go. I'd still like to have a unit-test that covers the use of this API from the embedders perspective but maybe we can handle that in a followup.

size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
FlutterMetalExternalTexture* texture =
new FlutterMetalExternalTexture();
if (!ptr(user_data, texture_identifier, width, height, texture)) {
Copy link
Member

Choose a reason for hiding this comment

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

In case of error, the texture struct is leaked. IMO, it would be better to use a unique pointer to begin with instead of using a raw pointer first and the wrapping it later in a an auto pointer.

int64_t /* texture identifier */,
size_t /* width */,
size_t /* height */,
FlutterMetalExternalTexture* /* texture out */);
Copy link
Member

Choose a reason for hiding this comment

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

Can we remove the out here? We aren't actually passing ownership of the texture out to the embedder. The embedder is only meant to populate the fields on this structs.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I just realized. If the caller is meant to populate the fields of this struct, the textures handle cannot be const. Sorry about that suggestion. Can we back just that one bit out? BTW, an embedder_unittest that creates an engine instance using the Metal renderer config and populates the texture would have caught this. I realize that you have a test that just covers the new subsystem, but there are no tests that cover the embedders use of this API. Can we close this gap as well please?

int64_t texture_identifier, size_t width,
size_t height) -> std::unique_ptr<FlutterMetalExternalTexture> {
FlutterMetalExternalTexture* texture =
new FlutterMetalExternalTexture();
Copy link
Member

Choose a reason for hiding this comment

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

This constructor will not populate the struct_size field of FlutterMetalExternalTexture. Just like the engine cares about not reading past the end of the struct in case of versioning mismatches, the embedder might perform similar checks.

@iskakaushik iskakaushik force-pushed the embedder_external_texture_metal branch from 4d8d025 to 967e0a4 Compare February 18, 2021 18:27
@chinmaygarde
Copy link
Member

Thanks for the updates. Looks great!

@iskakaushik iskakaushik merged commit c902a16 into flutter:master Feb 18, 2021
@iskakaushik iskakaushik deleted the embedder_external_texture_metal branch February 18, 2021 19:35
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 18, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 19, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 19, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 19, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 19, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 19, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 19, 2021
hjfreyer pushed a commit to hjfreyer/engine that referenced this pull request Mar 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants