-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Migrate FlutterUIPressProxy, ios_context*, rendering_api_selection, and a few other files to ARC #51633
Conversation
if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) { | ||
auto device = MTLCreateSystemDefaultDevice(); | ||
ios_version_supports_metal = [device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v3]; | ||
[device release]; |
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.
This kicked off a yak shave to remove this code by removing SHELL_ENABLE_METAL
I'll let that merge and then rebase this on top.
398e54a
to
7a8c5e9
Compare
ba7005b
to
cef18e6
Compare
@@ -2,9 +2,13 @@ | |||
// Use of this source code is governed by a BSD-style license that can be | |||
// found in the LICENSE file. | |||
|
|||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h" | |||
|
|||
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" |
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.
Why this order change? Does the engine not follow the suggested style guide header order where framework imports are before non-associated-header project imports?
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.
There seem to be many places in the engine that don't follow the guidelines. In this case I believe I should have made it:
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h"
#import <UIKit/UIKit.h>
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
#import <UIKit/UIKit.h> | ||
|
||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h" | ||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterUIPressProxy () | ||
@property(nonatomic, readonly) UIPress* press; |
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.
Were these properties accidentally weak before and it just hadn't happened to break anything?
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.
I guess? The usages look like this:
engine/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Lines 1885 to 1889 in fef8499
[self handlePressEvent:[[[FlutterUIPressProxy alloc] initWithPress:press | |
withEvent:event] autorelease] | |
nextAction:^() { | |
[super pressesBegan:[NSSet setWithObject:press] withEvent:event]; | |
}]; |
so maybe press
and event
are being retained in the nextAction
block? I don't see any obvious bugs about 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.
Interesting - yeah seems like this should previously have been explicitly strong
, and maybe worked because (I assume) it's retained in that map we create to pointer events being sent to the framework until we get a response? (Didn't look but IIRC we hold onto them there)
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{ | ||
[[darwin_context_metal_impeller_ createExternalTextureWithIdentifier:texture_id | ||
texture:texture] retain]}); | ||
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{[darwin_context_metal_impeller_ |
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.
Do we still need the scoped_nsobject here?
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.
Ideally the answer should be no, but since scoped_nsobject is ARC-friendly, we should be safe to do those in a followup patch if preferred.
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.
ios_context_->CreateExternalTexture
is only called from mrc platform_view_ios
:
engine/shell/platform/darwin/ios/platform_view_ios.mm
Lines 139 to 140 in a9a4496
RegisterTexture(ios_context_->CreateExternalTexture( | |
texture_id, fml::scoped_nsobject<NSObject<FlutterTexture>>{[texture retain]})); |
I'm going to hold off on removing scoped_nsobject from this signature until I can remove it there as well. Do you foresee any issues with 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.
Should be fine to keep scoped_nsobject
s since we have the multi-mode compliant version.
@@ -52,8 +54,7 @@ | |||
fml::scoped_nsobject<NSObject<FlutterTexture>> texture) { | |||
return std::make_unique<IOSExternalTextureMetal>( | |||
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{ | |||
[[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id | |||
texture:texture] retain]}); | |||
[darwin_context_metal_ createExternalTextureWithIdentifier:texture_id texture:texture]}); |
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.
Same question here.
@@ -5,6 +5,8 @@ | |||
#import "flutter/shell/platform/darwin/ios/ios_external_texture_metal.h" | |||
#include "flow/layers/layer.h" | |||
|
|||
FLUTTER_ASSERT_ARC | |||
|
|||
namespace flutter { | |||
|
|||
IOSExternalTextureMetal::IOSExternalTextureMetal( |
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 convert this scoped_nsobject to a simple Obj-C object property now?
59c56fd
to
608bf8c
Compare
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.
lgtm. Whether or not you prefer to deal with scoped_nsojbect in this patch or a followup, either way seems fine to me.
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{ | ||
[[darwin_context_metal_impeller_ createExternalTextureWithIdentifier:texture_id | ||
texture:texture] retain]}); | ||
fml::scoped_nsobject<FlutterDarwinExternalTextureMetal>{[darwin_context_metal_impeller_ |
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.
Ideally the answer should be no, but since scoped_nsobject is ARC-friendly, we should be safe to do those in a followup patch if preferred.
#import <UIKit/UIKit.h> | ||
|
||
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterUIPressProxy.h" | ||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterUIPressProxy () | ||
@property(nonatomic, readonly) UIPress* press; |
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.
Interesting - yeah seems like this should previously have been explicitly strong
, and maybe worked because (I assume) it's retained in that map we create to pointer events being sent to the framework until we get a response? (Didn't look but IIRC we hold onto them there)
608bf8c
to
224f6d2
Compare
@@ -25,8 +25,6 @@ class IOSContextMetalImpeller final : public IOSContext { | |||
|
|||
~IOSContextMetalImpeller(); | |||
|
|||
fml::scoped_nsobject<FlutterDarwinContextMetalSkia> GetDarwinContext() const; |
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.
"Hmm, why is IOSContextMetalImpeller
returning FlutterDarwinContextMetalSkia
?"
It's dead code.
224f6d2
to
dfd937d
Compare
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 "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). 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. |
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayer.h" | ||
|
||
FLUTTER_ASSERT_ARC | ||
|
||
namespace flutter { | ||
|
||
bool ShouldUseMetalRenderer() { | ||
bool ios_version_supports_metal = false; | ||
if (@available(iOS METAL_IOS_VERSION_BASELINE, *)) { | ||
auto device = MTLCreateSystemDefaultDevice(); |
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.
Optional nit: I don't think this meets the style guide guidance on auto
, since I couldn't tell what the type was; I would give this an explicit type instead.
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.
Done.
dfd937d
to
d4899bb
Compare
auto label is removed for flutter/engine/51633, due to - The status or check suite Mac mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…#52148) Clean up headers in FlutterChannelKeyResponder and FlutterSpellCheckPlugin. Migrate to ARC. Move `FlutterSpellCheckResult` interface into the .mm since it's only used there. Part of flutter/flutter#137801. Blocked by #51633 `FlutterUIPressProxy`
…lection, and a few other files to ARC (flutter/engine#51633)
…lection, and a few other files to ARC (flutter/engine#51633)
…146857) flutter/engine@4d69c0c...e7d8c62 2024-04-16 magder@google.com Migrate FlutterChannelKeyResponder and FlutterSpellCheckPlugin to ARC (flutter/engine#52148) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from b83b6bf7174f to e335a0a11aa0 (1 revision) (flutter/engine#52175) 2024-04-16 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] remove most temporary allocation during polyline generation. (#52131)" (flutter/engine#52177) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from d506a3d526f7 to b83b6bf7174f (2 revisions) (flutter/engine#52173) 2024-04-16 magder@google.com Migrate FlutterUIPressProxy, ios_context*, rendering_api_selection, and a few other files to ARC (flutter/engine#51633) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from 98dbba281a84 to d506a3d526f7 (2 revisions) (flutter/engine#52170) 2024-04-16 skia-flutter-autoroll@skia.org Roll Dart SDK from f2464b2892a1 to 57d7cba5bc3d (1 revision) (flutter/engine#52168) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from 300741074b41 to 98dbba281a84 (11 revisions) (flutter/engine#52167) 2024-04-16 30870216+gaaclarke@users.noreply.github.com [Impeller] removes advanced plus blending (flutter/engine#52163) 2024-04-16 jonahwilliams@google.com [Impeller] remove most temporary allocation during polyline generation. (flutter/engine#52131) 2024-04-16 jason-simmons@users.noreply.github.com Roll reclient, libpng, and zlib (flutter/engine#52072) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jsimmons@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#146857) flutter/engine@4d69c0c...e7d8c62 2024-04-16 magder@google.com Migrate FlutterChannelKeyResponder and FlutterSpellCheckPlugin to ARC (flutter/engine#52148) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from b83b6bf7174f to e335a0a11aa0 (1 revision) (flutter/engine#52175) 2024-04-16 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] remove most temporary allocation during polyline generation. (flutter#52131)" (flutter/engine#52177) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from d506a3d526f7 to b83b6bf7174f (2 revisions) (flutter/engine#52173) 2024-04-16 magder@google.com Migrate FlutterUIPressProxy, ios_context*, rendering_api_selection, and a few other files to ARC (flutter/engine#51633) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from 98dbba281a84 to d506a3d526f7 (2 revisions) (flutter/engine#52170) 2024-04-16 skia-flutter-autoroll@skia.org Roll Dart SDK from f2464b2892a1 to 57d7cba5bc3d (1 revision) (flutter/engine#52168) 2024-04-16 skia-flutter-autoroll@skia.org Roll Skia from 300741074b41 to 98dbba281a84 (11 revisions) (flutter/engine#52167) 2024-04-16 30870216+gaaclarke@users.noreply.github.com [Impeller] removes advanced plus blending (flutter/engine#52163) 2024-04-16 jonahwilliams@google.com [Impeller] remove most temporary allocation during polyline generation. (flutter/engine#52131) 2024-04-16 jason-simmons@users.noreply.github.com Roll reclient, libpng, and zlib (flutter/engine#52072) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jsimmons@google.com,rmistry@google.com,zra@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Smart pointers support ARC as of #47612, and the unit tests were migrated in #48162.
Migrate some files from MRC to ARC. These files do not themselves import any MRC files, only ARC-ified files like
FlutterMetalLayer.h
, making them leaf nodes in the dependency graph of MRC files. Just doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues.Part of flutter/flutter#137801.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.