This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
Migrate FlutterViewController to ARC #55669
Merged
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7f9c045
iOS: Migrate FlutterViewController to ARC
cbracken 60ea3e5
Migrate _engine to property
cbracken 7e46ed2
Migrate _flutterView to property
cbracken b20610c
Migrate _flutterViewRenderedCallback to property
cbracken 385e7c7
Migrate _statusBarStyle to property
cbracken e702f44
Migrate _initialized, _viewOpaque, _engineNeedsLaunch to properties
cbracken e9b7438
Migrate _ongoingTouches to property
cbracken 4245120
Migrate _scrollView to property
cbracken a451b9f
Migrate _keyboardAnimationView to property
cbracken b4f201e
Migrate _keyboardSpringAnimation to property
cbracken cbb8426
Migrate scrollInertiaEvent ivars to properties
cbracken 2606754
Make a couple more references to self weak
cbracken 950ef83
Avoid capturing self via super
cbracken 65129c2
Eliminate use of scoped_nsobject
cbracken b5b4978
Update TODO
cbracken f274f24
Fix typo
cbracken 134e6d3
ivar stuff
cbracken 03ec71b
Moar property syntax
cbracken 258e7e6
Add engine non-nil asserts
cbracken 5c9923b
Set explicit type for my own sanity
cbracken 445202b
One more property
cbracken bd4af67
err YES, not true. NO, not false.
cbracken e4d6308
Let's maybe assert ARC
cbracken e7360f4
retain to strong
cbracken be400a2
Fix self capture
cbracken 25a6263
Revert to previous setup local then assign
cbracken 496e4f5
Remove NSAsserts on self.engine -- though we probably do want em even…
cbracken f757a08
review feedback: comments and todos
cbracken f3c808e
review feedback: moar strongSelf
cbracken c492fcc
Extract keyboardAnimationCallback helper
cbracken 861d6a0
Extract onFirstFrameRendered
cbracken be71895
Format
cbracken 18781e1
review feedback: method name
cbracken 49800bb
Hangs head in shame
cbracken 4f9cf85
Weak engine is strong
cbracken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
Weak engine is strong
Previously we held a scoped_nsobject<FlutterEngine> as a strong reference ivar. This restores that behaviour.
- Loading branch information
commit 4f9cf856c84f54ddad46b710072583ae967a194b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,6 +156,7 @@ @implementation FlutterViewController { | |
| // TODO(cbracken): https://github.com/flutter/flutter/issues/137801 | ||
| // Eliminate once we can use weak pointers in platform_view_ios.h. | ||
| std::unique_ptr<fml::WeakNSObjectFactory<FlutterViewController>> _weakFactory; | ||
| FlutterEngine* _engine; | ||
|
|
||
| flutter::ViewportMetrics _viewportMetrics; | ||
| MouseState _mouseState; | ||
|
|
@@ -307,6 +308,10 @@ - (void)performCommonViewControllerInitialization { | |
| [self setUpNotificationCenterObservers]; | ||
| } | ||
|
|
||
| - (FlutterEngine*)engine { | ||
| return _engine; | ||
| } | ||
|
|
||
| - (fml::WeakNSObject<FlutterViewController>)getWeakNSObject { | ||
| return _weakFactory->GetWeakNSObject(); | ||
| } | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still needed by FlutterEngine, which calls this, and puts it into a field in a C++ class in platform_view_ios.h, which I'll migrate in the next patch. |
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Notice that previously we held
_engineas a strong ref (thefml::scoped_nsobjectabove) but that the header declares it as a weak property:engine/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h
Line 236 in 33f9064
Meanwhile, the engine owns FlutterViewController weakly:
engine/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Line 157 in 33f9064
To preserve existing semantics, I'm adding back a strong ref here. We need the getter too so that the compiler doesn't complain that the ivar should be declared as
__weak FlutterEngine* _engine.We should probably update the header to be a strong property, but it's a public header and I don't think that ARC migration is the right spot to change semantics in our public APIs.