-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
// VSyncClient has released the CADisplayLink. | ||
XCTAssertNil(weakLink); |
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 doesn't currently pass on main with the current code.
} | ||
callback_(std::move(recorder)); | ||
} | ||
|
||
- (void)invalidate { | ||
[display_link_.get() invalidate]; | ||
[_displayLink invalidate]; | ||
_displayLink = nil; // Break retain cycle. |
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.
The test I wrote to validate the display link is released when VSyncClient
invalidates and deallocs doesn't pass without this line (and also doesn't pass on main with the current code).
@@ -130,40 +123,37 @@ - (void)onDisplayLink:(CADisplayLink*)link { | |||
|
|||
recorder->RecordVsync(frame_start_time, frame_target_time); | |||
if (_allowPauseAfterVsync) { | |||
display_link_.get().paused = YES; | |||
link.paused = YES; |
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.
Use link
passed into onDisplayLink:
instead of grabbing it again.
} | ||
|
||
} // namespace flutter | ||
|
||
@implementation VSyncClient { | ||
flutter::VsyncWaiter::Callback callback_; | ||
fml::scoped_nsobject<CADisplayLink> display_link_; | ||
CADisplayLink* _displayLink; | ||
double current_refresh_rate_; |
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, but maybe fix the other two names while you are here so they aren't inconsistent?
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.
// Strongly retain the the captured link until it is added to the runloop. | ||
CADisplayLink* localDisplayLink = _displayLink; | ||
task_runner->PostTask([localDisplayLink]() { | ||
[localDisplayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; |
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 modernization nit: NSRunLoop.currentRunLoop
since it's a property.
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.
Did a sweep of this file for dot notation and other property cleanup. Moved refreshRate
off the header since it's only used in the implementation file and made it a readonly property, and made displayRefreshRate
a class property.
} | ||
callback_(std::move(recorder)); | ||
} | ||
|
||
- (void)invalidate { | ||
[display_link_.get() invalidate]; | ||
[_displayLink invalidate]; | ||
_displayLink = nil; // Break retain cycle. | ||
} | ||
|
||
- (void)dealloc { |
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 would remove this method; it's basically a lie (and was before as well). The display link has a strong reference to this object, so it's impossible† for dealloc
to be called unless the display link has already been invalidated.
† Unless there's an overrelease, of course, but then we have other problems.
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 removed it and added a comment to -invalidate
in the header.
083937b
to
08f4b22
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
08f4b22
to
7fcab77
Compare
…146811) flutter/engine@66ad802...cba7678 2024-04-16 [email protected] Roll Dart SDK from 7d02f18b8a84 to cb0c34389d90 (1 revision) (flutter/engine#52151) 2024-04-16 [email protected] Roll Skia from 50ac1117f159 to 8013b7f1dcd3 (5 revisions) (flutter/engine#52149) 2024-04-16 49699333+dependabot[bot]@users.noreply.github.com Bump google/osv-scanner-action from 1.6.2.pre.beta1 to 1.7.1 (flutter/engine#52147) 2024-04-16 [email protected] Migrate vsync_waiter_ios to ARC (flutter/engine#52104) 2024-04-16 [email protected] Roll Skia from b159229f2174 to 50ac1117f159 (1 revision) (flutter/engine#52146) 2024-04-16 [email protected] Roll Dart SDK from 5f03197b9992 to 7d02f18b8a84 (2 revisions) (flutter/engine#52145) 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],[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
…lutter#146811) flutter/engine@66ad802...cba7678 2024-04-16 [email protected] Roll Dart SDK from 7d02f18b8a84 to cb0c34389d90 (1 revision) (flutter/engine#52151) 2024-04-16 [email protected] Roll Skia from 50ac1117f159 to 8013b7f1dcd3 (5 revisions) (flutter/engine#52149) 2024-04-16 49699333+dependabot[bot]@users.noreply.github.com Bump google/osv-scanner-action from 1.6.2.pre.beta1 to 1.7.1 (flutter/engine#52147) 2024-04-16 [email protected] Migrate vsync_waiter_ios to ARC (flutter/engine#52104) 2024-04-16 [email protected] Roll Skia from b159229f2174 to 50ac1117f159 (1 revision) (flutter/engine#52146) 2024-04-16 [email protected] Roll Dart SDK from 5f03197b9992 to 7d02f18b8a84 (2 revisions) (flutter/engine#52145) 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],[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
Smart pointers support ARC as of #47612, and the unit tests were migrated in #48162.
Migrate
vsync_waiter_ios
from MRC to ARC.Part of flutter/flutter#137801.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.