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

iOS: Migrate FlutterAppDelegate to ARC #55472

Merged
merged 4 commits into from
Sep 27, 2024

Conversation

cbracken
Copy link
Member

@cbracken cbracken commented Sep 27, 2024

Migrates the FlutterAppDelegate.mm translation unit to be compiled with the -fobjc-arc compiler flag.

No test changes since no this change includes no semantic changes, and thus covered by existing tests such as testReleasesWindowOnDealloc.

Issue: flutter/flutter#137801

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 the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I'm pretty sure this patch makes me a software ARCictect.
  • 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.

@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, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

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. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@cbracken cbracken force-pushed the ios-arc-migrate-FlutterAppDelegate branch from fc0825a to 3cab92d Compare September 27, 2024 01:03
@matanlurey
Copy link
Contributor

test-exempt: No semantic changes.

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.

This imports "FlutterViewController" so that's why it wasn't done yet. We were migrating leaf -> root. That made me refactor some as I was doing the other ARC work, like #52271.

However, I'm not sure if the value of doing that is worth needing to migrate FlutterViewController and FlutterEngine monsters together (they are so snarled I couldn't break the import cycle). wdyt?

@jmagman
Copy link
Member

jmagman commented Sep 27, 2024

That made me refactor some as I was doing the other ARC work, like #52271.

Another example #52729

@cbracken
Copy link
Member Author

cbracken commented Sep 27, 2024

I'm tempted to migrate piecewise what we can safely migrate until we whittle it down to nothing. As you say, that lands us at the FlutterEngine/FlutterViewController tangle in the end. Any reason to limit ourselves to taking a leaf to root approach?

@cbracken
Copy link
Member Author

cbracken commented Sep 27, 2024

Any reason to limit ourselves to taking a leaf to root approach?

Answering my own question -- I'd likely need to look at the FlutterViewController header to answer that one. Taking a look.

Answer: it looks like there's nothing that would be problematic in there at the moment, and I'd expect the compiler to shout if anyone were to add, say, an assign property etc.

@jmagman
Copy link
Member

jmagman commented Sep 27, 2024

Any reason to limit ourselves to taking a leaf to root approach?

@stuartmorgan I thought there was a design doc for this, but I can't find it. I wasn't able to untangle the dependencies of the remaining MRC files:

"framework/Source/FlutterAppDelegate.mm",
"framework/Source/FlutterEngine.mm",
"framework/Source/FlutterEngineGroup.mm",
"framework/Source/FlutterEngine_Internal.h",
"framework/Source/FlutterHeadlessDartRunner.mm",
"framework/Source/FlutterPlatformPlugin.h",
"framework/Source/FlutterPlatformPlugin.mm",
"framework/Source/FlutterViewController.mm",
"framework/Source/FlutterViewController_Internal.h",
"framework/Source/accessibility_bridge.h",
"framework/Source/accessibility_bridge.mm",
"platform_view_ios.h",
"platform_view_ios.mm",

I'm not sure when we're even going to have the bandwidth to migrate all of those in one monster-PR, especially with merge conflicts (I sure gave up). What do you think about merging the rest individually, ignoring the dependency tree, if we commit to actually doing it all ASAP but in separate PRs? Can you think of why that's a really bad idea, vs keeping these last few MRC files around forever?

@stuartmorgan-g
Copy link
Contributor

stuartmorgan-g commented Sep 27, 2024

Any reason to limit ourselves to taking a leaf to root approach?

@stuartmorgan I thought there was a design doc for this, but I can't find it.

When we were still on the old, pre-ARC scoped_nsobject we basically had to do leaf-up because we couldn't have any transitive dependencies on scoped_nsobject or it wouldn't compile.

With the ARC-safe scoped_nsobject, I don't think there should be any ordering requirements.

Migrates the FlutterAppDelegate.mm translation unit to be compiled with
the `-fobjc-arc` compiler flag.

Issue: flutter/flutter#137801
Except in the initialiser, where `self` is not yet fully initialised.

In this case, it's a simple property so this really makes no real
difference, but best practices etc.
@cbracken cbracken force-pushed the ios-arc-migrate-FlutterAppDelegate branch from 30ffe8c to 5ff70d0 Compare September 27, 2024 21:56
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.

Thank you!

@cbracken cbracken added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 27, 2024
@auto-submit auto-submit bot merged commit e00d405 into flutter:main Sep 27, 2024
29 checks passed
@cbracken cbracken deleted the ios-arc-migrate-FlutterAppDelegate branch September 27, 2024 22:45
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 28, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 28, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 28, 2024
…155865)

flutter/engine@9c8e5cb...f3b11bc

2024-09-28 [email protected] Revert "Reland "[canvaskit] Further improve overlay optimization by splitting pictures"" (flutter/engine#55501)
2024-09-28 [email protected] Migrate `try/finally` calls to `addTearDown`. (flutter/engine#55499)
2024-09-27 [email protected] iOS: Migrate FlutterAppDelegate to ARC (flutter/engine#55472)

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 [email protected],[email protected] 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
thejitenpatel pushed a commit to thejitenpatel/flutter that referenced this pull request Oct 1, 2024
…lutter#155865)

flutter/engine@9c8e5cb...f3b11bc

2024-09-28 [email protected] Revert "Reland "[canvaskit] Further improve overlay optimization by splitting pictures"" (flutter/engine#55501)
2024-09-28 [email protected] Migrate `try/finally` calls to `addTearDown`. (flutter/engine#55499)
2024-09-27 [email protected] iOS: Migrate FlutterAppDelegate to ARC (flutter/engine#55472)

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 [email protected],[email protected] 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
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.

5 participants