Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
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 Oct 4, 2024
60ea3e5
Migrate _engine to property
cbracken Oct 4, 2024
7e46ed2
Migrate _flutterView to property
cbracken Oct 4, 2024
b20610c
Migrate _flutterViewRenderedCallback to property
cbracken Oct 4, 2024
385e7c7
Migrate _statusBarStyle to property
cbracken Oct 4, 2024
e702f44
Migrate _initialized, _viewOpaque, _engineNeedsLaunch to properties
cbracken Oct 4, 2024
e9b7438
Migrate _ongoingTouches to property
cbracken Oct 4, 2024
4245120
Migrate _scrollView to property
cbracken Oct 4, 2024
a451b9f
Migrate _keyboardAnimationView to property
cbracken Oct 4, 2024
b4f201e
Migrate _keyboardSpringAnimation to property
cbracken Oct 4, 2024
cbb8426
Migrate scrollInertiaEvent ivars to properties
cbracken Oct 4, 2024
2606754
Make a couple more references to self weak
cbracken Oct 4, 2024
950ef83
Avoid capturing self via super
cbracken Oct 4, 2024
65129c2
Eliminate use of scoped_nsobject
cbracken Oct 4, 2024
b5b4978
Update TODO
cbracken Oct 4, 2024
f274f24
Fix typo
cbracken Oct 4, 2024
134e6d3
ivar stuff
cbracken Oct 4, 2024
03ec71b
Moar property syntax
cbracken Oct 4, 2024
258e7e6
Add engine non-nil asserts
cbracken Oct 4, 2024
5c9923b
Set explicit type for my own sanity
cbracken Oct 4, 2024
445202b
One more property
cbracken Oct 4, 2024
bd4af67
err YES, not true. NO, not false.
cbracken Oct 4, 2024
e4d6308
Let's maybe assert ARC
cbracken Oct 4, 2024
e7360f4
retain to strong
cbracken Oct 5, 2024
be400a2
Fix self capture
cbracken Oct 5, 2024
25a6263
Revert to previous setup local then assign
cbracken Oct 5, 2024
496e4f5
Remove NSAsserts on self.engine -- though we probably do want em even…
cbracken Oct 5, 2024
f757a08
review feedback: comments and todos
cbracken Oct 18, 2024
f3c808e
review feedback: moar strongSelf
cbracken Oct 18, 2024
c492fcc
Extract keyboardAnimationCallback helper
cbracken Oct 18, 2024
861d6a0
Extract onFirstFrameRendered
cbracken Oct 18, 2024
be71895
Format
cbracken Oct 18, 2024
18781e1
review feedback: method name
cbracken Oct 18, 2024
49800bb
Hangs head in shame
cbracken Oct 22, 2024
4f9cf85
Weak engine is strong
cbracken Oct 25, 2024
File filter

Filter by extension

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
Next Next commit
Migrate _ongoingTouches to property
  • Loading branch information
cbracken committed Oct 26, 2024
commit e9b7438ca0970ccc5ffdaf80daaebf75f4e25903
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ @interface FlutterViewController () <FlutterBinaryMessenger, UIScrollViewDelegat
@property(nonatomic, assign) BOOL isHomeIndicatorHidden;
@property(nonatomic, assign) BOOL isPresentingViewControllerAnimating;

@property(nonatomic, strong) NSMutableSet<NSNumber*>* ongoingTouches;
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be copy?

/**
* Whether we should ignore viewport metrics updates during rotation transition.
*/
Expand Down Expand Up @@ -133,7 +134,6 @@ @implementation FlutterViewController {
std::unique_ptr<fml::WeakNSObjectFactory<FlutterViewController>> _weakFactory;

flutter::ViewportMetrics _viewportMetrics;
fml::scoped_nsobject<NSMutableSet<NSNumber*>> _ongoingTouches;
// This scroll view is a workaround to accommodate iOS 13 and higher. There isn't a way to get
// touches on the status bar to trigger scrolling to the top of a scroll view. We place a
// UIScrollView with height zero and a content offset so we can get those events. See also:
Expand Down Expand Up @@ -181,7 +181,7 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine
opaque:self.isViewOpaque
enableWideGamut:engine.project.isWideGamutEnabled];
_weakFactory = std::make_unique<fml::WeakNSObjectFactory<FlutterViewController>>(self);
_ongoingTouches.reset([[NSMutableSet alloc] init]);
_ongoingTouches = [[NSMutableSet alloc] init];

[self performCommonViewControllerInitialization];
[engine setViewController:self];
Expand Down Expand Up @@ -259,7 +259,7 @@ - (void)sharedSetupWithProject:(nullable FlutterDartProject*)project
enableWideGamut:project.isWideGamutEnabled];
[self.engine createShell:nil libraryURI:nil initialRoute:initialRoute];
_engineNeedsLaunch = YES;
_ongoingTouches.reset([[NSMutableSet alloc] init]);
_ongoingTouches = [[NSMutableSet alloc] init];
[self loadDefaultSplashScreenView];
[self performCommonViewControllerInitialization];
}
Expand Down Expand Up @@ -921,12 +921,12 @@ - (void)viewWillTransitionToSize:(CGSize)size
}

- (void)flushOngoingTouches {
if (self.engine && _ongoingTouches.get().count > 0) {
auto packet = std::make_unique<flutter::PointerDataPacket>(_ongoingTouches.get().count);
if (self.engine && self.ongoingTouches.count > 0) {
auto packet = std::make_unique<flutter::PointerDataPacket>(self.ongoingTouches.count);
size_t pointer_index = 0;
// If the view controller is going away, we want to flush cancel all the ongoing
// touches to the framework so nothing gets orphaned.
for (NSNumber* device in _ongoingTouches.get()) {
for (NSNumber* device in self.ongoingTouches) {
// Create fake PointerData to balance out each previously started one for the framework.
flutter::PointerData pointer_data = [self generatePointerDataForFake];

Expand All @@ -946,7 +946,7 @@ - (void)flushOngoingTouches {
packet->SetPointerData(pointer_index++, pointer_data);
}

[_ongoingTouches removeAllObjects];
[self.ongoingTouches removeAllObjects];
[self.engine dispatchPointerDataPacket:std::move(packet)];
}
}
Expand Down Expand Up @@ -1196,11 +1196,11 @@ - (void)dispatchTouches:(NSSet*)touches
// if the view controller goes away.
switch (pointer_data.change) {
case flutter::PointerData::Change::kDown:
[_ongoingTouches addObject:deviceKey];
[self.ongoingTouches addObject:deviceKey];
break;
case flutter::PointerData::Change::kCancel:
case flutter::PointerData::Change::kUp:
[_ongoingTouches removeObject:deviceKey];
[self.ongoingTouches removeObject:deviceKey];
break;
case flutter::PointerData::Change::kHover:
case flutter::PointerData::Change::kMove:
Expand Down