Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,11 @@ - (instancetype)initWithView:(NSView*)view {
- (void)invalidate {
@synchronized(self) {
FML_DCHECK([NSThread isMainThread]);
[_view removeFromSuperview];
// Unregister observer before removing the view to ensure
// that the viewDidChangeWindow notification is not received
// while in @synchronized block.
[[NSNotificationCenter defaultCenter] removeObserver:self];
[_view removeFromSuperview];
_view = nil;
_delegate = nil;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,14 @@ static void BusyWait(CFTimeInterval duration) {
CFRunLoopStop(CFRunLoopGetCurrent());
}];

__block CFTimeInterval expectedStartUntil;
// Warm up tick is scheduled immediately in a scheduled block. Schedule another
// block here to determine the maximum time when the warm up tick should be
// scheduled.
[waiter waitForVSync:kWarmUpBaton];
[[NSRunLoop currentRunLoop] performBlock:^{
expectedStartUntil = CACurrentMediaTime();
}];

// Reference vsync to setup phase.
CFTimeInterval now = CACurrentMediaTime();
Expand All @@ -166,15 +173,22 @@ static void BusyWait(CFTimeInterval duration) {
// Vsync without baton should pause the display link.
[displayLink tickWithTimestamp:now + 3.5 * displayLink.nominalOutputRefreshPeriod
targetTimestamp:now + 5 * displayLink.nominalOutputRefreshPeriod];
// Make sure to run the timer scheduled in display link callback.
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.02, NO);

CFTimeInterval start = CACurrentMediaTime();
while (!displayLink.paused) {
// Make sure to run the timer scheduled in display link callback.
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.02, NO);
if (CACurrentMediaTime() - start > 1.0) {
break;
}
}
ASSERT_TRUE(displayLink.paused);

EXPECT_EQ(entries.size(), size_t(4));

// Warm up frame should be presented as soon as possible.
EXPECT_TRUE(fabs(entries[0].timestamp - now) < 0.005);
EXPECT_TRUE(fabs(entries[0].targetTimestamp - now) < 0.005);
EXPECT_TRUE(entries[0].timestamp <= expectedStartUntil);
EXPECT_TRUE(entries[0].targetTimestamp <= expectedStartUntil);
EXPECT_EQ(entries[0].baton, kWarmUpBaton);

EXPECT_DOUBLE_EQ(entries[1].timestamp, now + displayLink.nominalOutputRefreshPeriod);
Expand Down