-
Notifications
You must be signed in to change notification settings - Fork 6k
[macOS] Use CVDisplayLink to drive repaint #49159
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
4189a33
to
b60b239
Compare
9423f12
to
e06c2c6
Compare
@cbracken, I think this is in good enough shape for review. |
4d508d2
to
c579a92
Compare
shell/platform/darwin/macos/framework/Source/FlutterCompositor.mm
Outdated
Show resolved
Hide resolved
shell/platform/darwin/macos/framework/Source/FlutterDisplayLink.mm
Outdated
Show resolved
Hide resolved
c579a92
to
41da795
Compare
@knopp is anything blocking this PR? |
@knopp Chris is out sick and may be delayed in reviewing this. Apologies for the delay. |
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.
A few more quick comments.
@@ -1029,6 +1088,13 @@ - (void)engineCallbackOnPreEngineRestart { | |||
} | |||
} | |||
|
|||
- (void)onVSync:(uintptr_t)baton { | |||
@synchronized(_vsyncWaiters) { | |||
FlutterVSyncWaiter* waiter = [_vsyncWaiters objectForKey:@(kFlutterImplicitViewId)]; |
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'm assuming we'll need to generalise this for multi-views, in which case, you'll want to add a TODO
here to wire up the proper view ID with an issue link. You may need to file a new subissue under flutter/flutter#142845 if nothing existing fits.
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 added a TODO for this. Right now it seems a bit unclear how exactly vsync is going to work with multiview. We might not have a viewId available.
At least for the multiview MVP we'll probably use some heuristic for this - i.e. if views are on different displays use waiter for view on primary display, or with display with higher refresh. We'll cross that bridge when we get there, but either way this should be a minor change.
shell/platform/darwin/macos/framework/Source/FlutterThreadSynchronizer.h
Outdated
Show resolved
Hide resolved
b9c3e77
to
5c2c131
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.
if (screen != nil) { | ||
// https://developer.apple.com/documentation/appkit/nsscreen/1388360-devicedescription?language=objc | ||
_display_id = (CGDirectDisplayID)[ | ||
[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; |
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.
Sure would have been nice if they'd provided a const NSString for this key! Thanks for the doc link to explain it.
#include "flutter/fml/synchronization/waitable_event.h" | ||
#include "flutter/testing/testing.h" | ||
|
||
#import <AppKit/AppKit.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.
nit: standard C/Obj-C headers like this go after the associated header (FlutterDisplayLink.h) but before the local flutter headers.
At some point we'll get round do adding a better header lint, though the associated header is sometimes tricky to figure out.
d8055c6
to
a4910bc
Compare
2461280c38 Roll Fuchsia Linux SDK from JCdhkDSFXzHyPuP4I... to T1xAi_ww_mWEiDkVN... (flutter/engine#51011) 8940ea0887 Code consistency fixes in FlScrollingManager (flutter/engine#50959) 21474ee4a4 [macOS] Use CVDisplayLink to drive repaint (flutter/engine#49159) 6f7b939568 Fail lazily when 1+ Skia gold comparions fail. (flutter/engine#51010) 249daf5512 Adjust Android emulator test timeouts (flutter/engine#51004)
This reverts commit 21474ee.
The original PR assumed that `fml::TimePoint` has same base as `CACurrentMediaTime()`. However due to recent change in Dart SDK that's no longer true. Dart SDK [replaced](https://dart-review.googlesource.com/c/sdk/+/348044?tab=comments) call to `mach_absolute_time` with `clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW)`, while `CACurrentMediaTime()` corresponds to `CLOCK_UPTIME_RAW`. This needs to be fixed either in Dart SDK dart-lang/sdk#55071 or the original PR needs to be relanded with appropriate conversions. This reverts commit 21474ee. *Replace this paragraph with a description of what this PR is changing or adding, and why. Consider including before/after screenshots.* *List which issues are fixed by this PR. You must list at least one issue.* *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] 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. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I signed the [CLA]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style [testing the engine]: https://github.com/flutter/flutter/wiki/Testing-the-engine [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat
…9159)" (flutter#51095)" This reverts commit dd3383d.
…9159)" (flutter#51095)" This reverts commit dd3383d.
Is there any possibility of this getting merged again? |
|
@knopp thank you so much for this! Can't wait to see the difference. Very excited. |
Fixes flutter/flutter#49757
This PR synchronises updates with display refresh allowing for true 120hz repaint. It also enforces frame pacing resulting in smoother experience at both 60hz and 120hz.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.